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
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -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 }
@@ -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)
}
@@ -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;
@@ -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)
}
}
@@ -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. */
@@ -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);
ProTip! Use n and p to navigate between commits in a pull request.