Skip to content

PDF Modeline Improvements#425

Closed
tecosaur wants to merge 1 commit intoseagle0128:masterfrom
tecosaur:master
Closed

PDF Modeline Improvements#425
tecosaur wants to merge 1 commit intoseagle0128:masterfrom
tecosaur:master

Conversation

@tecosaur
Copy link
Contributor

@tecosaur tecosaur commented Mar 9, 2021

There are a few changes here to improve the appearance of the PDF modeline.

  • Prioritise the page information, move segment in front of buffer name
  • Create (and use) new buffer-name segment, that doesn't include any
    mode or state information
  • Left-pad doom-modeline--pdf-pages to ensure that for a given PDF
    it's always the same width
  • Add a pdf-icon segment and place it in front of the buffer name

There are a few changes here to improve the appearance of the PDF modeline:
+ Prioritise the page information, move segment in front of buffer name
+ Create (and use) new buffer-name segment, that doesn't include any
  mode or state information
+ Left-pad `doom-modeline--pdf-pages' to ensure that for a given PDF
  it's always the same width
+ Add a `pdf-icon' segment and place it in front of the buffer name
@tecosaur
Copy link
Contributor Author

tecosaur commented Mar 9, 2021

Without this PR:

image

With this PR:

image

Also, I'm not sure that my choice of doom-modeline-buffer-minor-mode as an 'inactive' / 'less interesting' face is a good choice, please let me know if there's a better option I should use.

@seagle0128
Copy link
Owner

The default pdf modeline looks like this:

image

It should meet the most of requirements. If it doesn't, you can redefine the modeline, as you did. But I am not convinced yet, since I don't see any major changes here.

@tecosaur
Copy link
Contributor Author

tecosaur commented Mar 9, 2021

The main issue I have with the default modelling is that with long file names the path segment easily pushes the page number off the edge of the modeline (as seen in my screenshot).

IMO this is problematic as the page information is highly desirable, so I moved the segment in front of the buffer info.

Now as you move through the pages as you go from 1 to 2 digits etc. the width changes and the rest of the modeline shifts.
I also consider this behaviour to be undesirable, hence the constant width modification.

Lastly, when viewing a file in pdf-mode I don't think the lock gives any useful information, and you can still modify the PDF itself adding annotations etc. So, I've replaced buffer-info with a buffer-name segment that just gives the name, and added a PDF icon in front.

Does this help clarify the motivation behind these modifications?

@seagle0128
Copy link
Owner

Well, doom-modeline-buffer-file-name-style should address the issue of long file names with path. The position of pdf-pages is to keep consistence of the buffer-position in other buffers. Of course you can redefined the modeline as I clarified.

@tecosaur
Copy link
Contributor Author

tecosaur commented Mar 9, 2021

Hmmm, I do see the sense in consistency, I just wonder if it's worth making an exception for paged documents.

@seagle0128
Copy link
Owner

Maybe you just need a new modeline for pdf buffers, while not changing so many codes 😄️

(doom-modeline-def-modeline 'my-pdf
  '(bar window-number matches pdf-pages buffer-info-simple)
  '(misc-info major-mode process vcs))

@tecosaur
Copy link
Contributor Author

tecosaur commented Mar 9, 2021

Oh but then you get the cascade of "would be better if this was changed" 😅 (mentioned in my earlier commit) ... leading to what you see here.

@tecosaur
Copy link
Contributor Author

tecosaur commented Mar 9, 2021

FWIW even if I change the file name style to file-name I still see page-info-disappearing issues with some PDFs:
image

@seagle0128
Copy link
Owner

If the buffer/file name is too long, same issue for other files. It also exists in vanilla Emacs.
I am curious why there is no file icon for pdf files in your env. Are you not using pdf-tools?

@tecosaur
Copy link
Contributor Author

If the buffer/file name is too long, same issue for other files.

Yea, I'm just of the opinion that you don't tend to care as much about buffer position (in a text file) compared to page number (pdfs).

I am curious why there is no file icon for pdf files in your env. Are you not using pdf-tools?

I just have file-icons off.

@seagle0128
Copy link
Owner

Then I suggest to add an option to truncate the file name with while displaying.

@tecosaur
Copy link
Contributor Author

This reminds me of #345 😛, regardless I get the impression that with this issue, you'd like to leave things as they currently are and any other layout should be in personal config? If so, I'll close this PR.

@seagle0128
Copy link
Owner

yep, I'd like leave it to the private configurations.

@tecosaur
Copy link
Contributor Author

Alrighty then, I'll finish the discussion then. As a final note, I would like to re-express my opinion that this PR produces a nicer modelling than the default, but it's not a huge deal 🙂.

@tecosaur tecosaur closed this Mar 11, 2021
@tecosaur
Copy link
Contributor Author

For anyone who happens to be come across this and like the look, I've just noticed an omission from my PR:

(doom-modeline-def-modeline 'pdf
    '(bar window-number matches pdf-pages pdf-icon buffer-name)
    '(misc-info major-mode process vcs))

@seagle0128
Copy link
Owner

Try (setq doom-modeline-buffer-file-name-style 'auto). Thus the long buffer name will be truncated as fish-like style.

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.

2 participants