org-noter icon indicating copy to clipboard operation
org-noter copied to clipboard

Fix location autosave when using org-pdftools integration

Open xzz53 opened this issue 5 years ago • 8 comments

Hi!

I'm trying to get org-noter-integration.el working. Core functionality seems to be OK, but I've encountered an issue when running with org-noter-auto-save-last-location enabled. It results in org-noter-pdftools--doc-approx-location being called with 'interactive argument on every page change. That in turn activates interactive branch ("Do you want to create a free pointer annotation for the link?") in org-pdftools-get-link. This patch prevents that by changing org-noter-set-start-location so that 'interactive is passed to org-noter-pdftools--doc-approx-location only when directly called by user, not from org-noter--doc-location-change-handler.

xzz53 avatar Feb 05 '20 22:02 xzz53

@xzz53 Could you show your configuration about org-noter-integration.el' about org-noter'?

After loading the org-noter-integration.el in my config. click the pdftools:xxx link in the notes file failed to link to the location of pdf file. and a message `Invalid function: org-noter--with-valid-session' appears in minibuffer.

smallzhan avatar Feb 06 '20 10:02 smallzhan

@smallzhan, at present I just do (load "~/.emacs.d/straight/repos/org-noter/other/org-noter-integration.el"). I've just tested opening pdftools: links, and they work as expected. Are you sure you use master branch of both org-noter and org-pdftools?

PS I plan to set up a PR against org-pdftools to merge org-noter-integration.el there when I'm sure it basically works, in a few days probably

@xzz53 Could you show your configuration about org-noter-integration.el' about org-noter'?

After loading the org-noter-integration.el in my config. click the pdftools:xxx link in the notes file failed to link to the location of pdf file. and a message `Invalid function: org-noter--with-valid-session' appears in minibuffer.

xzz53 avatar Feb 06 '20 12:02 xzz53

@xzz53 seems that org-pdftools can't be complied as .elc, now it works, thank you!

Your `PS' will be a very great work!

PS I plan to set up a PR against org-pdftools to merge org-noter-integration.el there when I'm sure it basically works, in a few days probably

smallzhan avatar Feb 06 '20 13:02 smallzhan

I'm getting this issue now suddenly. It's frustrating as hell. Please merge!

spacekitteh avatar Apr 30 '20 04:04 spacekitteh

I'm getting this issue now suddenly. It's frustrating as hell. Please merge!

Same here. The package with this bug is unusable.

Update:

As a work around I installed el-patch and added to my init.el the following code:

(eval-when-compile
  (require 'el-patch))
(el-patch-feature org-noter)
(with-eval-after-load 'org-noter
  (el-patch-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 (el-patch-add (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)))))))))

wilya7 avatar Jun 29 '20 11:06 wilya7

"click anywhere on the page to add a link to. Do you want to do that?" keeps popping up ! Makes the package in Emacs 27.1 useless

LorenRiccie avatar Dec 28 '20 16:12 LorenRiccie

"click anywhere on the page to add a link to. Do you want to do that?" keeps popping up ! Makes the package in Emacs 27.1 useless

The author seems to have completely abandoned the package. From my point of view, either you fork and patch the package in your local github repository and instruct emacs to use it, or you install el-patch and patch org-noter every time you start emacs by adding https://github.com/weirdNox/org-noter/pull/93#issuecomment-651044421 to your init.el.

wilya7 avatar Jan 04 '21 08:01 wilya7

Now if you follow the use-package configuration recommended by the readme of org-pdftools, the fix goes in there. See: https://github.com/fuxialexander/org-pdftools/commit/2335f6a2369b28ac5531c98cf73f60a30a4fa171

It works well for me.

wilya7 avatar Jan 27 '21 11:01 wilya7