fuxialexander / org-pdftools

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

org-noter-insert-precise-note stopped working after installing org-pdftools #63

Closed RetepRennelk closed 3 years ago

RetepRennelk commented 3 years ago

Steps for reproduction:

Expected behavior:

Observations: The variable location in org-noter.el is a simple cons cell with x and y value. But after installing org-pdftools, location turns into a cl-defstructwith type org-noter-pdftools--location. And this crashes due to the frequent use of (car location) which won't work on a cl-defstruct. The problem persists with org-noter-pdftools-insert-precise-note from the readme.

Please help!

fuxialexander commented 3 years ago

I cannot reproduce your problem following the step above actually

RetepRennelk commented 3 years ago

I thought for a brief moment that I missed https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf but it does not help either.

After deleteing and re-installing all relevant packages freshly from Melpa and following your readme the error remains:

org-noter-pdftools-insert-precise-note calls org-noter-insert-note with the results of org-noter--get-precise-info, which calls the hook org-noter--get-precise-info-hook. This hook is set to org-noter-pdftools--get-precise-info which returns a cl-defstruct, on which (car location) chokes.

The only way I get org-noter-pdftools-insert-precise-note to work is to set the hook to nil, (setq org-noter--get-precise-info-hook nil). But this leaves the pdf without highlight, which I'd much prefer.

I am inching towards a solution, but for now I am stuck, it seems.

RetepRennelk commented 3 years ago

In order to make org-noter-pdftools-insert-precise-note work as described above, a single change in org-pdftools-get-link is required, i.e., a change from (pdf-view-active-region t) to (pdf-view-active-region).

If pdf-view-active-region is called with a non-nil argument (as it is currently), the selected region will be deactivated after running org-pdftools-get-link. And this prevents org-noter-insert-note to retrieve the previously selected text by calling pdf-view-active-region-text, which then can also not be inserted as a new heading.

Having reviewed the code quite a bit, it feels strange that the current implementation should work for you as is, i.e., without this change. Maybe there is an issue with the platform? I am on Windows.

fuxialexander commented 3 years ago

Thanks for your comment! Indeed org-noter was not able to retrieve the selected text as title due to the region be deactivated. I thought I set that explicitly to t for some reason but cannot remember it anymore. So I'll change it to nil for now.

However, I still don't quite understand how this issue is related to the location format and why I don't have the error warning. I'm on Linux with Emacs 28 so it could be a platform-specific thing.

roy-tancredi commented 3 years ago

I currently have similar problem - after steps specified by @RetepRennelk:

Steps for reproduction:

  • Select text in a pdf
  • Call org-noter-insert-precise-note or org-noter-pdftools-insert-precise-note

I can't even insert note content and I'm getting image-mode-window-get: Wrong type argument: listp, t

I inspected that there is no (pdf-view-active-region t) in rg-pdftools-get-link definition. Can you help me guys with that? Or if there is need for more info please give me guidelines for that.

org-noter-pdftools version: 20210118.1611 org-noter version: 20191020.1212 pdf-tools version : 20200512.1524 Emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0) of 2021-04-04, unofficial emacs-snapshot build: http://emacs.ganneff.de/, git commit dd5ba88afbb63f54603cc632fc55993c04531a85 OS: Debian GNU/Linux 10 (buster)