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