Mercurial > emacs
annotate lisp/textmodes/refer.el @ 96246:af03ed6d2772
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 25 Jun 2008 00:35:02 +0000 |
parents | f4a69fedbd46 |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30326
diff
changeset
|
1 ;;; refer.el --- look up references in bibliography files |
7638 | 2 |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1992, 1996, 2001, 2002, 2003, 2004, |
79719 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
7638 | 5 |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
6 ;; Author: Ashwin Ram <ashwin@cc.gatech.edu> |
30326
9d3a17593818
Correct maintainer's email address.
Gerd Moellmann <gerd@gnu.org>
parents:
29997
diff
changeset
|
7 ;; Maintainer: Gernot Heiser <gernot@acm.org> |
7638 | 8 ;; Adapted-By: ESR |
9 ;; Keywords: bib | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
7638 | 14 ;; it under the terms of the GNU General Public License as published by |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
7638 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
7638 | 25 |
26 ;;; Commentary: | |
14169 | 27 |
7638 | 28 ;; Functions to look up references in bibliography files given lists of |
29 ;; keywords, similar to refer(1). I don't use tags since tags on .bib files | |
30 ;; only picks up the cite key, where as refer-find-entry looks for occurrences | |
31 ;; of keywords anywhere in the bibliography entry. | |
32 ;; | |
33 ;; To use: | |
34 ;; (autoload 'refer-find-entry "refer" nil t) | |
35 ;; or (require 'refer) | |
36 ;; | |
37 ;; To look for an article by Knuth about semaphores: | |
38 ;; Invoke refer-find-entry, then in response to the Keywords: prompt, | |
39 ;; say: Knuth semaphores (a blank-separated list of keywords to be used | |
40 ;; as search strings). | |
41 ;; | |
42 ;; To continue the previous search, i.e., to search for the next occurrence | |
43 ;; of the keywords, use refer-find-next-entry, or invoke refer-find-entry | |
44 ;; with a prefix argument. | |
45 ;; | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 ;; Once you've found the entry you want to reference, invoke |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 ;; refer-yank-key to insert it at point in the current buffer |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 ;; (typically as the argument of a \cite{} command). |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 ;; |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 ;; I use (define-key tex-mode-map "\C-c\C-y" 'refer-yank-key) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
51 ;; to bind this often-used function to a key in (la)tex-mode. |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 ;; |
7638 | 53 ;; If the list of bibliography files changes, reinitialize the variable |
54 ;; refer-bib-files. | |
55 ;; | |
56 ;; To customize: | |
57 ;; See variables refer-bib-files, refer-cache-bib-files and | |
58 ;; refer-bib-files-regexp. By default, these are set up so that refer | |
59 ;; looks for the keywords you specify in all the .bib files in the current | |
60 ;; directory. | |
61 ;; | |
62 ;; The only assumption I make about bib files is that they contain a bunch | |
63 ;; of entries, one to a paragraph. refer-find-entry searches paragraph by | |
64 ;; paragraph, looking for a paragraph containing all the keywords | |
65 ;; specified. So you should be able to use pretty much any bib file with | |
66 ;; this code. If your bib file does not use paragraphs to separate | |
67 ;; entries, try setting the paragraph-start/separate variables, or changing | |
68 ;; the (forward-paragraph 1) call in refer-find-entry-in-file. | |
69 | |
70 ;;; Code: | |
71 | |
72 (provide 'refer) | |
73 | |
20959 | 74 (defgroup refer nil |
75 "Look up references in bibliography files." | |
76 :prefix "refer-" | |
77 :group 'wp) | |
78 | |
79 (defcustom refer-bib-directory nil | |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
80 "Directory, or list of directories, to search for \\.bib files. |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
81 Can be set to 'bibinputs or 'texinputs, in which case the environment |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
82 variable BIBINPUTS or TEXINPUTS, respectively, is used to obtain a |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
83 list of directories. Useful only if `refer-bib-files' is set to 'dir or |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
84 a list of file names (without directory). A value of nil indicates the |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
85 current working directory. |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
86 |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
87 If `refer-bib-directory' is 'bibinputs or 'texinputs, it is setq'd to |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
88 the appropriate list of directories when it is first used. |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
89 |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
90 Note that an empty directory is interpreted by BibTeX as indicating |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
91 the default search path. Since Refer does not know that default path, |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
92 it cannot search it. Include that path explicitly in your BIBINPUTS |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
93 environment if you really want it searched (which is not likely to |
20959 | 94 happen anyway)." |
95 :type '(choice (repeat directory) (const bibinputs) (const texinputs)) | |
96 :group 'refer) | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
97 |
20959 | 98 (defcustom refer-bib-files 'dir |
99 "*List of \\.bib files to search for references, | |
7638 | 100 or one of the following special values: |
101 nil = prompt for \\.bib file (if visiting a \\.bib file, use it as default) | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
102 auto = read \\.bib file names from appropriate command in buffer (see |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
103 `refer-bib-files-regexp') unless the buffer's mode is `bibtex-mode', |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
104 in which case only the buffer is searched |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
105 dir = use all \\.bib files in directories referenced by `refer-bib-directory'. |
7638 | 106 |
107 If a specified file doesn't exist and has no extension, a \\.bib extension | |
108 is automatically tried. | |
109 | |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
110 If `refer-bib-files' is nil, auto or dir, it is setq'd to the appropriate |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
111 list of files when it is first used if `refer-cache-bib-files' is t. If |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
112 `refer-cache-bib-files' is nil, the list of \\.bib files to use is re-read |
20959 | 113 each time it is needed." |
114 :type '(choice (repeat file) (const nil) (const auto) (const dir)) | |
115 :group 'refer) | |
7638 | 116 |
20959 | 117 (defcustom refer-cache-bib-files t |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
118 "*Variable determining whether the value of `refer-bib-files' should be cached. |
7638 | 119 If t, initialize the value of refer-bib-files the first time it is used. If |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
120 nil, re-read the list of \\.bib files depending on the value of `refer-bib-files' |
20959 | 121 each time it is needed." |
122 :type 'boolean | |
123 :group 'refer) | |
7638 | 124 |
20959 | 125 (defcustom refer-bib-files-regexp "\\\\bibliography" |
126 "*Regexp matching a bibliography file declaration. | |
7638 | 127 The current buffer is expected to contain a line such as |
128 \\bibliography{file1,file2,file3} | |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
129 which is read to set up `refer-bib-files'. The regexp must specify the command |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
130 \(such as \\bibliography) that is used to specify the list of bib files. The |
7638 | 131 command is expected to specify a file name, or a list of comma-separated file |
132 names, within curly braces. | |
133 If a specified file doesn't exist and has no extension, a \\.bib extension | |
20959 | 134 is automatically tried." |
135 :type 'regexp | |
136 :group 'refer) | |
7638 | 137 |
138 (make-variable-buffer-local 'refer-bib-files) | |
139 (make-variable-buffer-local 'refer-cache-bib-files) | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
140 (make-variable-buffer-local 'refer-bib-directory) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
141 |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
142 ;;; Internal variables |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
143 (defvar refer-saved-state nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
144 (defvar refer-previous-keywords nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
145 (defvar refer-saved-pos nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
146 (defvar refer-same-file nil) |
7638 | 147 |
148 (defun refer-find-entry (keywords &optional continue) | |
149 "Find entry in refer-bib-files containing KEYWORDS. | |
150 If KEYWORDS is nil, prompt user for blank-separated list of keywords. | |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
151 If CONTINUE is non-nil, or if called interactively with a prefix arg, |
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
152 look for next entry by continuing search from previous point." |
7638 | 153 (interactive (list nil current-prefix-arg)) |
154 (or keywords (setq keywords (if continue | |
155 refer-previous-keywords | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
156 (read-string "Keywords: ")))) |
7638 | 157 (setq refer-previous-keywords keywords) |
158 (refer-find-entry-internal keywords continue)) | |
159 | |
160 (defun refer-find-next-entry () | |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
161 "Find next occurrence of entry in `refer-bib-files'. See `refer-find-entry'." |
7638 | 162 (interactive) |
163 (refer-find-entry-internal refer-previous-keywords t)) | |
164 | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
165 (defun refer-yank-key () |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
166 "Inserts at point in current buffer the \"key\" field of the entry |
74586
30655edb57ac
(refer-find-entry): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
167 found on the last `refer-find-entry' or `refer-find-next-entry'." |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
168 (interactive) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
169 (let ((old-point (point))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
170 (insert |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 (save-window-excursion |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
172 (save-excursion |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
173 (find-file (car refer-saved-state)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
174 (if (looking-at |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
175 "[ \t\n]*@\\s-*[a-zA-Z][a-zA-Z0-9]*\\s-*{\\s-*\\([^ \t\n,]+\\)\\s-*,") |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
176 (buffer-substring (match-beginning 1) (match-end 1)) |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30326
diff
changeset
|
177 (error "Cannot find key for entry in file %s" |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
178 (car refer-saved-state)))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
179 (if (not (= (point) old-point)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
180 (set-mark old-point)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
181 |
7638 | 182 (defun refer-find-entry-internal (keywords continue) |
12952
0ad88e6d8ef1
(refer-every): Renamed from every.
Richard M. Stallman <rms@gnu.org>
parents:
7638
diff
changeset
|
183 (let ((keywords-list (refer-convert-string-to-list-of-strings keywords)) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
184 (old-buffer (current-buffer)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
185 (old-window (selected-window)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
186 (new-window (selected-window)) |
7638 | 187 (files (if continue |
188 refer-saved-state | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
189 (setq refer-saved-pos nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
190 (refer-get-bib-files))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
191 (n 0) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
192 (found nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
193 (file nil)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
194 ;; find window in which to display bibliography file. |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
195 ;; if a bibliography file is already displayed in a window, use |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
196 ;; that one, otherwise use any window other than the current one |
29997
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
197 (setq new-window |
39176
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
198 (get-window-with-predicate |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
199 (lambda (w) |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
200 (while (and (not (null (setq file (nth n files)))) |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
201 (setq n (1+ n)) |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
202 (not (string-equal file |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
203 (buffer-file-name |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
204 (window-buffer w)))))) |
286d91f8ebe3
(refer-find-entry-internal): Use
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
205 file))) |
29997
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
206 (unless new-window |
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
207 ;; didn't find bib file in any window: |
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
208 (when (one-window-p 'nomini) |
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
209 (setq old-window (split-window))) |
d6a745cf3bfc
(refer-find-entry-internal): Use some-window
Gerd Moellmann <gerd@gnu.org>
parents:
20959
diff
changeset
|
210 (setq new-window (next-window old-window 'nomini))) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
211 (select-window (if refer-same-file |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
212 old-window |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
213 new-window)) ; the window in which to show the bib file |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
214 (catch 'found |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
215 (while files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
216 (let ((file (cond ((file-exists-p (car files)) (car files)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
217 ((file-exists-p (concat (car files) ".bib")) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
218 (concat (car files) ".bib"))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
219 (setq refer-saved-state files) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
220 (if file |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
221 (if (refer-find-entry-in-file keywords-list file refer-saved-pos) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
222 (progn |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
223 (setq refer-saved-pos (point)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
224 (recenter 0) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
225 (throw 'found (find-file file))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
226 (setq refer-saved-pos nil |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
227 files (cdr files))) |
53853
9f8bd1b673a8
(refer-find-entry-internal): Remove extra
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
228 (progn (ding) |
9f8bd1b673a8
(refer-find-entry-internal): Remove extra
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
229 (message "Scanning %s... No such file" (car files)) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
230 (sit-for 1) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
231 (setq files (cdr files)))))) |
53853
9f8bd1b673a8
(refer-find-entry-internal): Remove extra
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
232 (ding) |
9f8bd1b673a8
(refer-find-entry-internal): Remove extra
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
233 (message "Keywords \"%s\" not found in any \.bib file" keywords)) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
234 (select-window old-window))) |
7638 | 235 |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
236 (defun refer-find-entry-in-file (keywords-list file &optional old-pos) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
237 (message "Scanning %s..." file) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
238 (expand-file-name file) |
7638 | 239 (set-buffer (find-file-noselect file)) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
240 (find-file file) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
241 (if (not old-pos) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
242 (goto-char (point-min)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
243 (goto-char old-pos) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
244 (forward-paragraph 1)) |
7638 | 245 (let ((begin (point)) |
246 (end 0) | |
247 (found nil)) | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
248 (while (and (not found) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
249 (not (eobp))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
250 (forward-paragraph 1) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
251 (setq end (point)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
252 (setq found |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
253 (refer-every (function (lambda (keyword) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
254 (goto-char begin) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
255 (re-search-forward keyword end t))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
256 keywords-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
257 (if (not found) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
258 (progn |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
259 (setq begin end) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
260 (goto-char begin)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
261 (if found |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
262 (progn (goto-char begin) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
263 (re-search-forward "\\W" nil t) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
264 (message "Scanning %s... found" file)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
265 (progn (message "Scanning %s... not found" file) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
266 nil)))) |
7638 | 267 |
12952
0ad88e6d8ef1
(refer-every): Renamed from every.
Richard M. Stallman <rms@gnu.org>
parents:
7638
diff
changeset
|
268 (defun refer-every (pred l) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
269 (cond ((null l) nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
270 ((funcall pred (car l)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
271 (or (null (cdr l)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
272 (refer-every pred (cdr l)))))) |
7638 | 273 |
12952
0ad88e6d8ef1
(refer-every): Renamed from every.
Richard M. Stallman <rms@gnu.org>
parents:
7638
diff
changeset
|
274 (defun refer-convert-string-to-list-of-strings (s) |
7638 | 275 (let ((current (current-buffer)) |
276 (temp-buffer (get-buffer-create "*refer-temp*"))) | |
277 (set-buffer temp-buffer) | |
278 (erase-buffer) | |
279 (insert (regexp-quote s)) | |
280 (goto-char (point-min)) | |
281 (insert "(\"") | |
282 (while (re-search-forward "[ \t]+" nil t) | |
283 (replace-match "\" \"" t t)) | |
284 (goto-char (point-max)) | |
285 (insert "\")") | |
286 (goto-char (point-min)) | |
287 (prog1 (read temp-buffer) | |
288 (set-buffer current)))) | |
289 | |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
290 (defun refer-expand-files (file-list dir-list) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
291 (let (file files dir dirs) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
292 (while (setq file (car file-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
293 (setq dirs (copy-alist dir-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
294 (while (setq dir (car dirs)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
295 (if (file-exists-p (expand-file-name file dir)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
296 (setq files (append files (list (expand-file-name file dir))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
297 dirs nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
298 (if (file-exists-p (expand-file-name (concat file ".bib") dir)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
299 (setq files (append files (list (expand-file-name (concat file ".bib") |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
300 dir))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
301 dirs nil) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
302 (setq dirs (cdr dirs))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
303 (setq file-list (cdr file-list))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
304 files)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
305 |
7638 | 306 (defun refer-get-bib-files () |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
307 (let* ((dir-list |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
308 (cond |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
309 ((null refer-bib-directory) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
310 '(".")) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
311 ((or (eq refer-bib-directory 'texinputs) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
312 (eq refer-bib-directory 'bibinputs)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
313 (let ((envvar (getenv (if (eq refer-bib-directory 'texinputs) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
314 "TEXINPUTS" |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
315 "BIBINPUTS"))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
316 (dirs nil)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
317 (if (null envvar) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
318 (setq envvar ".")) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
319 (while (string-match ":" envvar) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
320 (let ((dir (substring envvar 0 (match-beginning 0)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
321 (if (and (not (string-equal "" dir)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
322 (file-directory-p dir)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
323 (setq dirs (append (list (expand-file-name dir nil)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
324 dirs)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
325 (setq envvar (substring envvar (match-end 0)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
326 (if (and (not (string-equal "" envvar)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
327 (file-directory-p envvar)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
328 (setq dirs (append (list envvar) dirs))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
329 (setq dirs (nreverse dirs)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
330 ((listp refer-bib-directory) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
331 refer-bib-directory) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
332 (t |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
333 (list refer-bib-directory)))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
334 (files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
335 (cond |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39176
diff
changeset
|
336 ((null refer-bib-files) |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
337 (list (expand-file-name |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
338 (if (eq major-mode 'bibtex-mode) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
339 (read-file-name |
65680
ed770a0a7846
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents:
64751
diff
changeset
|
340 (format ".bib file (default %s): " |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
341 (file-name-nondirectory |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
342 (buffer-file-name))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
343 (file-name-directory (buffer-file-name)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
344 (file-name-nondirectory (buffer-file-name)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
345 t) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
346 (read-file-name ".bib file: " nil nil t))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
347 ((eq refer-bib-files 'auto) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
348 (let ((files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
349 (save-excursion |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
350 (if (setq refer-same-file (eq major-mode 'bibtex-mode)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
351 (list buffer-file-name) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
352 (if (progn |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
353 (goto-char (point-min)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
354 (re-search-forward (concat refer-bib-files-regexp |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
355 "\\s-*\{") nil t)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
356 (let ((files (list (buffer-substring |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
357 (point) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
358 (progn |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
359 (re-search-forward "[,\}]" |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
360 nil t) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
361 (backward-char 1) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
362 (point)))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
363 (while (not (looking-at "\}")) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
364 (setq files (append files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
365 (list (buffer-substring |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
366 (progn (forward-char 1) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
367 (point)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
368 (progn (re-search-forward |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
369 "[,\}]" nil t) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
370 (backward-char 1) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
371 (point))))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
372 files) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
373 (error (concat "No \\\\bibliography command in this " |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
374 "buffer, can't read refer-bib-files"))))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
375 (refer-expand-files files dir-list))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
376 ((eq refer-bib-files 'dir) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
377 (let ((dirs (nreverse dir-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
378 dir files) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
379 (while (setq dir (car dirs)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
380 (setq files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
381 (append (directory-files dir t "\\.bib$") |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
382 files)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
383 (setq dirs (cdr dirs))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
384 files)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
385 ((and (listp refer-bib-files) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
386 (or (eq refer-bib-directory 'texinputs) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
387 (eq refer-bib-directory 'bibinputs))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
388 (refer-expand-files refer-bib-files dir-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
389 ((listp refer-bib-files) refer-bib-files) |
60918
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
53853
diff
changeset
|
390 (t (error "Invalid value for refer-bib-files: %s" |
16473
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
391 refer-bib-files))))) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
392 (if (or (eq refer-bib-directory 'texinputs) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
393 (eq refer-bib-directory 'bibinputs)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
394 (setq refer-bib-directory dir-list)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
395 (if refer-cache-bib-files |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
396 (setq refer-bib-files files)) |
4ef76e689d69
(refer-bib-directory): New variable, list of
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
397 files)) |
7638 | 398 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
399 ;; arch-tag: 151f641b-e79b-462b-9a29-a95c3793f300 |
7638 | 400 ;;; refer.el ends here |