weirdNox / org-noter

Emacs document annotator, using Org-mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] Offset page wildcard in the default title

das-s opened this issue · comments

commented

Hey, first of all, thanks for the helpful extension.

In my field of research one is often required to read fragments or chapters of scanned books meaning the page in the PDF does not correctly correspond to the actual page number on paper. I've been using the quick insertion org-noter-default-heading-title a lot but it makes it a bit confusing for fragmented PDFs. When using citations I need to open the notes file as well as the PDF and sync both to find the actual page number in the PDF.

Would it be possible to provide a document local variable along the lines #+ORG-NOTER-PAGE-OFFSET: 10 to achieve a offset during the wildcard replacement of the "Notes for page $p$"? For example: Let's take a PDF containing scanned pages 80-120 of [Book]. Setting the offset to 80 lets the page number in the created default heading correspond to the original book page.

I've dabbled in the code a bit but was unable to provide a working example as my elisp is not up to par for the task (yet). If someone provides some pointers where to look at I might provide a PR myself.

commented

Found a better solution than proposed before:

Introducing a new parameter Custom_ID and page-offset into my capture-template for org-ref/org-roam-bibtex allows me to set the citekey and the page offset for the corresponding document. Then, the following function puts the citekey and the page (with the offset) on the current heading in the killring for it to be easily pasted where needed. There is surely some optimization possible but works for me so far.

    (defun +yank-current-page-citation ()
      "Copy an autocite key from the current heading and note file."
      (interactive)
      (let ((key (car (org-property-values "Custom_ID")))
            (page (cl-parse-integer (cdr (assoc "NOTER_PAGE" (org-entry-properties)))))
            (inc (car (org-property-values "page_offset"))))
        (if inc (kill-new (format "[[autocite:%s][%s]]" key (+ page (cl-parse-integer inc))))
          (kill-new (format "[[autocite:%s][%s]]" key page)))))