Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-noter: Wrong type argument: integer-or-marker-p, nil when starting note on pdf #1

Open
tazheinrich opened this issue Aug 2, 2023 · 1 comment

Comments

@tazheinrich
Copy link

When I want to annotate an open PDF I get the following error message "org-noter: Wrong type argument: integer-or-marker-p, nil".

It should open an org-noter-buffer side-by-side with the PDF, however the org-noter-buffer gets started (but no split screen) and the error message is displayed.

Here is how I set up the necessary packages to connect org, org-noter, pdf-tools, org-pdftools, and org-noter-pdftools

  (use-package org-noter
    :config
    (setq org-noter-notes-search-path my/notes)
    (setq org-noter-window-location 'vertical-split)
    (setq org-noter-alway-create-frame nil)
    (setq org-noter-separate-notes-from-heading t))

  (use-package pdf-tools
    :straight '(pdf-tools
                :host github
                :repo "vedang/pdf-tools"
                :branch "master")
    :magic ("%PDF" . pdf-view-mode)
    :hook ((pdf-view-mode . auto-revert-mode)
           (pdf-view-mode . cua-mode))
        :config
    ;; Scale pdfs to fit page
    (setq-default pdf-view-display-size 'fit-page)
    ;; Enable more fine grained zooming
    (setq pdf-view-resize-factor 1.1)
    ;; Use normal isearch
    (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
    :init
    ;; Initialize package
    (pdf-loader-install))

  (use-package org-pdftools
    :after org
    :hook (org-mode . org-pdftools-setup-link))

  (use-package org-noter-pdftools
    :after org-noter
    :config
    ;; Add a function to ensure precise note is inserted
    (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions)
      (interactive "P")
      (org-noter--with-valid-session
       (let ((org-noter-insert-note-no-questions (if toggle-no-questions
                                                     (not org-noter-insert-note-no-questions)
                                                   org-noter-insert-note-no-questions))
             (org-pdftools-use-isearch-link t)
             (org-pdftools-use-freepointer-annot t))
         (org-noter-insert-note (org-noter--get-precise-info)))))

    ;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf
    (defun org-noter-set-start-location (&optional arg)
      "When opening a session with this document, go to the current location.
  With a prefix ARG, remove start location."
      (interactive "P")
      (org-noter--with-valid-session
       (let ((inhibit-read-only t)
             (ast (org-noter--parse-root))
             (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive))))
         (with-current-buffer (org-noter--session-notes-buffer session)
           (org-with-wide-buffer
            (goto-char (org-element-property :begin ast))
            (if arg
                (org-entry-delete nil org-noter-property-note-location)
              (org-entry-put nil org-noter-property-note-location
                             (org-noter--pretty-print-location location))))))))
    (with-eval-after-load 'pdf-annot
      (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

Steps to reproduce:

  1. Open PDF
  2. Start org-noter with M-x org-noter
  3. Select file
  4. Get error message
@theconsciouspasticcio
Copy link

Same configuration, same error. The problem seems lie in the patch responsible for precise note insertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants