-;;; refer.el --- look up references in bibliography files.
+;;; refer.el --- look up references in bibliography files
-;; Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1996, 2001, 2002, 2003, 2004,
+;; 2005, 2006 Free Software Foundation, Inc.
;; Author: Ashwin Ram <ashwin@cc.gatech.edu>
-;; Maintainer: Gernot Heiser <gernot@jungfrau.disy.cse.unsw.EDU.AU>
+;; Maintainer: Gernot Heiser <gernot@acm.org>
;; Adapted-By: ESR
;; Keywords: bib
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(if (looking-at
"[ \t\n]*@\\s-*[a-zA-Z][a-zA-Z0-9]*\\s-*{\\s-*\\([^ \t\n,]+\\)\\s-*,")
(buffer-substring (match-beginning 1) (match-end 1))
- (error "Cannot find key for entry in file %s."
+ (error "Cannot find key for entry in file %s"
(car refer-saved-state))))))
(if (not (= (point) old-point))
(set-mark old-point))))
;; find window in which to display bibliography file.
;; if a bibliography file is already displayed in a window, use
;; that one, otherwise use any window other than the current one
- (while (not found)
- (while (and (not (null (setq file (nth n files))))
- (setq n (1+ n))
- (not (string-equal file
- (buffer-file-name
- (window-buffer new-window))))))
- (setq found
- (if (null file)
- (eq (setq new-window (next-window new-window 'nomini))
- old-window)
- 't)))
- (if (null file) ; didn't find bib file in any window:
- (progn (if (one-window-p 'nomini)
- (setq old-window (split-window)))
- (setq new-window (next-window old-window 'nomini))))
+ (setq new-window
+ (get-window-with-predicate
+ (lambda (w)
+ (while (and (not (null (setq file (nth n files))))
+ (setq n (1+ n))
+ (not (string-equal file
+ (buffer-file-name
+ (window-buffer w))))))
+ file)))
+ (unless new-window
+ ;; didn't find bib file in any window:
+ (when (one-window-p 'nomini)
+ (setq old-window (split-window)))
+ (setq new-window (next-window old-window 'nomini)))
(select-window (if refer-same-file
old-window
new-window)) ; the window in which to show the bib file
(throw 'found (find-file file)))
(setq refer-saved-pos nil
files (cdr files)))
- (progn (message "Scanning %s... No such file" (car files) (ding))
+ (progn (ding)
+ (message "Scanning %s... No such file" (car files))
(sit-for 1)
(setq files (cdr files))))))
- (message "Keywords \"%s\" not found in any \.bib file" keywords (ding)))
+ (ding)
+ (message "Keywords \"%s\" not found in any \.bib file" keywords))
(select-window old-window)))
(defun refer-find-entry-in-file (keywords-list file &optional old-pos)
(list refer-bib-directory))))
(files
(cond
- ((null refer-bib-files)
+ ((null refer-bib-files)
(list (expand-file-name
(if (eq major-mode 'bibtex-mode)
(read-file-name
- (format ".bib file: (default %s) "
+ (format ".bib file (default %s): "
(file-name-nondirectory
(buffer-file-name)))
(file-name-directory (buffer-file-name))
(eq refer-bib-directory 'bibinputs)))
(refer-expand-files refer-bib-files dir-list))
((listp refer-bib-files) refer-bib-files)
- (t (error "Illegal value for refer-bib-files: %s"
+ (t (error "Invalid value for refer-bib-files: %s"
refer-bib-files)))))
(if (or (eq refer-bib-directory 'texinputs)
(eq refer-bib-directory 'bibinputs))
(setq refer-bib-files files))
files))
+;;; arch-tag: 151f641b-e79b-462b-9a29-a95c3793f300
;;; refer.el ends here
-