fuxialexander / org-pdftools

A custom org link type for pdf-tools
GNU General Public License v3.0
331 stars 35 forks source link

wrong-type-argument integer-or-marker p nil #98

Closed tazheinrich closed 11 months ago

tazheinrich commented 11 months ago

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

Backtrace: Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) get-text-property(nil org-noter-session-id) org-noter(nil) org-noter--create-session-from-document-file-default(nil "/Users/tassiloheinrich/Dropbox/01-literaturdatenba...") run-hook-with-args-until-success(org-noter--create-session-from-document-file-default nil "/Users/tassiloheinrich/Dropbox/01-literaturdatenba...") org-noter(nil) funcall-interactively(org-noter nil) call-interactively(org-noter record nil) command-execute(org-noter record) execute-extended-command(nil "org-noter" "org-noter") funcall-interactively(execute-extended-command nil "org-noter" "org-noter") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command)

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 'horizontal-split)
    (setq org-noter-always-create-frame nil)
    (setq org-noter-separate-notes-from-heading t))

 (use-package pdf-tools
   :mode (("\\.pdf$" . pdf-view-mode))
   :bind (:map pdf-view-mode-map
                ("C-s" . search-forward))
   :hook ((pdf-view-mode . auto-revert-mode)
               (pdf-view-mode . (lambda () cue-mode 0))))
   :config
   (setq-default pdf-view-display-size 'fit-page)
   :init
   (pdf-tools-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