summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoost Kremers <joostkremers@fastmail.fm>2017-03-10 20:09:09 +0100
committerJoost Kremers <joostkremers@fastmail.fm>2017-03-10 20:09:09 +0100
commit1879e0c5696601005b4cc064251cda63a9fd95f2 (patch)
treefbb2bb48a53a96b1d836d080aba7fcefb6e49f77
parentfd58a8e40d0f004ac1f83409be435761b0a76653 (diff)
Refactor parsebib-read-string.
Also update doc string.
-rw-r--r--parsebib.el25
1 files changed, 11 insertions, 14 deletions
diff --git a/parsebib.el b/parsebib.el
index ae384f1..468f439 100644
--- a/parsebib.el
+++ b/parsebib.el
@@ -211,26 +211,23 @@ beginning of a line, but the @String entry must start at the
beginning of the line POS is on. If POS is nil, it defaults to
point.
-If STRINGS is provided it is assumed to be a hash table passed to
-parsebib-replace-strings."
+If STRINGS is provided it should be a hash table with string
+abbreviations, which are used to expand abbrevs in the string's
+expansion."
+ (interactive)
(when pos (goto-char pos))
(beginning-of-line)
- (when (parsebib--looking-at-goto-end (concat parsebib--entry-start "string[[:space:]]*[\(\{]"))
+ (when (parsebib--looking-at-goto-end (concat parsebib--entry-start "\\(string[[:space:]]*\\)[\(\{]") 1)
(let ((limit (save-excursion ; find the position of the matching end parenthesis
- (forward-char -1)
(parsebib--match-paren-forward)
(point))))
- (skip-chars-forward "#%'(),={} \n\t\f" limit) ; move up to the abbrev
- (let* ((beg (point)) ; read the abbrev
- (abbr (if (parsebib--looking-at-goto-end (concat "\\(" parsebib--bibtex-identifier "\\)[ \t\n\f]*=") 1)
- (buffer-substring-no-properties beg (point))
- nil)))
+ (parsebib--looking-at-goto-end (concat "[({]\\(" parsebib--bibtex-identifier "\\)[[:space:]]*=[[:space:]]*"))
+ (let ((abbr (match-string-no-properties 1)))
(when (and abbr (> (length abbr) 0)) ; if we found an abbrev
- (skip-chars-forward "#%'(),={} \n\t\f" limit) ; move forward to the expansion
- (let* ((beg (point)) ; read the expansion
- (expansion (parsebib-replace-strings
- (buffer-substring-no-properties beg limit)
- strings)))
+ (let ((expansion (parsebib-replace-strings
+ (buffer-substring-no-properties (point) limit)
+ strings)))
+ (goto-char (1+ limit))
(cons abbr expansion)))))))
(defun parsebib-read-preamble (&optional pos)