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 set-window-scroll-bars #1535

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Port set-window-scroll-bars #1535

wants to merge 4 commits into from

Conversation

clample
Copy link
Contributor

@clample clample commented Aug 10, 2019

Resolves #1459

The implementation is very similar to the porting of set-window-fringes

@@ -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.
Copy link
Contributor Author

@clample clample Aug 10, 2019

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm

Copy link
Contributor Author

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,
)
};

Copy link
Collaborator

@shaleh shaleh Aug 13, 2019

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
}

Copy link
Contributor Author

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

@shaleh
Copy link
Collaborator

shaleh commented Aug 14, 2019

This all looks good. Now to figure out how to test it properly....

@clample
Copy link
Contributor Author

clample commented Aug 14, 2019

The failure is from regex-tests-PTESTS. I think that it might be unrelated, but I'm not sure what the root cause is.

chrislample added 3 commits August 17, 2019 18:41
Resolves #1459

Update test
This reverts commit 91ef1eb.

The CI check is failing, and it's not clear if it's due to this commit
or some other issue. This temporarily reverts "Port
set-window-scroll-bars" to check.
@shaleh
Copy link
Collaborator

shaleh commented Jan 12, 2020

@clample this one needs a rebase.

Comment on lines +2050 to +2051
let mut window: LispWindowRef = window.into();
let updated_window = unsafe {
Copy link
Contributor

@denis631 denis631 Feb 16, 2020

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

Copy link
Collaborator

@shaleh shaleh Feb 17, 2020

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.

Copy link
Contributor

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

Copy link
Collaborator

@shaleh shaleh Feb 17, 2020

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>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port set-window-scroll-bars
4 participants