weirdNox / org-noter

Emacs document annotator, using Org-mode
GNU General Public License v3.0
1.08k stars 101 forks source link

Fix location autosave when using org-pdftools integration #93

Open xzz53 opened 4 years ago

xzz53 commented 4 years ago

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.

smallzhan commented 4 years ago

@xzz53 Could you show your configuration about org-noter-integration.el' aboutorg-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 commented 4 years ago

@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' aboutorg-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 commented 4 years ago

@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

spacekitteh commented 4 years ago

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

wilya7 commented 4 years ago

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)))))))))
LorenRiccie commented 3 years ago

"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

wilya7 commented 3 years ago

"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 commented 3 years ago

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.