Skip to content

Commit

Permalink
add goto_pos
Browse files Browse the repository at this point in the history
  • Loading branch information
brotzeit committed Dec 13, 2018
1 parent 1a61d19 commit dcb7203
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions rust_src/src/editfns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,20 @@ pub fn goto_char(position: LispObject) -> LispObject {
if position.is_marker() {
set_point_from_marker(position);
} else if let Some(num) = position.as_fixnum() {
let mut cur_buf = ThreadState::current_buffer();
let pos = clip_to_bounds(cur_buf.begv, num, cur_buf.zv);
let bytepos = unsafe { buf_charpos_to_bytepos(cur_buf.as_mut(), pos) };
unsafe { set_point_both(pos, bytepos) };
goto_char_rust(num);
} else {
wrong_type!(Qinteger_or_marker_p, position)
};
position
}

pub fn goto_pos(pos: i64) {
let mut cur_buf = ThreadState::current_buffer();
let p = clip_to_bounds(cur_buf.begv, num, cur_buf.zv);
let bytepos = unsafe { buf_charpos_to_bytepos(cur_buf.as_mut(), p) };
unsafe { set_point_both(p, bytepos) };
}

/// Return the byte position for character position POSITION.
/// If POSITION is out of range, the value is nil.
#[lisp_fn]
Expand Down
4 changes: 2 additions & 2 deletions rust_src/src/vterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::cmp;
use crate::{
cmds::forward_char,
cmds::forward_line,
editfns::{goto_char, point_min},
editfns::{goto_pos, point_min},
lisp::{defsubr, LispObject},

multibyte::LispStringRef,
Expand Down Expand Up @@ -84,7 +84,7 @@ pub unsafe extern "C" fn vterminal_refresh_screen(term: *mut vterminal) {
// vterminal height may have decreased before `invalid_end` reflects it.
let line_start = row_to_linenr(term, (*term).invalid_start);

goto_char(LispObject::from(point_min()));
goto_pos(ThreadState::current_buffer().begv);
forward_line(Some(line_start as EmacsInt));

vterminal_delete_lines(
Expand Down

0 comments on commit dcb7203

Please sign in to comment.