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 point-min and point-max to Rust #302

Merged
merged 1 commit into from Sep 7, 2017
Jump to file or symbol
Failed to load files and symbols.
+18 −23
Diff settings

Always

Just for now

Copy path View file
@@ -68,3 +68,19 @@ pub fn eolp() -> LispObject {
buffer_ref.pt == buffer_ref.zv() || buffer_ref.fetch_byte(buffer_ref.pt_byte) == b'\n',
)
}
/// Return the minimum permissible value of point in the current
/// buffer. This is 1, unless narrowing (a buffer restriction) is in
/// effect.
#[lisp_fn]
pub fn point_min() -> LispObject {
LispObject::from_natnum(ThreadState::current_buffer().begv as EmacsInt)

This comment has been minimized.

@kidd

kidd Sep 4, 2017

Collaborator

begv (the same as zv) is both an "attribute" of buffer and an accessor. Better use the accessor, right? (that means change this to begv()). Or for efficiency reasons we want to access the attr directly?
It's 'beg' the one that is an accessor. begv is only an attribute so the question is irrelevant.

}
/// Return the maximum permissible value of point in the current
/// buffer. This is (1+ (buffer-size)), unless narrowing (a buffer
/// restriction) is in effect, in which case it is less.
#[lisp_fn]
pub fn point_max() -> LispObject {
LispObject::from_natnum(ThreadState::current_buffer().zv() as EmacsInt)
}
Copy path View file
@@ -333,5 +333,7 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*editfns::Sbobp);
defsubr(&*editfns::Sbolp);
defsubr(&*editfns::Seolp);
defsubr(&*editfns::Spoint_min);
defsubr(&*editfns::Spoint_max);
}
}
Copy path View file
@@ -1045,16 +1045,6 @@ usage: (save-current-buffer &rest BODY) */)
return unbind_to (count, Fprogn (args));
}
DEFUN ("point-min", Fpoint_min, Spoint_min, 0, 0, 0,
doc: /* Return the minimum permissible value of point in the current buffer.
This is 1, unless narrowing (a buffer restriction) is in effect. */)
(void)
{
Lisp_Object temp;
XSETFASTINT (temp, BEGV);
return temp;
}
DEFUN ("point-min-marker", Fpoint_min_marker, Spoint_min_marker, 0, 0, 0,
doc: /* Return a marker to the minimum permissible value of point in this buffer.
This is the beginning, unless narrowing (a buffer restriction) is in effect. */)
@@ -1063,17 +1053,6 @@ This is the beginning, unless narrowing (a buffer restriction) is in effect. */
return build_marker (current_buffer, BEGV, BEGV_BYTE);
}
DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 0, 0,
doc: /* Return the maximum permissible value of point in the current buffer.
This is (1+ (buffer-size)), unless narrowing (a buffer restriction)
is in effect, in which case it is less. */)
(void)
{
Lisp_Object temp;
XSETFASTINT (temp, ZV);
return temp;
}
DEFUN ("point-max-marker", Fpoint_max_marker, Spoint_max_marker, 0, 0, 0,
doc: /* Return a marker to the maximum permissible value of point in this buffer.
This is (1+ (buffer-size)), unless narrowing (a buffer restriction)
@@ -5381,8 +5360,6 @@ functions if all the text being accessed has this property. */);
defsubr (&Ssave_excursion);
defsubr (&Ssave_current_buffer);
defsubr (&Spoint_max);
defsubr (&Spoint_min);
defsubr (&Spoint_min_marker);
defsubr (&Spoint_max_marker);
defsubr (&Sgap_position);
ProTip! Use n and p to navigate between commits in a pull request.