Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port forward point #321

Merged
merged 1 commit into from
Sep 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rust_src/src/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ impl LispBufferRef {
self.zv
}

#[inline]
pub fn pt(&self) -> ptrdiff_t {
self.pt
}

#[inline]
pub fn beg_addr(&self) -> *mut c_uchar {
unsafe { (*self.text).beg }
Expand Down
11 changes: 11 additions & 0 deletions rust_src/src/cmds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use lisp::LispObject;
use remacs_macros::lisp_fn;
use remacs_sys::EmacsInt;
use threads::ThreadState;

/// Return buffer position N characters after (before if N negative) point.
#[lisp_fn]
pub fn forward_point(n: LispObject) -> LispObject {
let pt = ThreadState::current_buffer().pt();
LispObject::from_fixnum(n.as_fixnum_or_error() + pt as EmacsInt)
}
2 changes: 2 additions & 0 deletions rust_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mod obarray;
mod editfns;
mod util;
mod minibuf;
mod cmds;

#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
Expand Down Expand Up @@ -379,5 +380,6 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*editfns::Spoint_max);
defsubr(&*minibuf::Sminibufferp);
defsubr(&*minibuf::Sactive_minibuffer_window);
defsubr(&*cmds::Sforward_point)
}
}
10 changes: 0 additions & 10 deletions src/cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "frame.h"

static int internal_self_insert (int, EMACS_INT);

DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
doc: /* Return buffer position N characters after (before if N negative) point. */)
(Lisp_Object n)
{
CHECK_NUMBER (n);

return make_number (PT + XINT (n));
}

/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
Validate the new location. Return nil. */
Expand Down Expand Up @@ -511,7 +502,6 @@ syms_of_cmds (void)
This is run after inserting the character. */);
Vpost_self_insert_hook = Qnil;

defsubr (&Sforward_point);
defsubr (&Sforward_char);
defsubr (&Sbackward_char);
defsubr (&Sforward_line);
Expand Down