nobiot / org-remark

Highlight & annotate text, EWW, Info, and EPUB
https://nobiot.github.io/org-remark/
GNU General Public License v3.0
425 stars 20 forks source link

Exclude pdfs from default file type #57

Closed sati-bodhi closed 1 year ago

sati-bodhi commented 1 year ago

Org-remark doesn't work with PDFs.

This is because of the PDF file structure, which EMACS renders as images. As a result, annotations are handled differently within the PDF file specification.

When we accidentally call org-remark-mark on a PDF, we get the following text inserted into marginalia.org:

* Mind, Self, and Society from the Standpoint of a Social Behaviorist
:PROPERTIES:
:org-remark-file: ../../Zotero/storage/8KBMIA4U/Mind, Self, and Society from the Standpoint of a Social Behaviorist.pdf
:END:

** %
:PROPERTIES:
:org-remark-beg: 1
:org-remark-end: 2
:org-remark-id: da48727d
:org-remark-label: nil
:org-remark-link: [[file:../../Zotero/storage/8KBMIA4U/Mind, Self, and Society from the Standpoint of a Social Behaviorist.pdf::1]]
:END:

We can do nothing about it except manually remove the insertion from the file, which is an inconvenience that disrupts the reading workflow.

Could some kind of filter be written to exclude pdf-view-mode from the default set up?

sati-bodhi commented 1 year ago

@nobiot, I've fixed the problem downstream with the following config.el settings:

(use-package! org-remark
...
  (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)
         )))

I'll leave it up to you to decide if it is necessary to add that filter upstream at source level.

nobiot commented 1 year ago

Thanks. I will think of a way upstream for dev/nov.el branch.

nobiot commented 1 year ago

Fix 32149d5 is in the dev/nov.el branch.

When you have some time, I'd appreciate it if you could test it on your end.

sati-bodhi commented 1 year ago

When you have some time, I'd appreciate it if you could test it on your end.

Tested the fix.

It now exits with org-remark: Highlights not saved; buffer is not supported when org-remark-mark is called on a PDFView buffer, which is what we want.

sati-bodhi commented 1 year ago

Guess we can close this issue for now.