Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
It is actually the other way around...
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfochrist committed Mar 13, 2015
1 parent 8cf53b5 commit 20c7026
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions interleave.el
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ Navigation is the same as in `doc-view-mode'."
(define-key map (kbd "q") 'interleave-quit)
(if (featurep 'pdf-view)
(progn
(define-key map (kbd "i") 'interleave-add-note-pdf-view))
(progn
(define-key map (kbd "n") 'interleave-go-to-next-page)
(define-key map (kbd "p") 'interleave-go-to-previous-page)
(define-key map (kbd "SPC") 'interleave-scroll-up)
(define-key map (kbd "S-SPC") 'interleave-scroll-down)
(define-key map (kbd "DEL") 'interleave-scroll-down)
(define-key map (kbd "i") 'interleave-add-note))
(progn
(define-key map (kbd "i") 'interleave-add-note-pdf-view)))
(define-key map (kbd "i") 'interleave-add-note)))
map))


Expand Down

2 comments on commit 20c7026

@kaushalmodi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea I had was to use funcalls everywhere.

Example:

(defvar interleave-add-note-fn nil
"Function to add interleave note.")
(if (featurep 'pdf-view)
   (setq interleave-add-note-fn 'interleave-add-note-pdf-view)
(setq interleave-add-note-fn 'interleave-add-note-doc-view))
;; skipped code
   (define-key map (kbd "i") (lambda () (interactive) (funcall interleave-add-note-fn)))
;; skipped code

@rudolfochrist
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, too. But then I learned that pdf-tools provide an after hook when the page changes. IMHO this is the cleanest way.
The only one that behaves badly is the interleave-add-note function, because doc-view and pdf-view use different functions to return the current page number.

What I'm planning is to make interleave-add-note parameterized

(defun interleave-add-note (current-page-fn) 
  ;; snip
  (let ((page (funcall current-page-fn))
     ::snip))

And then

(define-key (kbd "i") (lambda ()
                        (interactive)
                        (if (featurep 'pdf-tools)
                            (funcall 'interleave-add-not 'pdf-view-current-page)
                          (funcall 'interleave-add-not 'doc-view-current-page))))

Please sign in to comment.