reddit / emacs

Improved continuous scroll for pdf-tools

dalanicolai · 2022-02-04 12:57
gammarray · 2022-02-04 13:01
Is this improved in a new version or with the help of some other code?
dalanicolai · 2022-02-04 13:02
I should read how Reddit works (let you add a link while still showing an image). Anyway, the extension can be found in [this repo](https://github.com/dalanicolai/pdf-continuous-scroll-mode.el). Users that already use the 'two-buffer hack' can just update that package. You might want to use 'reset --hard' as I am using 'push --force' frequently. "WARNING", before updating note that an Emacs compiled with SVG support is required.
dalanicolai · 2022-02-04 13:05
It has been completely rewritten. It now provides continuous scroll more or less how it should be, i.e. using a single buffer.
dalanicolai · 2022-02-04 13:08
But redisplay (i.e. working in multiple buffers), does not work completely right yet, it is not trivial to find out how to get that right. However, I am using Spacemacs, where I can just scroll in the separate buffers and the issue will 'fix itself'. When testing that in vanilla Emacs this trick did not seem to work. But anyway, it seems to work very fine when using just a single buffer...
linwaytin · 2022-02-04 13:44
Your packages are all great!
dalanicolai · 2022-02-04 13:50
Haha... the best feedback! ;)
Tohiko · 2022-02-04 14:19
👏👏
J-ky · 2022-02-04 15:33
Nice work, but I have trouble using it in EXWM. I have to stick with the buffer, if I somehow switch to an EXWM buffer, like Firefox, the pdf buffer turn dark and unresponsive. Also, normal C-v and M-v navigation return error, scrolling with mouse also doesn't work. I may open some tickets in the weekend.
m0r1tz_1337 · 2022-02-04 15:39
Finally I hated the scrolling in PDF tools so I switched to zathura thanks now I can replace it with PDF tools again :)
dalanicolai · 2022-02-04 16:20
That's unfortunate, but not so surprising. I am not sure how EXWM works, but I do know that this current implementation of continuous-scroll has redisplay issues. If you're lucky, then you might be able to make the buffer responsive again by using \`pdf-view-goto-page\`. Using the scroll bar does not work indeed, but as far as I know using the mouse scrolling wheel works fine (at least here). Also, I am an Evil (Spacemacs) user, I am not sure what \`C-v\` and \`M-v\` normally do in Emacs, but it is probably a matter of mapping them to the correct commands. Finally, I know that the current implementation is buggy, but I am sharing it now because I think it is already useful to non-demanding users (using it in a simple way). And moreover, I hope that by releasing it, some very smart people will jump in and help fixing the remaining issues. For me, it already has been a lot of work to understand things up to the current level.
mlk · 2022-02-04 16:29
I don't want to nitpick on your work, but force pushing master of a public repo is not a good practice.
dalanicolai · 2022-02-04 16:31
Great, this was the effect I was hoping for. I have been a Zathura user also, and I was annoyed by the default pdf-tools scrolling behavior also. I was thinking if it can only scroll like Zathura, then pdf-tools really is the greatest pdf editor available (pdf-tools enabled me to quickly write things like [toc-mode](https://melpa.org/#/toc-mode)). The new [alternative pdf server](https://github.com/vedang/pdf-tools/pull/61), already provides features like line and arrow annotations, and with it a few more things will be possible like scripting (I am not sure how useful that ever will be, but anyway it is possible).
dalanicolai · 2022-02-04 16:40
I know. Although I still agree it is bad practice here, I am looking more to this as a shared personal repo (e.g. is not published via one of the package archives, and I am currently, more or less, the only contributor). The thing is, I want to share small fixes quickly, but I do not want to mess up the history too much. Anyway, if the redisplay issues can get solved soon, then this will for sure get merged into pdf-tools. I hope by sharing it, the issues might get solved quicker...
mlk · 2022-02-04 16:50
OK, I thought you could have not known that
dalanicolai · 2022-02-04 16:52
Ah yeah, thanks for the info anyway of course...
m0r1tz_1337 · 2022-02-04 17:35
:)
1nc0ns1st3nt · 2022-02-04 19:45
Hi, you said 'two buffer hack'. I am very interested for epub reading with nov mode. Would this hack be possible used for this purpose do you reckon?
dalanicolai · 2022-02-04 21:33
The 2 buffer hack used for pdf-tools can not directly be used for the nov.el package (pdf-tools shows images, while nov.el shows text). A very similar 'hack' should be perfectly possible for the nov.el package (and I guess not very difficult to write), but I would try/advise to come up with an alternative hack to obtain it within a single buffer (insert and remove the right sections at appropriate times). In Emacs 29, doc-view has epub support if the 'mutool' command (from mupdf) is available. A new 'alternative' pdf-tools server using mupdf, will also bring epub support to pdf-tools (so that this continuous-scroll package can be used for it). Both these solutions make use of mupdf's ability to print the epub as pages of png images. Although, I think nov.el is a great package, I probably prefer to read epub's using doc-view or even better pdf-tools (but preferences may differ).
1nc0ns1st3nt · 2022-02-04 23:10
Thank you, this is very informative. Emacs 29 seems to be so promising, although, it puzzles me as to why 28 hasn't been released yet (but of course I am using 28 right now)
dalanicolai · 2022-02-04 23:34
It seems like I have been able to fix the 'redisplay' issue for Spacemacs in the latest update. So it seems that Spacemacs users can happily continuous scroll a single book in separate windows. I am not sure why the issue seems to persist in vanilla Emacs...
dalanicolai · 2022-02-04 23:51
I think you can simply use doc-view.el from Emacs 29 in Emacs 28 (not sure though but very simple to check it out). Otherwise, compiling Emacs 29 is as straightforward as compiling Emacs 28. I don't know why 28 has not been released yet, but for sure, they prefer things to be stable and well tested...
dalanicolai · 2022-02-04 23:54
I have fixed some more things now. There is a small possibility that it might work better now in EXWM. But I don't use EXWM, so I can not test it (and also not debug it for that case...)
wheel_of_confusion · 2022-02-05 02:26
Damn I was under the impression this wasn't possible. Excited to test this out next time I have to write latex
funshine · 2022-02-05 09:17
pdf-tools is a very useful package. Any small improvement to it is very welcome. The recent-ish hidpi support made it so I could use it again, and made a noticable improvement in my workflow when reviewing papers.
dalanicolai · 2022-02-05 09:51
Me too, until I read [this](https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00938.html) thread in the Emacs devel mailing list. And especially when I found [this](https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00087.html) more useful message in the mailing list. In the end, I think it was not simple.el but image-mode.el + doc-view.el code that was most helpful in 'hinting' how to achieve this... it still took me quite some work to sort out the details of doc-view.el though
Jack-o-tall-tales · 2022-02-06 20:37
This looks *amazing*. Curious though: any reason this is a separate package rather than a PR on pdf-tools itself? That would have seemed more the Right Way to me.
dalanicolai · 2022-02-07 14:32
Haha... thanks for the enthusiasm. Well, there are multiple reasons for not creating a PR to pdf-tools itself directly. The main reason is that it is still far from a complete implementation: working in multiple buffers does not work flawlessly, isearch does not work, and when I test here in vanilla Emacs, then I find even more things that seem to not work correctly yet, such as activating text for highlighting. However, I have sent it to both the current pdf-tools maintainer and to the Emacs developer mailing list for review. I hope, some more knowledgeable users will help with fixing bugs and completing the implementation. As soon as it all works well enough, then it would be great to have it merged into pdf-tools.
Bingelman142 · 2022-02-07 23:31
Great work man. I really like pdf-tools packages, considering I work so much with it. If you could continue making good stuff like this for pdf-tools, would be amazing. Thanks a lot.