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 set-window-scroll-bars #1535
base: master
Are you sure you want to change the base?
Conversation
test/rust_src/src/windows-tests.el
Outdated
@@ -189,3 +189,21 @@ | |||
;; frames inside tests (see https://github.com/remacs/remacs/issues/1429). | |||
(ert-deftest window-pixel-height-before-size-change () | |||
(window-pixel-height-before-size-change)) | |||
|
|||
;; TODO: find a way to ignore COLUMNS, LINES. Otherwise it fails when run by hand. |
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.
It looks like the columns and lines returned by window-scroll-bars
will vary. It is calculated based on width and height of the scroll bar. For example, the test fails if I open emacs and run the test locally.
I'm not sure what the best way is to make this test lest fragile.
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.
hmmmm
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.
So I believe I kind of found the reason why the column value varied. When Remacs is run without a window system (in the terminal), there is no scroll bar and columns is always 0.
I haven't pinned down the exact line where this happens, but it seems to be how it works.
To work around it - I check window-system in the test.
horizontal_type, | ||
) | ||
}; | ||
|
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.
Perhaps flip the following logic? I am not sure which I prefer.
if updated_window.is_null() {
false
} else {
unsafe { apply_window_adjustment(updated_window) };
true
}
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.
Good point, this is more readable to me than !updated_window.is_null()
.
I updated the PR
This all looks good. Now to figure out how to test it properly.... |
The failure is from |
@clample this one needs a rebase. |
let mut window: LispWindowRef = window.into(); | ||
let updated_window = unsafe { |
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.
@clample In the original implementation, the window is accessed via decode_live_window
which checks for the selected window being nil first, if yes -> use it instead of the passed window, otherwise check the passed window for being live (otherwise throwing a "wrong type argument exception") and then use it.
Do you think this may be the case here? Seems like semantics is not preserved.
reference: window.c line:264
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.
@denis631 LispWindowLiveOrSelected
is meant to encapsulate the logic of decode_live_window
.
Line 2067 gets the correct Window.
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.
Ohhh so the #lisp_fn
macro does all the necessary transformations? It this case mapping LispObject
to LispWindowLiveOrSelected
? I see. Nice. Sorry for false negative
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.
@denis631 correct. The lisp_fn
macro is a proc macro which creates code that looks like:
pub fn new_defun(obj1: LispObject, obj2: LispObject, .......) -> LispObject {
let result = original_defun(obj1.into(), obj2.into(), ....);
result.into()
}
Which is super simple. All of the error handling, checking, and the like occurs in the From
implementations. The lisp_fn
macro gets more complicated when the lisp function is of variable arguments. These collect the args into a Vector.
Our convention is that where a Lisp function takes optional parameters we use the Option
type. In the C code this is represented with a Nil value. Essentially C's LispObject is really an Option<LispValue>
.
Resolves #1459
The implementation is very similar to the porting of set-window-fringes