From 99f65cface3bf5f8a8af7b9bd8a7159b5c77fad9 Mon Sep 17 00:00:00 2001 From: Ralf Angeli Date: Sat, 16 Oct 2010 17:08:47 +0200 Subject: [PATCH] Fix searching for bibitem entries. --- lisp/ChangeLog | 7 ++++++ lisp/textmodes/reftex-cite.el | 45 +++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 931ee696482..109b4d99f95 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2010-10-16 Ralf Angeli + + * textmodes/reftex-cite.el + (reftex-extract-bib-entries-from-thebibliography): Do not move + point when searching for \bibitem entries. Match entries with + spaces or tabs in front of arguments. + 2010-10-16 Chong Yidong * cus-theme.el (customize-create-theme): Delete overlays after diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index 79797b4791b..5edd9f24122 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -358,27 +358,30 @@ (message "Scanning thebibliography environment in %s" file) (with-current-buffer buf - (save-restriction - (widen) - (goto-char (point-min)) - (while (re-search-forward - "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) - (beginning-of-line 2) - (setq start (point)) - (if (re-search-forward - "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) - (progn - (beginning-of-line 1) - (setq end (point)))) - (when (and start end) - (setq entries - (append entries - (mapcar 'reftex-parse-bibitem - (delete "" - (split-string - (buffer-substring-no-properties start end) - "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))) - (goto-char end))))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (while (re-search-forward + "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) + (beginning-of-line 2) + (setq start (point)) + (if (re-search-forward + "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) + (progn + (beginning-of-line 1) + (setq end (point)))) + (when (and start end) + (setq entries + (append entries + (mapcar 'reftex-parse-bibitem + (delete "" + (split-string + (buffer-substring-no-properties + start end) + "[ \t\n\r]*\\\\bibitem\ +\\(\\[[^]]*]\\)*\[ \t]*")))))) + (goto-char end)))))) (unless entries (error "No bibitems found")) -- 2.39.2