summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parsebib.el22
1 files changed, 10 insertions, 12 deletions
diff --git a/parsebib.el b/parsebib.el
index 84b222c..2fcc643 100644
--- a/parsebib.el
+++ b/parsebib.el
@@ -323,9 +323,8 @@ the entry. The latter should be at position LIMIT."
(defun parsebib-collect-strings (&optional hash)
"Collect all @String definitions in the current buffer.
Return value is a hash with the abbreviations as keys and the
-expansions as values. If HASH is a hash table, the abbeviations
-are stored there instead and nil is returned. Note that HASH
-should use `equal' as its test function."
+expansions as values. If HASH is a hash table with test function
+`equal', it is used to store the @String definitions."
(save-excursion
(goto-char (point-min))
(let* ((res (if (and (hash-table-p hash)
@@ -338,8 +337,7 @@ should use `equal' as its test function."
(when (cl-equalp item "string")
(setq string (parsebib-read-string))
(puthash (car string) (cdr string) res)))
- (unless hash
- res))))
+ hash)))
(defun parsebib-collect-preambles ()
"Collect all @Preamble definitions in the current buffer.
@@ -365,12 +363,13 @@ Return a list of strings, each string a separate @Comment."
(push (parsebib-read-comment) res)))
(nreverse res))))
-(defun parsebib-collect-entries (&optional hash)
+(defun parsebib-collect-entries (&optional hash strings)
"Collect all entries is the current buffer.
Return value is a hash table containing the entries. If HASH is
-a hash table, the entries are stored there instead and nil is
-returned. Note that HASH should use `equal' as its test
-function."
+a hash table, with test function `equal', it is used to store the
+entries. If STRINGS is non-nil, it should be a hash table of
+string definitions, which are used to expand abbreviations used
+in the entries."
(save-excursion
(goto-char (point-min))
(let* ((res (if (and (hash-table-p hash)
@@ -381,11 +380,10 @@ function."
(cl-loop for entry-type = (parsebib-find-next-item)
while entry-type do
(unless (member-ignore-case entry-type '("preamble" "string" "comment"))
- (setq entry (parsebib-read-entry entry-type))
+ (setq entry (parsebib-read-entry entry-type nil strings))
(if entry
(puthash (cdr (assoc-string "=key=" entry)) entry res))))
- (unless hash
- res))))
+ hash)))
(defun parsebib-find-bibtex-dialect ()
"Find the BibTeX dialect of a file if one is set.