Mercurial > emacs
annotate lisp/textmodes/refbib.el @ 103508:b3c1a923f213
* xdisp.c (Qbefore_string, Qafter_string): Add externs.
(load_overlay_strings): Remove externs.
(fast_find_position): Function deleted.
(mouse_face_from_buffer_pos): New function, based on
fast_find_position. Correctly handle before-strings,
display-strings, and after-strings (Bug#1220).
(note_mouse_highlight): Use mouse_face_from_buffer_pos.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 22 Jun 2009 01:53:11 +0000 |
parents | a9dc0e7c3f2b |
children | df4934f25eef |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; refbib.el --- convert refer-style references to ones usable by Latex bib |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
74509 | 3 ;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, |
100908 | 4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
845 | 5 |
829
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
6 ;; Author: Henry Kautz <kautz@research.att.com> |
64791
ef236edf96ec
No more contact with Henry Kautz.
Richard M. Stallman <rms@gnu.org>
parents:
64751
diff
changeset
|
7 ;; Maintainer: FSF |
829
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
8 ;; Keywords: bib, tex |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
9 |
36 | 10 ;; This file is part of GNU Emacs. |
11 | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
36 | 13 ;; 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
|
14 ;; 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
|
15 ;; (at your option) any later version. |
36 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; 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
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
36 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
25 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
26 |
36 | 27 ;; Use: from a buffer containing the refer-style bibliography, |
28 ;; M-x r2b-convert-buffer | |
29 ;; Program will prompt for an output buffer name, and will log | |
30 ;; warnings during the conversion process in the buffer *Log*. | |
31 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
32 ;;; Change Log: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
33 |
14169 | 34 ;; HISTORY |
35 ;; 9/88, created H.Kautz | |
36 ;; modified 1/19/89, allow books with editor but no author; | |
37 ;; added %O ordering field; | |
60918
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
52401
diff
changeset
|
38 ;; appended invalid multiple fields, instead of |
14169 | 39 ;; discarding; |
40 ;; added rule, a tech report whose %R number | |
41 ;; contains "ISBN" is really a book | |
42 ;; added rule, anything with an editor is a book | |
43 ;; or a proceedings | |
44 ;; added 'manual type, for items with institution | |
45 ;; but no author or editor | |
46 ;; fixed bug so trailing blanks are trimmed | |
47 ;; added 'proceedings type | |
48 ;; used "organization" field for proceedings | |
49 ;; modified 2/16/89, updated help messages | |
50 ;; modified 2/23/89, include capitalize stop words in r2b stop words, | |
51 ;; fixed problems with contractions (e.g. it's), | |
52 ;; caught multiple stop words in a row | |
53 ;; modified 3/1/89, fixed capitalize-title for first words all caps | |
54 ;; modified 3/15/89, allow use of " to delimit fields | |
55 ;; modified 4/18/89, properly "quote" special characters on output | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
56 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
57 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
58 |
36 | 59 ;********************************************************** |
60 ; User Parameters | |
61 | |
20959 | 62 (defgroup refbib nil |
63 "Convert refer-style references to ones usable by Latex bib." | |
64 :prefix "r2b-" | |
65 :group 'wp) | |
36 | 66 |
20959 | 67 (defcustom r2b-trace-on nil |
68 "*Non-nil means trace conversion." | |
69 :type 'boolean | |
70 :group 'refbib) | |
71 | |
72 (defcustom r2b-journal-abbrevs | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
73 '( |
20959 | 74 ) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
75 "Abbreviation list for journal names. |
36 | 76 If the car of an element matches a journal name exactly, it is replaced by |
77 the cadr when output. Braces must be included if replacement is a | |
78 {string}, but not if replacement is a bibtex abbreviation. The cadr | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
79 may be eliminated if is exactly the same as the car. |
36 | 80 Because titles are capitalized before matching, the abbreviation |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
81 for the journal name should be listed as beginning with a capital |
36 | 82 letter, even if it really doesn't. |
83 For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") | |
7639 | 84 \(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
85 \"Artificial Intelligence\", but would replace Ijcai81 with the |
20959 | 86 BibTeX macro \"ijcai7\"." |
87 :type '(repeat (list string string)) | |
88 :group 'refbib) | |
36 | 89 |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
90 (defcustom r2b-booktitle-abbrevs |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
91 '( |
20959 | 92 ) |
93 "Abbreviation list for book and proceedings names. | |
94 If the car of an element matches a title or booktitle exactly, it is | |
95 replaced by the cadr when output. Braces must be included if | |
96 replacement is a {string}, but not if replacement is a bibtex | |
97 abbreviation. The cadr may be eliminated if is exactly the same as | |
98 the car. | |
36 | 99 Because titles are capitalized before matching, the abbreviated title |
100 should be listed as beginning with a capital letter, even if it doesn't. | |
101 For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") | |
7639 | 102 \(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
103 \"Artificial Intelligence\", but would replace Ijcai81 with the |
20959 | 104 BibTeX macro \"ijcai7\"." |
105 :type '(repeat (list string string)) | |
106 :group 'refbib) | |
36 | 107 |
20959 | 108 (defcustom r2b-proceedings-list |
109 '() | |
110 "Assoc list of books or journals which are really conference proceedings, | |
243 | 111 but whose name and whose abbrev expansion (as defined in `r2b-journal-abbrevs' |
112 and `r2b-booktitle-abbrevs') does not contain the words \"conference\" or | |
113 \"proceedings\". (Those cases are handled automatically.) | |
36 | 114 The entry must match the given data exactly. |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
115 Because titles are capitalized before matching, the items in this list |
36 | 116 should begin with a capital letter. |
117 For example, suppose the title \"Ijcai81\" is used for the proceedings of | |
16420
35bc9eed0c1f
(r2b-proceedings-list, r2b-help-message): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16284
diff
changeset
|
118 a conference, and its expansion is the BibTeX macro \"ijcai7\". Then |
243 | 119 `r2b-proceedings-list' should be '((\"Ijcai81\") ...). If instead its |
36 | 120 expansion were \"Proceedings of the Seventh International Conference |
243 | 121 on Artificial Intelligence\", then you would NOT need to include Ijcai81 |
20959 | 122 in `r2b-proceedings-list' (although it wouldn't cause an error)." |
123 :type '(repeat (list string string)) | |
124 :group 'refbib) | |
36 | 125 |
126 (defvar r2b-additional-stop-words | |
20959 | 127 "Some\\|What" |
128 "Words not to be used to build the citation key. | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
129 This is in addition to the `r2b-capitalize-title-stop-words'.") |
36 | 130 |
20959 | 131 (defcustom r2b-delimit-with-quote t |
132 "*If true, then use \" to delimit fields, otherwise use braces." | |
133 :type 'boolean | |
134 :group 'refbib) | |
36 | 135 |
136 ;********************************************************** | |
137 ; Utility Functions | |
138 | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
139 (defvar r2b-capitalize-title-stop-words |
36 | 140 (concat |
141 "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|" | |
142 "by\\|with\\|that\\|its") | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
143 "Words not to be capitalized in a title (unless the first word).") |
36 | 144 |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
145 (defvar r2b-capitalize-title-stop-regexp |
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
146 (concat "\\(" r2b-capitalize-title-stop-words "\\)\\(\\b\\|'\\)")) |
36 | 147 |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
148 (defun r2b-capitalize-title-region (begin end) |
243 | 149 "Like `capitalize-region', but don't capitalize stop words, except the first." |
36 | 150 (interactive "r") |
151 (let ((case-fold-search nil) (orig-syntax-table (syntax-table))) | |
152 (unwind-protect | |
153 (save-restriction | |
154 (set-syntax-table text-mode-syntax-table) | |
155 (narrow-to-region begin end) | |
156 (goto-char (point-min)) | |
157 (if (looking-at "[A-Z][a-z]*[A-Z]") | |
158 (forward-word 1) | |
159 (capitalize-word 1)) | |
160 (while (re-search-forward "\\<" nil t) | |
161 (if (looking-at "[A-Z][a-z]*[A-Z]") | |
162 (forward-word 1) | |
163 (if (let ((case-fold-search t)) | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
164 (looking-at r2b-capitalize-title-stop-regexp)) |
36 | 165 (downcase-word 1) |
166 (capitalize-word 1))) | |
167 )) | |
168 (set-syntax-table orig-syntax-table)))) | |
169 | |
170 | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 (defun r2b-capitalize-title (s) |
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
172 "Like `capitalize', but don't capitalize stop words, except the first." |
36 | 173 (save-excursion |
174 (set-buffer (get-buffer-create "$$$Scratch$$$")) | |
175 (erase-buffer) | |
176 (insert s) | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
177 (r2b-capitalize-title-region (point-min) (point-max)) |
36 | 178 (buffer-string))) |
179 | |
180 ;********************************************************* | |
181 (defun r2b-reset () | |
243 | 182 "Unbind defvars, for debugging." |
36 | 183 (interactive) |
184 (makunbound 'r2b-journal-abbrevs) | |
185 (makunbound 'r2b-booktitle-abbrevs) | |
186 (makunbound 'r2b-proceedings-list) | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
187 (makunbound 'r2b-capitalize-title-stop-words) |
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
188 (makunbound 'r2b-capitalize-title-stop-regexp) |
36 | 189 (makunbound 'r2b-additional-stop-words) |
243 | 190 (makunbound 'r2b-stop-regexp)) |
36 | 191 |
192 (defvar r2b-stop-regexp | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
193 (concat "\\`\\(\\(" |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
194 r2b-additional-stop-words "\\|" r2b-capitalize-title-stop-words |
36 | 195 "\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)")) |
196 | |
197 | |
198 (defun r2b-trace (&rest args) | |
199 (if r2b-trace-on | |
200 (progn | |
201 (apply (function message) args) | |
243 | 202 (sit-for 0)))) |
36 | 203 |
204 (defun r2b-match (exp) | |
243 | 205 "Returns string matched in current buffer." |
36 | 206 (buffer-substring (match-beginning exp) (match-end exp))) |
207 | |
20959 | 208 (defcustom r2b-out-buf-name "*Out*" |
209 "*Name of buffer for output from refer-to-bibtex." | |
210 :type 'string | |
211 :group 'refbib) | |
212 | |
213 (defcustom r2b-log-name "*Log*" | |
214 "*Name of buffer for logs errors from refer-to-bibtex." | |
215 :type 'string | |
216 :group 'refbib) | |
217 | |
36 | 218 (defvar r2b-in-buf nil) |
219 (defvar r2b-out-buf nil) | |
220 (defvar r2b-log nil) | |
221 | |
222 (defvar r2b-error-found nil) | |
223 | |
93097 | 224 (defvar r2b-variables) (defvar r2bv-address) (defvar r2bv-annote) |
225 (defvar r2bv-author) (defvar r2bv-booktitle) (defvar r2bv-date) | |
226 (defvar r2bv-decade) (defvar r2bv-editor) (defvar r2bv-entry-kind) | |
227 (defvar r2bv-institution) (defvar r2bv-journal) (defvar r2bv-keywords) | |
228 (defvar r2bv-kn) (defvar r2bv-month) (defvar r2bv-note) | |
229 (defvar r2bv-number) (defvar r2bv-ordering) (defvar r2bv-organization) | |
230 (defvar r2bv-pages) (defvar r2bv-primary-author) (defvar r2bv-publisher) | |
231 (defvar r2bv-school) (defvar r2bv-title) (defvar r2bv-title-first-word) | |
232 (defvar r2bv-tr) (defvar r2bv-type) (defvar r2bv-volume) | |
233 (defvar r2bv-where) (defvar r2bv-year) | |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
234 |
36 | 235 (setq r2b-variables '( |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
236 r2b-error-found |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
237 r2bv-author |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
238 r2bv-primary-author |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
239 r2bv-date |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
240 r2bv-year |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
241 r2bv-decade |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
242 r2bv-month |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
243 r2bv-title |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
244 r2bv-title-first-word |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
245 r2bv-editor |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
246 r2bv-annote |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
247 r2bv-tr |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
248 r2bv-address |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
249 r2bv-institution |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
250 r2bv-keywords |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
251 r2bv-booktitle |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
252 r2bv-journal |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
253 r2bv-volume |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
254 r2bv-number |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
255 r2bv-pages |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
256 r2bv-booktitle |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
257 r2bv-kn |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
258 r2bv-publisher |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
259 r2bv-organization |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
260 r2bv-school |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
261 r2bv-type |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
262 r2bv-where |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
263 r2bv-note |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
264 r2bv-ordering |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
265 )) |
36 | 266 |
267 (defun r2b-clear-variables () | |
243 | 268 "Set all global vars used by r2b to nil." |
36 | 269 (let ((vars r2b-variables)) |
270 (while vars | |
271 (set (car vars) nil) | |
243 | 272 (setq vars (cdr vars))))) |
36 | 273 |
274 (defun r2b-warning (&rest args) | |
275 (setq r2b-error-found t) | |
276 (princ (apply (function format) args) r2b-log) | |
277 (princ "\n" r2b-log) | |
278 (princ "\n" r2b-out-buf) | |
279 (princ "% " r2b-out-buf) | |
243 | 280 (princ (apply (function format) args) r2b-out-buf)) |
36 | 281 |
282 (defun r2b-get-field (var field &optional unique required capitalize) | |
283 "Set VAR to string value of FIELD, if any. If none, VAR is set to | |
284 nil. If multiple fields appear, then separate values with the | |
285 '\\nand\\t\\t', unless UNIQUE is non-nil, in which case log a warning | |
286 and just concatenate the values. Trim off leading blanks and tabs on | |
287 first line, and trailing blanks and tabs of every line. Log a warning | |
288 and set VAR to the empty string if REQUIRED is true. Capitalize as a | |
289 title if CAPITALIZE is true. Returns value of VAR." | |
290 (let (item val (not-past-end t)) | |
291 (r2b-trace "snarfing %s" field) | |
292 (goto-char (point-min)) | |
293 (while (and not-past-end | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
294 (re-search-forward |
36 | 295 (concat "^" field "\\b[ \t]*\\(.*[^ \t\n]\\)[ \t]*") nil t)) |
296 (setq item (r2b-match 1)) | |
297 (while (and (setq not-past-end (zerop (forward-line 1))) | |
298 (not (looking-at "[ \t]*$\\|%"))) | |
299 (looking-at "\\(.*[^ \t\n]\\)[ \t]*$") | |
300 (setq item (concat item "\n" (r2b-match 1))) | |
301 ) | |
302 (if (null val) | |
303 (setq val item) | |
304 (if unique | |
305 (progn | |
60918
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
52401
diff
changeset
|
306 (r2b-warning "*Invalid multiple field %s %s" field item) |
36 | 307 (setq val (concat val "\n" item)) |
308 ) | |
309 (setq val (concat val "\n\t\tand " item)) | |
310 ) | |
311 ) | |
312 ) | |
313 (if (and val capitalize) | |
16284
f4cc8bf7ca84
(r2b-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
314 (setq val (r2b-capitalize-title val))) |
36 | 315 (set var val) |
316 (if (and (null val) required) | |
317 (r2b-require var)) | |
318 )) | |
319 | |
320 (defun r2b-set-match (var n regexp string ) | |
243 | 321 "Set VAR to the Nth subpattern in REGEXP matched by STRING, or nil if none." |
36 | 322 (set var |
323 (if (and (stringp string) (string-match regexp string)) | |
324 (substring string (match-beginning n) (match-end n)) | |
325 nil) | |
326 ) | |
327 ) | |
328 | |
329 (defvar r2b-month-abbrevs | |
330 '(("jan") ("feb") ("mar") ("apr") ("may") ("jun") ("jul") ("aug") | |
331 ("sep") ("oct") ("nov") ("dec"))) | |
332 | |
333 (defun r2b-convert-month () | |
243 | 334 "Try to convert `r2bv-month' to a standard 3 letter name." |
36 | 335 (if r2bv-month |
336 (let ((months r2b-month-abbrevs)) | |
337 (if (string-match "[^0-9]" r2bv-month) | |
338 (progn | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
339 (while (and months (not (string-match (car (car months)) |
36 | 340 r2bv-month))) |
341 (setq months (cdr months))) | |
342 (if months | |
343 (setq r2bv-month (car (car months))))) | |
344 (progn | |
345 (setq months (car (read-from-string r2bv-month))) | |
346 (if (and (numberp months) | |
347 (> months 0) | |
348 (< months 13)) | |
349 (setq r2bv-month (car (nth months r2b-month-abbrevs))) | |
350 (progn | |
351 (r2b-warning "* Ridiculous month") | |
352 (setq r2bv-month nil)) | |
353 )) | |
354 )) | |
355 ) | |
356 ) | |
357 | |
358 (defun r2b-snarf-input () | |
243 | 359 "Parse buffer into global variables." |
36 | 360 (let ((case-fold-search t)) |
361 (r2b-trace "snarfing...") | |
362 (sit-for 0) | |
363 (set-buffer r2b-in-buf) | |
364 (goto-char (point-min)) | |
365 (princ " " r2b-log) | |
366 (princ (buffer-substring (point) (progn (end-of-line) (point))) r2b-log) | |
367 (terpri r2b-log) | |
368 | |
369 (r2b-get-field 'r2bv-author "%A") | |
370 (r2b-get-field 'r2bv-editor "%E") | |
371 (cond | |
372 (r2bv-author | |
373 (r2b-set-match 'r2bv-primary-author 1 | |
374 "\\b\\(\\w+\\)[ \t]*\\($\\|,\\)" r2bv-author) | |
375 ) | |
376 (r2bv-editor | |
377 (r2b-set-match 'r2bv-primary-author 1 | |
378 "\\b\\(\\w+\\)[ \t]*\\($\\|,\\)" r2bv-editor) | |
379 ) | |
380 (t | |
381 (setq r2bv-primary-author "") | |
382 ) | |
383 ) | |
384 | |
385 (r2b-get-field 'r2bv-date "%D" t t) | |
386 (r2b-set-match 'r2bv-year 0 "[12][0-9][0-9][0-9]" r2bv-date) | |
387 (and (null r2bv-year) | |
388 (r2b-set-match 'r2bv-year 1 "[^0-9]\\([0-9][0-9]\\)$" r2bv-date) | |
389 (setq r2bv-year (concat "19" r2bv-year))) | |
390 (r2b-set-match 'r2bv-decade 1 "..\\(..\\)" r2bv-year) | |
391 (r2b-set-match 'r2bv-month 0 | |
392 "[0-9]+/\\|[a-zA-Z]+" r2bv-date) | |
393 (if (and (stringp r2bv-month) (string-match "\\(.*\\)/$" r2bv-month)) | |
394 (setq r2bv-month (substring r2bv-month 0 (match-end 1)))) | |
395 (r2b-convert-month) | |
396 | |
397 (r2b-get-field 'r2bv-title "%T" t t t) | |
398 (r2b-set-match 'r2bv-title-first-word 4 | |
399 r2b-stop-regexp | |
400 r2bv-title) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
401 |
36 | 402 (r2b-get-field 'r2bv-annote "%X" t ) |
403 (r2b-get-field 'r2bv-tr "%R" t) | |
404 (r2b-get-field 'r2bv-address "%C" t) | |
405 (r2b-get-field 'r2bv-institution "%I" t) | |
406 (r2b-get-field 'r2bv-keywords "%K") | |
407 (r2b-get-field 'r2bv-booktitle "%B" t nil t) | |
408 (r2b-get-field 'r2bv-journal "%J" t nil t) | |
409 (r2b-get-field 'r2bv-volume "%V" t) | |
410 (r2b-get-field 'r2bv-number "%N" t) | |
411 (r2b-get-field 'r2bv-pages "%P" t) | |
412 (r2b-get-field 'r2bv-where "%W" t) | |
413 (r2b-get-field 'r2bv-ordering "%O" t) | |
414 ) | |
415 ) | |
416 | |
417 | |
418 (defun r2b-put-field (field data &optional abbrevs) | |
243 | 419 "Print bibtex FIELD = {DATA} if DATA not null; precede |
36 | 420 with a comma and newline; if ABBREVS list is given, then |
243 | 421 try to replace the {DATA} with an abbreviation." |
36 | 422 (if data |
423 (let (match nodelim multi-line index) | |
424 (cond | |
425 ((and abbrevs (setq match (assoc data abbrevs))) | |
426 (if (null (cdr match)) | |
427 (setq data (car match)) | |
428 (setq data (car (cdr match)))) | |
429 (setq nodelim t)) | |
430 ((and (not (equal data "")) | |
431 (not (string-match "[^0-9]" data))) | |
432 (setq nodelim t)) | |
433 (t | |
434 (setq index 0) | |
435 (while (string-match "[\\~^]" data index) | |
436 (setq data (concat (substring data 0 (match-beginning 0)) | |
437 "\\verb+" | |
438 (substring data (match-beginning 0) (match-end 0)) | |
439 "+" | |
440 (substring data (match-end 0)))) | |
441 (setq index (+ (match-end 0) 7))) | |
442 (setq index 0) | |
443 (while (string-match "[$&%#_{}]" data index) | |
444 (setq data (concat (substring data 0 (match-beginning 0)) | |
445 "\\" | |
446 (substring data (match-beginning 0)))) | |
447 (setq index (+ (match-end 0) 1))) | |
448 (setq index 0) | |
449 (if r2b-delimit-with-quote | |
450 (while (string-match "\"" data index) | |
451 (setq data (concat (substring data 0 (match-beginning 0)) | |
452 "{\"}" | |
453 (substring data (match-end 0)))) | |
454 (setq index (+ (match-end 0) 2)))) | |
455 )) | |
456 (princ ", \n ") | |
457 (princ field) | |
458 (princ " =\t") | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
459 (if (not nodelim) |
36 | 460 (if r2b-delimit-with-quote |
461 (princ "\"") | |
462 (princ "{"))) | |
463 (string-match ".*" data) | |
464 (if (> (match-end 0) 59) | |
465 (princ "\n")) | |
466 (princ data) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
467 (if (not nodelim) |
36 | 468 (if r2b-delimit-with-quote |
469 (princ "\"") | |
470 (princ "}"))) | |
471 ) | |
472 )) | |
473 | |
474 | |
475 (defun r2b-require (vars) | |
243 | 476 "If any of VARS is null, set to empty string and log error." |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
477 (cond |
36 | 478 ((null vars)) |
479 ((listp vars) (r2b-require (car vars)) (r2b-require (cdr vars))) | |
480 (t | |
481 (if (null (symbol-value vars)) | |
482 (progn | |
483 (r2b-warning "*Missing value for field %s" vars) | |
484 (set vars "") | |
485 ))) | |
486 ) | |
487 ) | |
488 | |
489 | |
490 (defmacro r2b-moveq (new old) | |
243 | 491 "Set NEW to OLD and set OLD to nil." |
36 | 492 (list 'progn (list 'setq new old) (list 'setq old 'nil))) |
493 | |
494 (defun r2b-isa-proceedings (name) | |
243 | 495 "Return t if NAME is the name of proceedings." |
36 | 496 (and |
497 name | |
498 (or | |
499 (string-match "proceedings\\|conference" name) | |
500 (assoc name r2b-proceedings-list) | |
501 (let ((match (assoc name r2b-booktitle-abbrevs))) | |
502 (and match | |
503 (string-match "proceedings\\|conference" (car (cdr match))))) | |
504 ))) | |
505 | |
506 (defun r2b-isa-university (name) | |
243 | 507 "Return t if NAME is a university or similar organization, |
508 but not a publisher." | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
509 (and |
36 | 510 name |
511 (string-match "university" name) | |
512 (not (string-match "press" name)) | |
513 | |
514 )) | |
515 | |
516 (defun r2b-barf-output () | |
243 | 517 "Generate bibtex based on global variables." |
36 | 518 (let ((standard-output r2b-out-buf) (case-fold-search t) match) |
519 | |
520 (r2b-trace "...barfing") | |
521 (sit-for 0) | |
522 (set-buffer r2b-out-buf) | |
523 | |
524 (setq r2bv-kn (concat r2bv-primary-author r2bv-decade | |
525 r2bv-title-first-word)) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
526 |
36 | 527 (setq r2bv-entry-kind |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
528 (cond |
36 | 529 ((r2b-isa-proceedings r2bv-journal) |
530 (r2b-moveq r2bv-booktitle r2bv-journal) | |
531 (if (r2b-isa-university r2bv-institution) | |
532 (r2b-moveq r2bv-organization r2bv-institution) | |
533 (r2b-moveq r2bv-publisher r2bv-institution)) | |
534 (r2b-moveq r2bv-note r2bv-tr) | |
535 (r2b-require 'r2bv-author) | |
536 'inproceedings) | |
537 ((r2b-isa-proceedings r2bv-booktitle) | |
538 (if (r2b-isa-university r2bv-institution) | |
539 (r2b-moveq r2bv-organization r2bv-institution) | |
540 (r2b-moveq r2bv-publisher r2bv-institution)) | |
541 (r2b-moveq r2bv-note r2bv-tr) | |
542 (r2b-require 'r2bv-author) | |
543 'inproceedings) | |
544 ((and r2bv-tr (string-match "phd" r2bv-tr)) | |
545 (r2b-moveq r2bv-school r2bv-institution) | |
546 (r2b-require 'r2bv-school ) | |
547 (r2b-require 'r2bv-author) | |
548 'phdthesis) | |
549 ((and r2bv-tr (string-match "master" r2bv-tr)) | |
550 (r2b-moveq r2bv-school r2bv-institution) | |
551 (r2b-require 'r2bv-school ) | |
552 (r2b-require 'r2bv-author) | |
553 'mastersthesis) | |
554 ((and r2bv-tr (string-match "draft\\|unpublish" r2bv-tr)) | |
555 (r2b-moveq r2bv-note r2bv-institution) | |
556 (r2b-require 'r2bv-author) | |
557 'unpublished) | |
558 (r2bv-journal | |
559 (r2b-require 'r2bv-author) | |
560 'article) | |
561 (r2bv-booktitle | |
562 (r2b-moveq r2bv-publisher r2bv-institution) | |
563 (r2b-moveq r2bv-note r2bv-tr) | |
564 (r2b-require 'r2bv-publisher) | |
565 (r2b-require 'r2bv-author) | |
566 'incollection) | |
567 ((and r2bv-author | |
568 (null r2bv-editor) | |
569 (string-match "\\`personal communication\\'" r2bv-title)) | |
570 'misc) | |
571 ((r2b-isa-proceedings r2bv-title) | |
572 (if (r2b-isa-university r2bv-institution) | |
573 (r2b-moveq r2bv-organization r2bv-institution) | |
574 (r2b-moveq r2bv-publisher r2bv-institution)) | |
575 (r2b-moveq r2bv-note r2bv-tr) | |
576 'proceedings) | |
577 ((or r2bv-editor | |
578 (and r2bv-author | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
579 (or |
36 | 580 (null r2bv-tr) |
581 (string-match "\\bisbn\\b" r2bv-tr)))) | |
582 (r2b-moveq r2bv-publisher r2bv-institution) | |
583 (r2b-moveq r2bv-note r2bv-tr) | |
584 (r2b-require 'r2bv-publisher) | |
585 (if (null r2bv-editor) | |
586 (r2b-require 'r2bv-author)) | |
587 'book) | |
588 (r2bv-tr | |
589 (r2b-require 'r2bv-institution) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
590 (if (string-match |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
591 "\\`\\(\\(.\\|\n\\)+\\)[ \t\n]+\\([^ \t\n]\\)+\\'" |
36 | 592 r2bv-tr) |
593 (progn | |
594 (setq r2bv-type (substring r2bv-tr 0 (match-end 1))) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
595 (setq r2bv-number (substring r2bv-tr |
36 | 596 (match-beginning 3))) |
597 (setq r2bv-tr nil)) | |
598 (r2b-moveq r2bv-number r2bv-tr)) | |
599 (r2b-require 'r2bv-author) | |
600 'techreport) | |
601 (r2bv-institution | |
602 (r2b-moveq r2bv-organization r2bv-institution) | |
603 'manual) | |
604 (t | |
605 'misc) | |
606 )) | |
607 | |
608 (r2b-require '( r2bv-year)) | |
609 | |
610 (if r2b-error-found | |
611 (princ "\n% Warning -- Errors During Conversion Next Entry\n")) | |
612 | |
613 (princ "\n@") | |
614 (princ r2bv-entry-kind) | |
615 (princ "( ") | |
616 (princ r2bv-kn) | |
617 | |
618 (r2b-put-field "author" r2bv-author ) | |
619 (r2b-put-field "title" r2bv-title r2b-booktitle-abbrevs) | |
620 (r2b-put-field "year" r2bv-year ) | |
621 | |
622 (r2b-put-field "month" r2bv-month r2b-month-abbrevs) | |
623 (r2b-put-field "journal" r2bv-journal r2b-journal-abbrevs) | |
624 (r2b-put-field "volume" r2bv-volume) | |
625 (r2b-put-field "type" r2bv-type) | |
626 (r2b-put-field "number" r2bv-number) | |
627 (r2b-put-field "booktitle" r2bv-booktitle r2b-booktitle-abbrevs) | |
628 (r2b-put-field "editor" r2bv-editor) | |
629 (r2b-put-field "publisher" r2bv-publisher) | |
630 (r2b-put-field "institution" r2bv-institution) | |
631 (r2b-put-field "organization" r2bv-organization) | |
632 (r2b-put-field "school" r2bv-school) | |
633 (r2b-put-field "pages" r2bv-pages) | |
634 (r2b-put-field "address" r2bv-address) | |
635 (r2b-put-field "note" r2bv-note) | |
636 (r2b-put-field "keywords" r2bv-keywords) | |
637 (r2b-put-field "where" r2bv-where) | |
638 (r2b-put-field "ordering" r2bv-ordering) | |
639 (r2b-put-field "annote" r2bv-annote) | |
640 | |
641 (princ " )\n") | |
642 ) | |
643 ) | |
644 | |
645 | |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
646 (defun r2b-convert-record (output) |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
647 "Transform current bib entry and append to buffer OUTPUT. |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
648 Do `\\[r2b-help]' for more info." |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
649 (interactive |
36 | 650 (list (read-string "Output to buffer: " r2b-out-buf-name))) |
651 (let (rec-end rec-begin not-done) | |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
652 (setq r2b-out-buf-name output) |
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
653 (setq r2b-out-buf (get-buffer-create output)) |
36 | 654 (setq r2b-in-buf (current-buffer)) |
655 (set-buffer r2b-out-buf) | |
656 (goto-char (point-max)) | |
657 (setq r2b-log (get-buffer-create r2b-log-name)) | |
658 (set-buffer r2b-log) | |
659 (goto-char (point-max)) | |
660 (set-buffer r2b-in-buf) | |
661 (setq not-done (re-search-forward "[^ \t\n]" nil t)) | |
662 (if not-done | |
663 (progn | |
664 (re-search-backward "^[ \t]*$" nil 2) | |
665 (re-search-forward "^%") | |
666 (beginning-of-line nil) | |
667 (setq rec-begin (point)) | |
668 (re-search-forward "^[ \t]*$" nil 2) | |
669 (setq rec-end (point)) | |
670 (narrow-to-region rec-begin rec-end) | |
671 (r2b-clear-variables) | |
672 (r2b-snarf-input) | |
673 (r2b-barf-output) | |
674 (set-buffer r2b-in-buf) | |
675 (widen) | |
676 (goto-char rec-end) | |
677 t) | |
678 nil | |
679 ) | |
680 )) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
681 |
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
682 |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
683 (defun r2b-convert-buffer (output) |
24811
adcead6b7ce1
Don't print any messages or display
Karl Heuer <kwzh@gnu.org>
parents:
20959
diff
changeset
|
684 "Transform current buffer and append to buffer OUTPUT. |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
685 Do `\\[r2b-help]' for more info." |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
686 (interactive |
36 | 687 (list (read-string "Output to buffer: " r2b-out-buf-name))) |
688 (save-excursion | |
689 (setq r2b-log (get-buffer-create r2b-log-name)) | |
690 (set-buffer r2b-log) | |
691 (erase-buffer)) | |
692 (widen) | |
693 (goto-char (point-min)) | |
694 (message "Working, please be patient...") | |
695 (sit-for 0) | |
64815
d5907fe7fee3
(r2b-convert-record, r2b-convert-buffer): Improve argument/docstring
Juanma Barranquero <lekktu@gmail.com>
parents:
64791
diff
changeset
|
696 (while (r2b-convert-record output) t) |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24811
diff
changeset
|
697 (message "Done, results in %s, errors in %s" |
36 | 698 r2b-out-buf-name r2b-log-name) |
699 ) | |
700 | |
701 (defvar r2b-help-message | |
702 " Refer to Bibtex Bibliography Conversion | |
703 | |
704 A refer-style database is of the form: | |
705 | |
706 %A Joe Blow | |
707 %T Great Thoughts I've Thought | |
708 %D 1977 | |
709 etc. | |
710 | |
711 This utility converts these kind of databases to bibtex form, for | |
712 users of TeX and LaTex. Instructions: | |
713 1. Visit the file containing the refer-style database. | |
714 2. The command | |
715 M-x r2b-convert-buffer | |
16420
35bc9eed0c1f
(r2b-proceedings-list, r2b-help-message): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
16284
diff
changeset
|
716 converts the entire buffer, appending its output by default in a |
36 | 717 buffer named *Out*, and logging progress and errors in a buffer |
718 named *Log*. The original file is never modified. | |
719 Note that results are appended to *Out*, so if that buffer | |
720 buffer already exists and contains material you don't want to | |
721 save, you should kill it first. | |
722 3. Switch to the buffer *Out* and save it as a named file. | |
723 4. To convert a single refer-style entry, simply position the cursor | |
724 at the entry and enter | |
725 M-x r2b-convert-record | |
726 Again output is appended to *Out* and errors are logged in *Log*. | |
727 | |
728 This utility is very robust and pretty smart about determining the | |
729 type of the entry. It includes facilities for expanding refer macros | |
730 to text, or substituting bibtex macros. Do M-x describe-variable on | |
731 r2b-journal-abbrevs | |
732 r2b-booktitle-abbrevs | |
733 r2b-proceedings-list | |
734 for information on these features. | |
735 | |
829
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
736 Please send bug reports and suggestions to |
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
737 Henry Kautz |
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
738 kautz@research.att.com |
f6f8f3eae92f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
739 allegra!kautz") |
36 | 740 |
741 | |
742 (defun r2b-help () | |
24811
adcead6b7ce1
Don't print any messages or display
Karl Heuer <kwzh@gnu.org>
parents:
20959
diff
changeset
|
743 "Print help describing the `refbib' package." |
36 | 744 (interactive) |
745 (with-output-to-temp-buffer "*Help*" | |
9848
1365bc291f4c
(r2b-help): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
7639
diff
changeset
|
746 (princ r2b-help-message) |
1365bc291f4c
(r2b-help): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
7639
diff
changeset
|
747 (save-excursion |
1365bc291f4c
(r2b-help): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
7639
diff
changeset
|
748 (set-buffer standard-output) |
1365bc291f4c
(r2b-help): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
7639
diff
changeset
|
749 (help-mode)))) |
36 | 750 |
24811
adcead6b7ce1
Don't print any messages or display
Karl Heuer <kwzh@gnu.org>
parents:
20959
diff
changeset
|
751 (provide 'refbib) |
584 | 752 (provide 'refer-to-bibtex) |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
753 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93097
diff
changeset
|
754 ;; arch-tag: 664afee2-6e76-4408-ba56-981d8a179586 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
755 ;;; refbib.el ends here |