vedang / pdf-tools

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

Add support for `follow-mode` to PDF Tools #25

Open WhatisRT opened 3 years ago

WhatisRT commented 3 years ago

PDF-tools doesn't seem to support follow-mode, trying to use it results in the other window displaying the buffer being empty. I don't know what would need to happen for it to be supported and if it is even possible in principle without large refactoring, but in case of some refactoring happening for #18, this might be a nice goal to keep in mind.

tongjie-chen commented 3 years ago

follow-mode worked in some way, but the viewer is implemented as a single image viewer. A quick way would be to rebind all scroll key in your defined follow-mode to be like,

(define-minor-mode my-pdf-follow-mode
  "My pdf follow mode"
  :keymap
  `((,(kbd "SPC") . (lambda() (interactive) (pdf-view-scroll-up-or-next-page) (other-window 1) (pdf-view-scroll-up-or-next-page) (other-window -1))))
  `((,(kbd "S-SPC") . (lambda() (interactive) (pdf-view-scroll-down-or-previous-page) (other-window 1) (pdf-view-scroll-down-or-previous-page) (other-window -1))))
)

Just tried to write this by opening a pdf side by side and M-x my-pdf-follow-mode. The scroll up worked, but scroll down still worked only on one window.

Hope this may inspired you to build up this follow-mode.