Mercurial > emacs
comparison lisp/textmodes/bibtex.el @ 90813:e6fdae9180d4
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 698-710)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 216)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-196
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 24 Apr 2007 21:56:25 +0000 |
parents | 95d0cdf160ea 372e6a7ea660 |
children | 988f1edc9674 |
comparison
equal
deleted
inserted
replaced
90812:6137cc8ddf90 | 90813:e6fdae9180d4 |
---|---|
84 If this is a string, use it as the initial field text. | 84 If this is a string, use it as the initial field text. |
85 If this is a function, call it to generate the initial field text." | 85 If this is a function, call it to generate the initial field text." |
86 :group 'bibtex | 86 :group 'bibtex |
87 :type '(choice (const :tag "None" nil) | 87 :type '(choice (const :tag "None" nil) |
88 (string :tag "Initial text") | 88 (string :tag "Initial text") |
89 (function :tag "Initialize Function" :value fun) | 89 (function :tag "Initialize Function") |
90 (const :tag "Default" t))) | 90 (const :tag "Default" t))) |
91 (put 'bibtex-include-OPTkey 'risky-local-variable t) | 91 (put 'bibtex-include-OPTkey 'risky-local-variable t) |
92 | 92 |
93 (defcustom bibtex-user-optional-fields | 93 (defcustom bibtex-user-optional-fields |
94 '(("annote" "Personal annotation (ignored)")) | 94 '(("annote" "Personal annotation (ignored)")) |
96 Entries should be of the same form as the OPTIONAL and | 96 Entries should be of the same form as the OPTIONAL and |
97 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)." | 97 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)." |
98 :group 'bibtex | 98 :group 'bibtex |
99 :type '(repeat (group (string :tag "Field") | 99 :type '(repeat (group (string :tag "Field") |
100 (string :tag "Comment") | 100 (string :tag "Comment") |
101 (option (group :inline t | 101 (option (choice :tag "Init" |
102 :extra-offset -4 | 102 (const nil) string function))))) |
103 (choice :tag "Init" :value "" | |
104 string | |
105 function)))))) | |
106 (put 'bibtex-user-optional-fields 'risky-local-variable t) | 103 (put 'bibtex-user-optional-fields 'risky-local-variable t) |
107 | 104 |
108 (defcustom bibtex-entry-format | 105 (defcustom bibtex-entry-format |
109 '(opts-or-alts required-fields numerical-fields) | 106 '(opts-or-alts required-fields numerical-fields) |
110 "Type of formatting performed by `bibtex-clean-entry'. | 107 "Type of formatting performed by `bibtex-clean-entry'. |
222 "If non-nil, use fast but simplified algorithm for parsing BibTeX keys. | 219 "If non-nil, use fast but simplified algorithm for parsing BibTeX keys. |
223 If parsing fails, try to set this variable to nil." | 220 If parsing fails, try to set this variable to nil." |
224 :group 'bibtex | 221 :group 'bibtex |
225 :type 'boolean) | 222 :type 'boolean) |
226 | 223 |
227 (defvar bibtex-entry-field-alist | 224 (defcustom bibtex-entry-field-alist |
228 '(("Article" | 225 '(("Article" |
229 ((("author" "Author1 [and Author2 ...] [and others]") | 226 ((("author" "Author1 [and Author2 ...] [and others]") |
230 ("title" "Title of the article (BibTeX converts it to lowercase)") | 227 ("title" "Title of the article (BibTeX converts it to lowercase)") |
231 ("journal" "Name of the journal (use string, remove braces)") | 228 ("journal" "Name of the journal (use string, remove braces)") |
232 ("year" "Year of publication")) | 229 ("year" "Year of publication")) |
450 FIELD-NAME is the name of the field, COMMENT-STRING is the comment that | 447 FIELD-NAME is the name of the field, COMMENT-STRING is the comment that |
451 appears in the echo area, INIT is either the initial content of the | 448 appears in the echo area, INIT is either the initial content of the |
452 field or a function, which is called to determine the initial content | 449 field or a function, which is called to determine the initial content |
453 of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the | 450 of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the |
454 field is an alternative. ALTERNATIVE-FLAG may be t only in the | 451 field is an alternative. ALTERNATIVE-FLAG may be t only in the |
455 REQUIRED or CROSSREF-REQUIRED lists.") | 452 REQUIRED or CROSSREF-REQUIRED lists." |
453 :group 'bibtex | |
454 :type '(repeat (group (string :tag "Entry name") | |
455 (group (repeat :tag "Required fields" | |
456 (group (string :tag "Field") | |
457 (string :tag "Comment") | |
458 (option (choice :tag "Init" :value nil | |
459 (const nil) string function)) | |
460 (option (choice :tag "Alternative" | |
461 (const :tag "No" nil) | |
462 (const :tag "Yes" t))))) | |
463 (repeat :tag "Optional fields" | |
464 (group (string :tag "Field") | |
465 (string :tag "Comment") | |
466 (option (choice :tag "Init" :value nil | |
467 (const nil) string function))))) | |
468 (option :extra-offset -4 | |
469 (group (repeat :tag "Crossref: required fields" | |
470 (group (string :tag "Field") | |
471 (string :tag "Comment") | |
472 (option (choice :tag "Init" :value nil | |
473 (const nil) string function)) | |
474 (option (choice :tag "Alternative" | |
475 (const :tag "No" nil) | |
476 (const :tag "Yes" t))))) | |
477 (repeat :tag "Crossref: optional fields" | |
478 (group (string :tag "Field") | |
479 (string :tag "Comment") | |
480 (option (choice :tag "Init" :value nil | |
481 (const nil) string function))))))))) | |
456 (put 'bibtex-entry-field-alist 'risky-local-variable t) | 482 (put 'bibtex-entry-field-alist 'risky-local-variable t) |
457 | 483 |
458 (defcustom bibtex-comment-start "@Comment" | 484 (defcustom bibtex-comment-start "@Comment" |
459 "String starting a BibTeX comment." | 485 "String starting a BibTeX comment." |
460 :group 'bibtex | 486 :group 'bibtex |
1783 ;; insert past the current field | 1809 ;; insert past the current field |
1784 (goto-char (bibtex-end-of-field (bibtex-enclosing-field comma))) | 1810 (goto-char (bibtex-end-of-field (bibtex-enclosing-field comma))) |
1785 (set-mark (point)) | 1811 (set-mark (point)) |
1786 (message "Mark set") | 1812 (message "Mark set") |
1787 (bibtex-make-field (funcall fun 'bibtex-field-kill-ring-yank-pointer | 1813 (bibtex-make-field (funcall fun 'bibtex-field-kill-ring-yank-pointer |
1788 bibtex-field-kill-ring) t)) | 1814 bibtex-field-kill-ring) t nil t)) |
1789 ;; insert past the current entry | 1815 ;; insert past the current entry |
1790 (bibtex-skip-to-valid-entry) | 1816 (bibtex-skip-to-valid-entry) |
1791 (set-mark (point)) | 1817 (set-mark (point)) |
1792 (message "Mark set") | 1818 (message "Mark set") |
1793 (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer | 1819 (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer |
2829 optional (nth 1 (nth 1 e)))) | 2855 optional (nth 1 (nth 1 e)))) |
2830 (if bibtex-include-OPTkey | 2856 (if bibtex-include-OPTkey |
2831 (push (list "key" | 2857 (push (list "key" |
2832 "Used for reference key creation if author and editor fields are missing" | 2858 "Used for reference key creation if author and editor fields are missing" |
2833 (if (or (stringp bibtex-include-OPTkey) | 2859 (if (or (stringp bibtex-include-OPTkey) |
2834 (fboundp bibtex-include-OPTkey)) | 2860 (functionp bibtex-include-OPTkey)) |
2835 bibtex-include-OPTkey)) | 2861 bibtex-include-OPTkey)) |
2836 optional)) | 2862 optional)) |
2837 (if (member-ignore-case entry-type bibtex-include-OPTcrossref) | 2863 (if (member-ignore-case entry-type bibtex-include-OPTcrossref) |
2838 (push '("crossref" "Reference key of the cross-referenced entry") | 2864 (push '("crossref" "Reference key of the cross-referenced entry") |
2839 optional)) | 2865 optional)) |
3018 (comment (assoc-string field (append (car field-list) | 3044 (comment (assoc-string field (append (car field-list) |
3019 (cdr field-list)) t))) | 3045 (cdr field-list)) t))) |
3020 (if comment (message "%s" (nth 1 comment)) | 3046 (if comment (message "%s" (nth 1 comment)) |
3021 (message "No comment available"))))) | 3047 (message "No comment available"))))) |
3022 | 3048 |
3023 (defun bibtex-make-field (field &optional move interactive) | 3049 (defun bibtex-make-field (field &optional move interactive nodelim) |
3024 "Make a field named FIELD in current BibTeX entry. | 3050 "Make a field named FIELD in current BibTeX entry. |
3025 FIELD is either a string or a list of the form | 3051 FIELD is either a string or a list of the form |
3026 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in | 3052 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in |
3027 `bibtex-entry-field-alist'. | 3053 `bibtex-entry-field-alist'. |
3028 If MOVE is non-nil, move point past the present field before making | 3054 If MOVE is non-nil, move point past the present field before making |
3029 the new field. If INTERACTIVE is non-nil, move point to the end of | 3055 the new field. If INTERACTIVE is non-nil, move point to the end of |
3030 the new field. Otherwise move point past the new field. | 3056 the new field. Otherwise move point past the new field. |
3031 MOVE and INTERACTIVE are t when called interactively." | 3057 MOVE and INTERACTIVE are t when called interactively. |
3058 INIT is surrounded by field delimiters, unless NODELIM is non-nil." | |
3032 (interactive | 3059 (interactive |
3033 (list (let ((completion-ignore-case t) | 3060 (list (let ((completion-ignore-case t) |
3034 (field-list (bibtex-field-list | 3061 (field-list (bibtex-field-list |
3035 (save-excursion | 3062 (save-excursion |
3036 (bibtex-beginning-of-entry) | 3063 (bibtex-beginning-of-entry) |
3056 (insert "= ") | 3083 (insert "= ") |
3057 (unless bibtex-align-at-equal-sign | 3084 (unless bibtex-align-at-equal-sign |
3058 (indent-to-column (+ bibtex-entry-offset | 3085 (indent-to-column (+ bibtex-entry-offset |
3059 bibtex-text-indentation))) | 3086 bibtex-text-indentation))) |
3060 (let ((init (nth 2 field))) | 3087 (let ((init (nth 2 field))) |
3061 (insert (cond ((stringp init) init) | 3088 (if (not init) (setq init "") |
3062 ((fboundp init) (funcall init)) | 3089 (if (functionp init) (setq init (funcall init))) |
3063 (t (concat (bibtex-field-left-delimiter) | 3090 (unless (stringp init) (error "`%s' is not a string" init))) |
3064 (bibtex-field-right-delimiter)))))) | 3091 ;; NODELIM is required by `bibtex-insert-kill' |
3092 (if nodelim (insert init) | |
3093 (insert (bibtex-field-left-delimiter) init | |
3094 (bibtex-field-right-delimiter)))) | |
3065 (when interactive | 3095 (when interactive |
3066 ;; (bibtex-find-text nil nil bibtex-help-message) | 3096 ;; (bibtex-find-text nil nil bibtex-help-message) |
3067 (if (memq (preceding-char) '(?} ?\")) (forward-char -1)) | 3097 (if (memq (preceding-char) '(?} ?\")) (forward-char -1)) |
3068 (if bibtex-help-message (bibtex-print-help-message (car field))))) | 3098 (if bibtex-help-message (bibtex-print-help-message (car field))))) |
3069 | 3099 |