summaryrefslogtreecommitdiff
path: root/lisp/textmodes/reftex-cite.el
diff options
context:
space:
mode:
authorCarsten Dominik <dominik@science.uva.nl>2006-11-07 08:27:16 +0000
committerCarsten Dominik <dominik@science.uva.nl>2006-11-07 08:27:16 +0000
commit759f7eed9e78ced41033d1132b5e59ac4beca0c9 (patch)
treedb3c08f8eb84c3acd9915a046b7b535c74b34b87 /lisp/textmodes/reftex-cite.el
parent53a8eb2c92fae409e891f2a71ab2d7b3b8aeffc6 (diff)
downloademacs-759f7eed9e78ced41033d1132b5e59ac4beca0c9.tar.gz
(reftex-pop-to-bibtex-entry): Preserve point when displaying a bibtex
cross reference in the echo area.
Diffstat (limited to 'lisp/textmodes/reftex-cite.el')
-rw-r--r--lisp/textmodes/reftex-cite.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index ced44757ffd..a83c790f076 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -125,7 +125,7 @@
;; If MARK-TO-KILL is non-nil, mark new buffer to kill.
;; If HIGHLIGHT is non-nil, highlight the match.
;; If ITEM in non-nil, search for bibitem instead of database entry.
- ;; If RETURN is non-nil, just return the entry.
+ ;; If RETURN is non-nil, just return the entry and restore point.
(let* ((re
(if item
@@ -133,7 +133,7 @@
(concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
"[, \t\r\n}]")))
(buffer-conf (current-buffer))
- file buf pos)
+ file buf pos oldpos)
(catch 'exit
(while file-list
@@ -142,9 +142,11 @@
(unless (setq buf (reftex-get-file-buffer-force file mark-to-kill))
(error "No such file %s" file))
(set-buffer buf)
+ (setq oldpos (point))
(widen)
(goto-char (point-min))
- (when (re-search-forward re nil t)
+ (if (not (re-search-forward re nil t))
+ (goto-char oldpos) ;; restore previous position of point
(goto-char (match-beginning 0))
(setq pos (point))
(when return
@@ -152,6 +154,7 @@
(if item (goto-char (match-end 0)))
(setq return (buffer-substring
(point) (reftex-end-of-bib-entry item)))
+ (goto-char oldpos) ;; restore point.
(set-buffer buffer-conf)
(throw 'exit return))
(switch-to-buffer-other-window buf)