rudolfochrist / interleave

Emacs minor mode to interleave notes and text books
329 stars 18 forks source link

Support for pdf-tools #1

Closed kaushalmodi closed 9 years ago

kaushalmodi commented 9 years ago

Hi,

This is an awesome idea for note taking.

Can you please add support for pdf-tools.

I get the below error as I use pdf-tools instead of docview for viewing pdf files:

n runs the command interleave-go-to-next-page Error running timer `pdf-cache--prefetch-start': (error "epdfinfo: No such page 0")

Note: With pdf-tools installed, the n key is bound to pdf-view-next-page-command.

kaushalmodi commented 9 years ago

Found an easy fix:

(when (featurep 'pdf-view) ; if `pdf-tools' is installed
  (defun interleave-go-to-next-page ()
    "Go to the next page in PDF. Look up for available notes."
    (interactive)
    (pdf-view-next-page-command 1)
    (interleave-go-to-page-note (pdf-view-current-page)))

  (defun interleave-go-to-previous-page ()
    "Go to the previous page in PDF. Look up for available notes."
    (interactive)
    (pdf-view-previous-page-command 1)
    (interleave-go-to-page-note (pdf-view-current-page)))

  (defun interleave-scroll-up ()
    "Scroll up the PDF. Look up for available notes."
    (interactive)
    (setq *interleave-page-marker* (pdf-view-current-page))
    (pdf-view-scroll-up-or-next-page)
    (unless (= *interleave-page-marker* (pdf-view-current-page))
      (interleave-go-to-page-note (pdf-view-current-page))))

  (defun interleave-scroll-down ()
    "Scroll down the PDF. Look up for available notes."
    (interactive)
    (setq *interleave-page-marker* (pdf-view-current-page))
    (pdf-view-scroll-down-or-previous-page)
    (unless (= *interleave-page-marker* (pdf-view-current-page))
      (interleave-go-to-page-note (pdf-view-current-page))))

  (defun interleave-add-note ()
    "Add note for the current page. If there are already notes for this page,
jump to the notes buffer."
    (interactive)
    (let ((page (pdf-view-current-page)))
      (with-current-buffer *interleave--org-buf*
        (save-excursion
          (if (interleave-go-to-page-note page)
              (other-window 1)
            (interleave-create-new-note page)))))))
rudolfochrist commented 9 years ago

Hi @kaushalmodi,

thank you for your suggestion. Sounds great. I add your fix later that evening.

Best, Sebastian

rudolfochrist commented 9 years ago

Should be available when melpa builds v0.2.0.