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 bolp and eolp to rust #293
Changes from 7 commits
5ffd064
72a897f
cd5eb4f
b34bc96
8664b32
d782485
c24273c
a7c999e
03fd9e9
12403b1
bdf1873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,22 @@ pub fn bobp() -> LispObject { | |
let buffer_ref = ThreadState::current_buffer(); | ||
LispObject::from_bool(buffer_ref.pt == buffer_ref.begv) | ||
} | ||
|
||
/// Return t if point is at the beginning of a line. | ||
#[lisp_fn] | ||
pub fn bolp() -> LispObject { | ||
let buffer_ref = ThreadState::current_buffer(); | ||
LispObject::from_bool( | ||
buffer_ref.pt == buffer_ref.begv || buffer_ref.fetch_byte(buffer_ref.pt_byte - 1) == b'\n', | ||
) | ||
} | ||
|
||
/// Return t if point is at the end of a line. | ||
///`End of a line' includes point being at the end of the buffer. | ||
#[lisp_fn] | ||
pub fn eolp() -> LispObject { | ||
let buffer_ref = ThreadState::current_buffer(); | ||
LispObject::from_bool( | ||
buffer_ref.pt == buffer_ref.zv() || buffer_ref.fetch_byte(buffer_ref.pt_byte) == b'\n', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cargo fmt told me about that final comma, but.... does it make sense? I find it a bit strange, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, it's a little odd. Perhaps it's a rustfmt bug. I like that rustfmt is a tool that you just run and it fixes formatting without human input. We could file a bug upstream, but I'd leave the comma for now if rustfmt wants it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's a big, it's just consistent in always having a final comma on multi-line lists of expressions. The argument for having the trailing comma in the first place, less churn when an element is added, applies to single arguments as well. |
||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer we called this
offset
-- it's not actually an address (0 wouldn't make sense as an address here).