Skip to content

Commit

Permalink
Do not go into infinite loop with entries cross-referencing themselves.
Browse files Browse the repository at this point in the history
This fixes Github issue #281.
  • Loading branch information
Joost Kremers committed Nov 16, 2023
1 parent f477d2b commit 4410933
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ebib-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -2034,10 +2034,14 @@ system."
(xref-key (ebib-get-field-value "xref" key db 'noerror 'unbraced)))
;; Alist of name of refering field, and bibkey to which it refers. Order
;; matters here -- earlier xdata keys take precedence, then later ones, then
;; the crossref key (this follows the BibLaTeX implementation).
`(,@(mapcar (lambda (key) `("xdata" . ,key)) xdata-key-list)
,@(when crossref-key `(("crossref" . ,crossref-key)))
,@(when xref-key `(("xref" . ,xref-key))))))
;; the crossref key (this follows the BibLaTeX implementation). As a
;; precaution, cross-referencing fields that reference the entry itself are
;; removed, because they would throw Ebib in an infinite loop.
(cl-remove-if (lambda (e)
(string= key (cdr e)))
`(,@(mapcar (lambda (key) `("xdata" . ,key)) xdata-key-list)
,@(when crossref-key `(("crossref" . ,crossref-key)))
,@(when xref-key `(("xref" . ,xref-key)))))))

(defun ebib-get-field-value (field key db &optional noerror unbraced xref expand-strings)
"Return the value of FIELD in entry KEY in database DB.
Expand Down

0 comments on commit 4410933

Please sign in to comment.