35 |
;; 9/88, created H.Kautz |
;; 9/88, created H.Kautz |
36 |
;; modified 1/19/89, allow books with editor but no author; |
;; modified 1/19/89, allow books with editor but no author; |
37 |
;; added %O ordering field; |
;; added %O ordering field; |
38 |
;; appended illegal multiple fields, instead of |
;; appended illegal multiple fields, instead of |
39 |
;; discarding; |
;; discarding; |
40 |
;; added rule, a tech report whose %R number |
;; added rule, a tech report whose %R number |
41 |
;; contains "ISBN" is really a book |
;; contains "ISBN" is really a book |
70 |
:group 'refbib) |
:group 'refbib) |
71 |
|
|
72 |
(defcustom r2b-journal-abbrevs |
(defcustom r2b-journal-abbrevs |
73 |
'( |
'( |
74 |
) |
) |
75 |
"Abbreviation list for journal names. |
"Abbreviation list for journal names. |
76 |
If the car of an element matches a journal name exactly, it is replaced by |
If the car of an element matches a journal name exactly, it is replaced by |
77 |
the cadr when output. Braces must be included if replacement is a |
the cadr when output. Braces must be included if replacement is a |
78 |
{string}, but not if replacement is a bibtex abbreviation. The cadr |
{string}, but not if replacement is a bibtex abbreviation. The cadr |
79 |
may be eliminated if is exactly the same as the car. |
may be eliminated if is exactly the same as the car. |
80 |
Because titles are capitalized before matching, the abbreviation |
Because titles are capitalized before matching, the abbreviation |
81 |
for the journal name should be listed as beginning with a capital |
for the journal name should be listed as beginning with a capital |
82 |
letter, even if it really doesn't. |
letter, even if it really doesn't. |
83 |
For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") |
For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") |
84 |
\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
85 |
\"Artificial Intelligence\", but would replace Ijcai81 with the |
\"Artificial Intelligence\", but would replace Ijcai81 with the |
86 |
BibTeX macro \"ijcai7\"." |
BibTeX macro \"ijcai7\"." |
87 |
:type '(repeat (list string string)) |
:type '(repeat (list string string)) |
88 |
:group 'refbib) |
:group 'refbib) |
89 |
|
|
90 |
(defcustom r2b-booktitle-abbrevs |
(defcustom r2b-booktitle-abbrevs |
91 |
'( |
'( |
92 |
) |
) |
93 |
"Abbreviation list for book and proceedings names. |
"Abbreviation list for book and proceedings names. |
94 |
If the car of an element matches a title or booktitle exactly, it is |
If the car of an element matches a title or booktitle exactly, it is |
100 |
should be listed as beginning with a capital letter, even if it doesn't. |
should be listed as beginning with a capital letter, even if it doesn't. |
101 |
For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") |
For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") |
102 |
\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string |
103 |
\"Artificial Intelligence\", but would replace Ijcai81 with the |
\"Artificial Intelligence\", but would replace Ijcai81 with the |
104 |
BibTeX macro \"ijcai7\"." |
BibTeX macro \"ijcai7\"." |
105 |
:type '(repeat (list string string)) |
:type '(repeat (list string string)) |
106 |
:group 'refbib) |
:group 'refbib) |
112 |
and `r2b-booktitle-abbrevs') does not contain the words \"conference\" or |
and `r2b-booktitle-abbrevs') does not contain the words \"conference\" or |
113 |
\"proceedings\". (Those cases are handled automatically.) |
\"proceedings\". (Those cases are handled automatically.) |
114 |
The entry must match the given data exactly. |
The entry must match the given data exactly. |
115 |
Because titles are capitalized before matching, the items in this list |
Because titles are capitalized before matching, the items in this list |
116 |
should begin with a capital letter. |
should begin with a capital letter. |
117 |
For example, suppose the title \"Ijcai81\" is used for the proceedings of |
For example, suppose the title \"Ijcai81\" is used for the proceedings of |
118 |
a conference, and its expansion is the BibTeX macro \"ijcai7\". Then |
a conference, and its expansion is the BibTeX macro \"ijcai7\". Then |
190 |
(makunbound 'r2b-stop-regexp)) |
(makunbound 'r2b-stop-regexp)) |
191 |
|
|
192 |
(defvar r2b-stop-regexp |
(defvar r2b-stop-regexp |
193 |
(concat "\\`\\(\\(" |
(concat "\\`\\(\\(" |
194 |
r2b-additional-stop-words "\\|" r2b-capitalize-title-stop-words |
r2b-additional-stop-words "\\|" r2b-capitalize-title-stop-words |
195 |
"\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)")) |
"\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)")) |
196 |
|
|
280 |
(r2b-trace "snarfing %s" field) |
(r2b-trace "snarfing %s" field) |
281 |
(goto-char (point-min)) |
(goto-char (point-min)) |
282 |
(while (and not-past-end |
(while (and not-past-end |
283 |
(re-search-forward |
(re-search-forward |
284 |
(concat "^" field "\\b[ \t]*\\(.*[^ \t\n]\\)[ \t]*") nil t)) |
(concat "^" field "\\b[ \t]*\\(.*[^ \t\n]\\)[ \t]*") nil t)) |
285 |
(setq item (r2b-match 1)) |
(setq item (r2b-match 1)) |
286 |
(while (and (setq not-past-end (zerop (forward-line 1))) |
(while (and (setq not-past-end (zerop (forward-line 1))) |
325 |
(let ((months r2b-month-abbrevs)) |
(let ((months r2b-month-abbrevs)) |
326 |
(if (string-match "[^0-9]" r2bv-month) |
(if (string-match "[^0-9]" r2bv-month) |
327 |
(progn |
(progn |
328 |
(while (and months (not (string-match (car (car months)) |
(while (and months (not (string-match (car (car months)) |
329 |
r2bv-month))) |
r2bv-month))) |
330 |
(setq months (cdr months))) |
(setq months (cdr months))) |
331 |
(if months |
(if months |
387 |
(r2b-set-match 'r2bv-title-first-word 4 |
(r2b-set-match 'r2bv-title-first-word 4 |
388 |
r2b-stop-regexp |
r2b-stop-regexp |
389 |
r2bv-title) |
r2bv-title) |
390 |
|
|
391 |
(r2b-get-field 'r2bv-annote "%X" t ) |
(r2b-get-field 'r2bv-annote "%X" t ) |
392 |
(r2b-get-field 'r2bv-tr "%R" t) |
(r2b-get-field 'r2bv-tr "%R" t) |
393 |
(r2b-get-field 'r2bv-address "%C" t) |
(r2b-get-field 'r2bv-address "%C" t) |
445 |
(princ ", \n ") |
(princ ", \n ") |
446 |
(princ field) |
(princ field) |
447 |
(princ " =\t") |
(princ " =\t") |
448 |
(if (not nodelim) |
(if (not nodelim) |
449 |
(if r2b-delimit-with-quote |
(if r2b-delimit-with-quote |
450 |
(princ "\"") |
(princ "\"") |
451 |
(princ "{"))) |
(princ "{"))) |
453 |
(if (> (match-end 0) 59) |
(if (> (match-end 0) 59) |
454 |
(princ "\n")) |
(princ "\n")) |
455 |
(princ data) |
(princ data) |
456 |
(if (not nodelim) |
(if (not nodelim) |
457 |
(if r2b-delimit-with-quote |
(if r2b-delimit-with-quote |
458 |
(princ "\"") |
(princ "\"") |
459 |
(princ "}"))) |
(princ "}"))) |
463 |
|
|
464 |
(defun r2b-require (vars) |
(defun r2b-require (vars) |
465 |
"If any of VARS is null, set to empty string and log error." |
"If any of VARS is null, set to empty string and log error." |
466 |
(cond |
(cond |
467 |
((null vars)) |
((null vars)) |
468 |
((listp vars) (r2b-require (car vars)) (r2b-require (cdr vars))) |
((listp vars) (r2b-require (car vars)) (r2b-require (cdr vars))) |
469 |
(t |
(t |
495 |
(defun r2b-isa-university (name) |
(defun r2b-isa-university (name) |
496 |
"Return t if NAME is a university or similar organization, |
"Return t if NAME is a university or similar organization, |
497 |
but not a publisher." |
but not a publisher." |
498 |
(and |
(and |
499 |
name |
name |
500 |
(string-match "university" name) |
(string-match "university" name) |
501 |
(not (string-match "press" name)) |
(not (string-match "press" name)) |
512 |
|
|
513 |
(setq r2bv-kn (concat r2bv-primary-author r2bv-decade |
(setq r2bv-kn (concat r2bv-primary-author r2bv-decade |
514 |
r2bv-title-first-word)) |
r2bv-title-first-word)) |
515 |
|
|
516 |
(setq r2bv-entry-kind |
(setq r2bv-entry-kind |
517 |
(cond |
(cond |
518 |
((r2b-isa-proceedings r2bv-journal) |
((r2b-isa-proceedings r2bv-journal) |
519 |
(r2b-moveq r2bv-booktitle r2bv-journal) |
(r2b-moveq r2bv-booktitle r2bv-journal) |
520 |
(if (r2b-isa-university r2bv-institution) |
(if (r2b-isa-university r2bv-institution) |
565 |
'proceedings) |
'proceedings) |
566 |
((or r2bv-editor |
((or r2bv-editor |
567 |
(and r2bv-author |
(and r2bv-author |
568 |
(or |
(or |
569 |
(null r2bv-tr) |
(null r2bv-tr) |
570 |
(string-match "\\bisbn\\b" r2bv-tr)))) |
(string-match "\\bisbn\\b" r2bv-tr)))) |
571 |
(r2b-moveq r2bv-publisher r2bv-institution) |
(r2b-moveq r2bv-publisher r2bv-institution) |
576 |
'book) |
'book) |
577 |
(r2bv-tr |
(r2bv-tr |
578 |
(r2b-require 'r2bv-institution) |
(r2b-require 'r2bv-institution) |
579 |
(if (string-match |
(if (string-match |
580 |
"\\`\\(\\(.\\|\n\\)+\\)[ \t\n]+\\([^ \t\n]\\)+\\'" |
"\\`\\(\\(.\\|\n\\)+\\)[ \t\n]+\\([^ \t\n]\\)+\\'" |
581 |
r2bv-tr) |
r2bv-tr) |
582 |
(progn |
(progn |
583 |
(setq r2bv-type (substring r2bv-tr 0 (match-end 1))) |
(setq r2bv-type (substring r2bv-tr 0 (match-end 1))) |
584 |
(setq r2bv-number (substring r2bv-tr |
(setq r2bv-number (substring r2bv-tr |
585 |
(match-beginning 3))) |
(match-beginning 3))) |
586 |
(setq r2bv-tr nil)) |
(setq r2bv-tr nil)) |
587 |
(r2b-moveq r2bv-number r2bv-tr)) |
(r2b-moveq r2bv-number r2bv-tr)) |
635 |
(defun r2b-convert-record (output-name) |
(defun r2b-convert-record (output-name) |
636 |
"Transform current bib entry and append to buffer OUTPUT; |
"Transform current bib entry and append to buffer OUTPUT; |
637 |
do \"M-x r2b-help\" for more info." |
do \"M-x r2b-help\" for more info." |
638 |
(interactive |
(interactive |
639 |
(list (read-string "Output to buffer: " r2b-out-buf-name))) |
(list (read-string "Output to buffer: " r2b-out-buf-name))) |
640 |
(let (rec-end rec-begin not-done) |
(let (rec-end rec-begin not-done) |
641 |
(setq r2b-out-buf-name output-name) |
(setq r2b-out-buf-name output-name) |
667 |
nil |
nil |
668 |
) |
) |
669 |
)) |
)) |
670 |
|
|
671 |
|
|
672 |
(defun r2b-convert-buffer (output-name) |
(defun r2b-convert-buffer (output-name) |
673 |
"Transform current buffer and append to buffer OUTPUT. |
"Transform current buffer and append to buffer OUTPUT. |
674 |
Do `M-x r2b-help' for more info." |
Do `M-x r2b-help' for more info." |
675 |
(interactive |
(interactive |
676 |
(list (read-string "Output to buffer: " r2b-out-buf-name))) |
(list (read-string "Output to buffer: " r2b-out-buf-name))) |
677 |
(save-excursion |
(save-excursion |
678 |
(setq r2b-log (get-buffer-create r2b-log-name)) |
(setq r2b-log (get-buffer-create r2b-log-name)) |
683 |
(message "Working, please be patient...") |
(message "Working, please be patient...") |
684 |
(sit-for 0) |
(sit-for 0) |
685 |
(while (r2b-convert-record output-name) t) |
(while (r2b-convert-record output-name) t) |
686 |
(message "Done, results in %s, errors in %s" |
(message "Done, results in %s, errors in %s" |
687 |
r2b-out-buf-name r2b-log-name) |
r2b-out-buf-name r2b-log-name) |
688 |
) |
) |
689 |
|
|