Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org-ref gives "Wrong type argument: listp, 771" #1121

Open
sprig opened this issue Aug 31, 2024 · 2 comments
Open

org-ref gives "Wrong type argument: listp, 771" #1121

sprig opened this issue Aug 31, 2024 · 2 comments

Comments

@sprig
Copy link

sprig commented Aug 31, 2024

Hi,
Thanks for org-ref!

Running org-ref in an org buffer in emacs 29.2 gives the above messages. I traced the code and found the error originating in this function from org-ref:

;;** bad citations, labels, refs and files in orgfile
;;  These are used i
(defvar bibtex-files)
(defvar bibtex-file-path)
(defun org-ref-bad-cite-candidates ()
  "Return a list of conses (key . marker) where key does not exist in the known bibliography files, and marker points to the key."
  (let* ((cp (point))			; save to return to later
         (bibtex-files (cl-loop for f in (org-ref-find-bibliography)
				if (file-exists-p f)
				collect (file-truename f)))
         (bibtex-file-path (mapconcat
                            (lambda (x)
                              (file-name-directory (file-truename x)))
                            bibtex-files ":"))
         (bibtex-keys (mapcar (lambda (x) (car x))
                              (bibtex-global-key-alist)))
         (bad-citations '()))

    (org-element-map (org-ref-parse-buffer) 'link
      (lambda (link)
        (let ((plist (nth 1 link)))
          (when (assoc (plist-get plist :type) org-ref-cite-types)
	    (when (not (string= "*" (plist-get plist :path)))
	      (cl-loop for ref in (plist-get (org-ref-parse-cite-path (plist-get plist :path)) :references)
		       do
		       (when (not (member (plist-get ref :key) bibtex-keys))
			 (goto-char (org-element-property :begin link))
			 (re-search-forward (plist-get ref :key))
			 (push (cons (plist-get ref :key) (point-marker)) bad-citations)))))))
      ;; add with-affiliates to get cites in caption
      nil nil nil t)
    (goto-char cp)
    bad-citations))

Specifically in this sexp:

         (mapcar (lambda (x) (car x))
                              (bibtex-global-key-alist))

It seems that the result from (bibtex-global-key-alist) is some function reference, rather than an alist.

Result: #f(compiled-function (string pred action) #<bytecode 0x1dfcf93f30d2e84b>)

Seems like a bug in bibtex, although I'm not sure - other functionality seems to work correctly, e.g. org-ref-insert-link. On the other hand, it seems that the only places this function is used inside bibtex is in bibtex-completion-at-point-function as well as bibtex-read-key which I assume helm overrides.

Any idea what's going on?

@jkitchin
Copy link
Owner

jkitchin commented Sep 1, 2024

I can't reproduce this on Emacs 30. For me, bibtex-global-key-alist is a function that returns an alist. It seems weird it would return a function.

I guess what is happening is that code gets run in a bibtex file. Then, it looks like bibtex-global-key-alist returns bibtex-reference-keys, which does have the results you showed. I don't know why that would happen though.

Can you run this elisp block in an org file successfully?

#+BEGIN_SRC emacs-lisp
(org-ref-bad-cite-candidates)
#+END_SRC

#+RESULTS:
: ((not-today . #<marker at 96 in 2024-09-01.org>))

[[cite:&not-today]]

@sprig
Copy link
Author

sprig commented Sep 1, 2024

Hi!

Thanks for your response.

I cannot right now test on emacs above 29.2 because network connections there (such as in package.el) lead to hangs. I saw a similar bug report and apparently a fix for future versions but I'm not sure it's out yet.

The code above raises the same message as in the title...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants