0

I annotate my reading with org-remark and pdf-annot. They work with EPUBs and PDFs respectively, and are not interchangeable, with inconvenient consequences.

What I would like to do is to bind a single key-binding to org-remark-mark and pdf-annot-add-highlight-markup-annotation based on the major mode of a buffer. If it is in pdf-view-mode, call pdf-annot-add-highlight-markup-annotation; if it is in nov-mode, call org-remark-mark.

At present, I have:

(map! :leader
        (:prefix-map ("r" . "reading")
                     (:prefix ("n" . "org-noter")
                      :desc "PDF Add Highlight Annotation" "h" #'pdf-annot-add-highlight-markup-annotation
)))

and

(map! :leader
        (:prefix-map ("r" . "reading")
        (:prefix ("r" . "org-remark")
        :desc "Highlight text at point" "h" #'org-remark-mark
)))

in my config.el on Doom Emacs.

I am thinking of working with hooks and conditionals, on a custom function, to be mapped onto SPCRR in place of org-remark-mark, but fall short of implementing the actual code.

2
  • 3
    The normal approach is to bind your key sequence to pdf-annot-add-highlight-markup-annotation in pdf-view-mode-map, and separately bind it to org-remark-mark in nov-mode-map (n.b. I am making assumptions about the keymap names).
    – phils
    Jan 13, 2023 at 3:18
  • @phils There is, indeed, a nov-mode-map and a pdf-view-mode-map.
    – Sati
    Jan 13, 2023 at 3:41

1 Answer 1

0

Not exactly as @phils suggested in his comment above, but I've fixed the problem with this setting in config.el:

  (map! :leader
        (:prefix-map ("r" . "reading")
        :desc "Make highlight annotation for EPUB or PDF" "h" #'my-reading-make-highlight-annotation))
(defun my-reading-make-highlight-annotation ()

  "Highlight text and activate the annotation notes for input.
This single function can be called for both EPUBs and PDFs."

  (interactive)
  (cond ((eq major-mode 'nov-mode)
         (apply 'org-remark-mark (org-remark-region-or-word))
         (org-remark-view (- (point) 1))
         (switch-to-buffer "*marginal notes*")
         (evil-org-open-below 1))

        ((eq major-mode 'pdf-view-mode)
         (pdf-annot-add-highlight-markup-annotation pdf-view-active-region)
         (evil-insert 1)
         )))

Welcome other answers that propose to solve the problem in a more standard way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.