annotate lisp/textmodes/refbib.el @ 112441:2097405cdc11

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