vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
643 stars 90 forks source link

pdf-view-mode: remove default space before "P" in mode line #193

Closed Hugo-Heagren closed 1 year ago

Hugo-Heagren commented 1 year ago

I recently altered my mode line to be a bit more minimal. I set the default value of mode-line-position to ("%C/%l"), and then include (:propertize ("[" mode-line-position "]") face italic) in my mode line. Pdf view's mode line integration is great, but screws this up slightly because it assumes that the user wants an extra space before the "P" page indicator (which I don't -- I want it look just like the column/line indicator usually does).

This PR fixes this. Users who still want the extra space can add it manually in their mode line configuration (though conversely, there is no obvious way for users like me to remove it if it is there by default).

astoff commented 1 year ago

[...] though conversely [...]

I don't see a difference in these two cases. Both would involve overwriting the mode's default mode-line-position in pdf-view-mode-hook. The only way to make this easier would be to make the pdf-tools mode-line-position a user option.

Hugo-Heagren commented 1 year ago

I don't see a difference in these two cases. Both would involve overwriting the mode's default mode-line-position in pdf-view-mode-hook.

I don't think so. If the pdf-view mode-line-position includes a space, then yes, the user would have to overwrite the value of mode-line-position to remove the space. But if it doesn't include the space, the user can just alter the modeline format to include one, with a modeline construct such as (" " mode-line-position). This doesn't involve altering the value of mode-line-position, but the value of mode-line-format.

Moreover, users who want a space before the mode line position will probably have something like this set anyway (so will not need to alter mode-line-format in pdf-view-mode-hook), since the default global value of mode-line-position does not include a leading space, so they would have to have put one in themselves.

The only way to make this easier would be to make the pdf-tools mode-line-position a user option.

I wouldn't mind doing this either -- personally I try to keep my PRs as close to the original code as possible, but if you think this is a good idea that would be cool.

astoff commented 1 year ago

If I just remove the space on emacs -Q, I see this, which doesn't look right:

image

The 10% (or Top, Bottom, etc) is added there by pdf-misc-size-indication-minor-mode, which apparently is enabled by default.

but if you think this is a good idea that would be cool

Let me clarify that I have no say about patches to this project :-).

vedang commented 1 year ago

Hi @Hugo-Heagren , I think the space is important in the mode-line-position as it stands in the code today.

I'm open to reviewing and accepting a PR which refactors the code and exposes a user-configuration pdf-view-mode-line, if you (or anyone else) is up for that change.