dalanicolai / image-roll.el

Virtual scroll display engine for Emacs
80 stars 4 forks source link

Page numbers not updated in doom-modeline when using continuous scroll #3

Open stewmehr opened 2 years ago

stewmehr commented 2 years ago

I use doom-modeline (in vanilla Emacs) which can handle page numbers fine when I only skip entire pages via pdf-view-next-page. If I use continuous scrolling to move through a document from the top, the page number freezes at 1 and does not update. This may be due to doom-modeline expecting a string argument for page numbers whereas image-roll probably provides a list of those via image-roll-displayed-pages. I get the following error in my *Messages* buffer:

Error during redisplay: (eval (doom-modeline-segment--pdf-pages)) signaled (wrong-type-argument stringp nil)

I can also confirm some behavior @dalanicolai warned me about: calling pdf-view-next-page when the next page is partly visible (even the tiniest fraction of white space is enough) does not work as expected. I only mention this here because it also has some side effects with regards to page numbers. Calling pdf-view-next-page once increments the page counter (good) but only greys out the current page and otherwise does not update the view (bad). A second call to pdf-view-next-page increments the page counter again and then jumps two pages ahead from the last position - page number in the modeline and the displayed page match again, but we have skipped over one page. Interestingly enough, scrolling backwards through the PDF via pdf-view-previous-page works just fine.

EDIT: See screenshots to get around my awkward phrasing.

Initial situation: Screenshot1

After calling pdf-view-next-page once. Page counter updated, view greyed out: Screenshot2

After calling pdf-view-next-page twice. Page counter updated, view moved two pages forward: Screenshot 2022-05-04 at 13 12 47

dalanicolai commented 2 years ago

Thanks for creating the issue. I think that the issue when using pdf-view-next-page should have been fixed now (you should update both the image-roll and the pdf-tools packages).

About the page numbers not updating; I hope the issue got fixed as a 'side-effect' of the just mentioned fix. Otherwise, I am afraid that I can not be of much help because I do not use Doom, while also the page-numbers seem to update fine on emacs -Q and on Spacemacs.

aikrahguzar commented 1 year ago

I think this issue is caused by the fact that pdf-view-change-page-hook is not longer run. I fixed it for myself by

(add-hook 'image-roll-after-change-page-hook #'+modeline-update-pdf-pages)

This is with the "light" version of the mode-line which doesn't use the doom-modeline package but looking at what doom-modeline adds to pdf-view-change-page-hook and adding the same function to image-roll-after-change-page-hook should fix the issue.