jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.35k stars 242 forks source link

cannot open and edit notes #1094

Closed philohistoria closed 9 months ago

philohistoria commented 9 months ago

I have been using Emcas 26 and org-ref-20191023 without a problem. After upgrading to Emacs 29.1 and org-ref-20230921, strange things begin to occur:

backtrace shows:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
 regexp-quote(nil)
  bibtex-completion-get-entry1(nil)
  bibtex-completion-get-entry(nil)
  bibtex-completion-edit-notes-default((nil))
  bibtex-completion-edit-notes((nil))
  org-ref-open-notes-at-point()
  funcall-interactively(org-ref-open-notes-at-point)
  call-interactively(org-ref-open-notes-at-point)
  hydra--call-interactively-remap-maybe(org-ref-open-notes-at-point)
  org-ref-citation-hydra/org-ref-open-notes-at-point-and-exit()
  funcall-interactively(org-ref-citation-hydra/org-ref-open-notes-at-point-and-exit)
  call-interactively(org-ref-citation-hydra/org-ref-open-notes-at-point-and-exit nil nil)
  command-execute(org-ref-citation-hydra/org-ref-open-notes-at-point-and-exit)

------ here is my setup in init.el (I am using spacemacs; I have always been using one file to store my notes; and I prefer the old org-ref syntax simply because I have many old files that used the old syntex without &).

(setq bibtex-completion-bibliography '("~/Dropbox/Writings/globalbib/zoterolibrary.bib"))
(setq bibtex-completion-notes-path "~/Dropbox/Org-mode/paper_summary.org")

(setq bibtex-completion-notes-template-one-file
      (format
       "\n** ${author} (${year}): ${title}\n  :properties:\n  :custom_id: ${=key=}\n:end:\n"))

(setq bibtex-completion-notes-template-multiple-files
      (format
       "\n** ${author} (${year}): ${title}\n  :properties:\n  :custom_id: ${=key=}\n:end:\n"))
(setq org-ref-notes-function
      (lambda (thekey)
        (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
          (bibtex-completion-edit-notes
           (list (car (org-ref-get-bibtex-key-and-file thekey)))))))

I appreciate any thing that may be helpful! Below is the output of org-ref-debug

#+TITLE: org-ref debug

org-ref: Version 3.0

* System

- system-type :: System: darwin
- system-configuration :: aarch64-apple-darwin21.6.0
- window system :: Window system: ns
- Emacs :: GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646))
 of 2023-08-17
- org-version :: 9.6.6

* about org-ref

org-ref installed in [[/Users/han/.emacs.d/elpa/develop/org-ref-20230921.1327/org-ref.elc]].

* org-ref setup

-  org-ref-insert-link-function :: org-ref-insert-link
-  org-ref-insert-cite-function :: org-ref-cite-insert-helm
-  org-ref-insert-label-function :: org-ref-insert-label-link
-  org-ref-insert-ref-function :: org-ref-insert-ref-link
-  org-ref-cite-onclick-function :: #[257 \300 \207 [org-ref-citation-hydra/body] 2 

(fn _)]

* org-ref libraries

** org-ref-helm (loaded: t)
** org-ref-ivy  (loaded: nil)
** org-ref-pdf (loaded: nil)

- system pdftotext :: org-ref-pdf not loaded

You set =pdftotext-executable= to org-ref-pdf not loaded (exists: pdftotext-executable is not bound)

** org-ref-url-utils (loaded: nil)

* export variables

- org-latex-pdf-process :: ("latexmk -pdflatex='xelatex -interaction nonstopmode' -g -pdf -bibtex -f %f")
jkitchin commented 9 months ago

It sounds like (org-ref-get-bibtex-key-under-cursor) is not working right. I don't know what would cause that, other than font-lock is not working right in some files and not others. You might check Messages for things related to that.

I use Emacs 28, and don't see issues like this so far. Are you doing anything with native compiling?

jkitchin commented 9 months ago

In an org file where things are working, with your cursor on a cite link, you can type M-x describe-text-properties. You should see something like:

There are text properties here:
  cite-key             "gelžinytė-2023-python-toolk"
  face                 org-ref-cite-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:gelžinytė-2023-python-toolk")
  isearch-open-invisible org-fold-core--isearch-show
  isearch-open-invisible-temporary org-fold-core--isearch-show-temporary
  keymap               [Show]
  mouse-face           highlight
  org-fold--spec-org-link-description-global org-link-description
  org-fold--spec-org-link-global org-link

And in a file where it does not work I guess you will see something different. If that is the case, then it is almost certainly a font-lock issue.

philohistoria commented 9 months ago

Thanks! @jkitchin I have tried and don't think that's the font-lock issue


the below is a working link

Text content at position 143145:

There are text properties here:

  face                 org-ref-cite-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:law_take_2019")
  keymap               [Show]
  line-prefix          [Show]
  mouse-face           highlight
  wrap-prefix          [Show]

The below is a link that does not work (but with exact the same citation key)

There are text properties here:
  face                 org-ref-cite-face
  font-lock-multiline  t
  fontified            t
  help-echo            org-ref-cite-tooltip
  htmlize-link         (:uri "cite:law_take_2019")
  keymap               [Show]
  line-prefix          [Show]
  mouse-face           highlight
  wrap-prefix          [Show]
jkitchin commented 9 months ago

I think this suggests to me it is a font-lock issue. neither one is as complete as the example I shared, e.g. it is missing the cite-key property most critically, which is what is used to get the key. This is normally done in the org-ref-cite-activate function, which suggests to me your cite links are not getting activated correctly.

In your org files do you have mixed cite link syntaxes, e.g. cite:key and cite:&key?

Also, can you see what you have the variable org-ref-activate-cite-links set to? It should be t.

philohistoria commented 9 months ago

@jkitchin setting org-ref-activate-cite-links to t solves the problem for me. Thanks a lot for everything you have done for making this fantastic package!