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

Shows header even if top of window is not in a defun #1

Open
aspiers opened this issue Dec 21, 2020 · 4 comments
Open

Shows header even if top of window is not in a defun #1

aspiers opened this issue Dec 21, 2020 · 4 comments

Comments

@aspiers
Copy link
Contributor

aspiers commented Dec 21, 2020

This can be somewhat confusing, as the end of the defun the header refers to is not visible. I think it should look to see if it's in a defun, and if not, omit the header (or at least offer a defcustom for this behaviour).

@alphapapa
Copy link
Owner

I think it might be better to not disable the header, because I guess that would cause buffer text to jump around when the header line is toggled.

What do you think? Thanks.

@aspiers
Copy link
Contributor Author

aspiers commented Aug 5, 2021

It would only be a jump of one line though, right? I think I'd prefer that to having a misleading header.

@alphapapa
Copy link
Owner

I'd find the jumping really annoying, I think. As it is, it seems to show the top line of the file (i.e. ;;; simple-sticky-header.el ...), which I don't mind. It would probably also be relatively easy to have it show the ;;;-style section heading above the window start.

@aspiers
Copy link
Contributor Author

aspiers commented Aug 6, 2021

Good idea! or even just a blank header if there is no such comment.

roshanshariff added a commit to roshanshariff/topsy.el that referenced this issue Nov 9, 2021
* Add two new customizable faces, topsy and topsy-highlight.

The topsy face is used for the header-line face when topsy-mode is enabled.  It
inherits from the default face, so that the text in the header line matches the
contents of the buffer. The topsy-highlight face is applied (with low priority)
when topsy is showing the first line of a defun (see below).

To go back to the previous appearance (using header-line face), customize the
topsy face to nil or remove its ":inherit default" attribute.

* Properly handle narrowed buffers

The first line of the defun is shown even if it is only partly within a
narrowed buffer.

* Improve logic for finding the first line of a defun

The first line of a defun is shown only if it is partially visible. If the
defun is entirely outside the window, its first line is not shown.

Fixes alphapapa#1

* Show previous line when a defun starts at the top of a window

Finally, when there is no partially visible defun, show the line that is above
the top of the window. This gives a smooth scrolling effect, where the header
line looks and acts just like a normally scrolling part of the buffer. When you
scroll up, the top line of text will appear in the header line, which then
becomes sticky when you scroll past a defun.

Buffer text shown in this way doesn't have the topsy-highlight face.
roshanshariff added a commit to roshanshariff/topsy.el that referenced this issue Jun 15, 2023
* Add two new customizable faces, topsy and topsy-highlight.

The topsy face is used for the header-line face when topsy-mode is enabled.  It
inherits from the default face, so that the text in the header line matches the
contents of the buffer. The topsy-highlight face is applied (with low priority)
when topsy is showing the first line of a defun (see below).

To go back to the previous appearance (using header-line face), customize the
topsy face to nil or remove its ":inherit default" attribute.

* Properly handle narrowed buffers

The first line of the defun is shown even if it is only partly within a
narrowed buffer.

* Improve logic for finding the first line of a defun

The first line of a defun is shown only if it is partially visible. If the
defun is entirely outside the window, its first line is not shown.

Fixes alphapapa#1

* Show previous line when a defun starts at the top of a window

Finally, when there is no partially visible defun, show the line that is above
the top of the window. This gives a smooth scrolling effect, where the header
line looks and acts just like a normally scrolling part of the buffer. When you
scroll up, the top line of text will appear in the header line, which then
becomes sticky when you scroll past a defun.

Buffer text shown in this way doesn't have the topsy-highlight face.
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 a pull request may close this issue.

2 participants