Skip to content

Commit

Permalink
fix stupid bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarcus committed Mar 25, 2021
1 parent 3644ec7 commit 0bccaf0
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions bibtex-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ bibliography file is reparsed.")
(defvar bibtex-completion-string-hash-table nil
"A hash table used for string replacements.")


(defun bibtex-completion-normalize-bibliography (&optional type)
"Return a list of bibliography file(s) in `bibtex-completion-bibliography'.
If there are org mode bibliography-files, their corresponding
Expand Down Expand Up @@ -415,28 +414,28 @@ Also sets `bibtex-completion-display-formats-internal'."
;; Pre-calculate minimal widths needed by the format strings for
;; various entry types:
(setq bibtex-completion-display-formats-internal
bibtex-completion-process-display-format
bibtex-completion-display-formats))
; BD: move this to function, turn variable into alist?

(defun bibtex-completion-process-display-format (display-formats)
"Pre-calculate minimal widths needed by the FORMAT strings for
various entry types."
(mapcar (lambda (format)
(let* ((format-string (cdr format))
(fields-width 0)
(string-width
(string-width
(s-format format-string
(lambda (field)
(setq fields-width
(+ fields-width
(string-to-number
(or (cadr (split-string field ":"))
""))))
"")))))
(-cons* (car format) format-string (+ fields-width string-width))))
display-formats))
(bibtex-completion-process-display-format
bibtex-completion-display-formats)))
; BD: turn variable into alist?

(defun bibtex-completion-process-display-format (formats)
"Pre-calculate minimal widths needed by the FORMATS strings for various entry types."
(cl-loop
for format in formats
collect
(let* ((format-string (cdr format))
(fields-width 0)
(string-width
(string-width
(s-format format-string
(lambda (field)
(setq fields-width
(+ fields-width
(string-to-number
(or (cadr (split-string field ":"))
""))))
"")))))
(-cons* (car format) format-string (+ fields-width string-width)))))

(defun bibtex-completion-clear-cache (&optional files)
"Clears FILES from cache.
Expand Down Expand Up @@ -854,7 +853,7 @@ find a PDF file."
:test (lambda (x y) (string= (s-downcase x) (s-downcase y)))
:key 'car :from-end t))

(defun bibtex-completion-format-entry (entry width & alt-display-formats)
(defun bibtex-completion-format-entry (entry width &optional alt-display-formats)
"Formats a BibTeX ENTRY for display in results list.
WIDTH is the width of the results list. The display format is
governed by the variable `bibtex-completion-display-formats', or
Expand Down

0 comments on commit 0bccaf0

Please sign in to comment.