(defcustom bibtex-entry-format '(opts-or-alts numerical-fields)
"*Controls type of formatting performed by `bibtex-clean-entry'.
-It may be t, nil, or a list of symbols out of the following:
+It may be t, nil, or a list of symbols out of the following:
opts-or-alts Delete empty optional and alternative fields and
remove OPT and ALT prefixes from used fields.
numerical-fields Delete delimiters around numeral fields.
correctly sorted.
realign Realign entries, so that field texts and perhaps equal
signs (depending on the value of
- bibtex-align-at-equal-sign) begin in the same column.
+ `bibtex-align-at-equal-sign') begin in the same column.
last-comma Add or delete comma on end of last field in entry,
according to value of `bibtex-comma-after-last-field'.
delimiters Change delimiters according to variables
(defcustom bibtex-sort-ignore-string-entries t
"*If non-nil, BibTeX @String entries are not sort-significant.
That means they are ignored when determining ordering of the buffer
-(e.g. sorting, locating alphabetical position for new entries, etc.).
+(e.g., sorting, locating alphabetical position for new entries, etc.).
This variable is buffer-local."
:group 'bibtex
:type 'boolean)
(defcustom bibtex-maintain-sorted-entries nil
"*If non-nil, BibTeX mode maintains all BibTeX entries in sorted order.
-Setting this variable to nil will strip off some comfort (e.g. TAB
+Setting this variable to nil will strip off some comfort (e.g., TAB
completion for reference keys in minibuffer, automatic detection of
duplicates) from BibTeX mode. See also `bibtex-sort-ignore-string-entries'.
This variable is buffer-local."
(defcustom bibtex-parse-keys-timeout 60
"*Specifies interval for parsing buffers.
-All BibTeX buffers in emacs are parsed if emacs has been idle
+All BibTeX buffers in Emacs are parsed if Emacs has been idle
`bibtex-parse-keys-timeout' seconds. Only buffers which were modified
after last parsing and which are maintained in sorted order are parsed."
:group 'bibtex
((("author" "Author1 [and Author2 ...] [and others]")
("title" "Title of the article (BibTeX converts it to lowercase)"))
(("pages" "Pages in the journal")
- ("journal" "Name of the journal (use string, remove braces)")
+ ("journal" "Name of the journal (use string, remove braces)")
("year" "Year of publication")
("volume" "Volume of the journal")
("number" "Number of the journal")
If the third element is nil, the first pair is always used.
If not, the second pair is used in the case of presence of a crossref
field and the third in the case of absence.
-REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists.
+REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists.
Each element of these lists is a list of the form
(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG).
COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional.
"*List of BibTeX files containing string definitions.
Those files must be specified using pathnames relative to the
directories specified in `bibtex-string-file-path'. This variable is only
-evaluated when BibTeX mode is entered (i. e. when loading the BibTeX
+evaluated when BibTeX mode is entered (i.e., when loading the BibTeX
file)."
:group 'bibtex
:type '(repeat file))
"Function to call before the generated key is presented.
If non-nil this should be a single function, which is called before
the generated key is presented (in entry or, if
-`bibtex-autokey-edit-before-use' is t, in minibuffer). This function
+`bibtex-autokey-edit-before-use' is t, in minibuffer). This function
must take one argument (the automatically generated key), and must
return with a string (the key to use)."
:group 'bibtex-autokey
(concat
"{"
"\\("
- bibtex-field-string-part-not-braced
+ bibtex-field-string-part-not-braced
"\\|"
"\\(" bibtex-field-string-part-no-inner-braces "\\)"
"\\)*"
"\\("
"[^\"\\]" ;; every character except quote or backslash
"\\|"
-;; "\\(" "\"[a-z-]" "\\)" ;; a quote followed by a letter or dash
+;; "\\(" "\"[a-z-]" "\\)" ;; a quote followed by a letter or dash
;; "\\|"
;; last two lines commented out until lines like
;; author = "Stefan Sch"of"
(list bibtex-type-in-head 'font-lock-function-name-face)
(list bibtex-key-in-head 'font-lock-constant-face nil t))
;; comments
- (list
+ (list
(concat "^\\([ \t]*" bibtex-comment-start ".*\\)$")
1 'font-lock-comment-face)
;; optional field names (treated as comments)
(goto-char (match-beginning 0))
(if (equal noerror nil)
;; yell
- (error "Search of BibTeX reference failed."))
+ (error "Search of BibTeX reference failed"))
(if (equal noerror t)
;; don't move
(goto-char pnt))
(point))
(if (equal noerror nil)
;; yell
- (error "Search of BibTeX reference failed."))
+ (error "Search of BibTeX reference failed"))
(if (equal noerror t)
;; don't move
(goto-char pnt))
(defun bibtex-move-outside-of-entry ()
;; Make sure we are outside of a BibTeX entry.
+ (let ((orig-point (point)))
(bibtex-end-of-entry)
- (skip-chars-forward " \t\n"))
+ (if (< (point) orig-point)
+ ;; We moved backward, so we weren't inside an entry to begin with.
+ ;; Leave point at the beginning of a line, and preferably
+ ;; at the beginning of a paragraph.
+ (progn
+ (goto-char orig-point)
+ (beginning-of-line 1)
+ (if (not (= ?\n (char-before (1- (point)))))
+ (progn
+ (re-search-forward "^[ \t]*[@\n]" nil 'move)
+ (backward-char 1)))))
+ (skip-chars-forward " \t\n")))
(defun bibtex-beginning-of-first-entry ()
;; Go to the beginning of the first BibTeX entry in buffer. Return
(goto-char old-point)
(if noerr
(setq success nil)
- (error "Can't find enclosing BibTeX field.")))
+ (error "Can't find enclosing BibTeX field")))
(if (or (not (re-search-forward bibtex-field nil t))
(< (match-end 0) old-point)
(> (match-beginning 0) old-point))
(goto-char old-point)
(if noerr
(setq success nil)
- (error "Can't find enclosing BibTeX field.")))))
+ (error "Can't find enclosing BibTeX field")))))
success))
(defun bibtex-enclosing-reference-maybe-empty-head ()
(re-search-backward
bibtex-reference-maybe-empty-head nil t))
(progn
- (error "Can't find enclosing BibTeX reference.")
+ (error "Can't find enclosing BibTeX reference")
(goto-char old-point)))
(goto-char (match-beginning bibtex-type-in-head))
(if (not
(bibtex-search-reference t nil t))
(progn
- (error "Can't find enclosing BibTeX reference.")
+ (error "Can't find enclosing BibTeX reference")
(goto-char old-point)))))
(defun bibtex-insert-current-kill (n)
(if (not bibtex-last-kill-command)
- (error "BibTeX kill ring is empty.")
+ (error "BibTeX kill ring is empty")
(let* ((kr (if (equal bibtex-last-kill-command 'field)
'bibtex-field-kill-ring
'bibtex-entry-kill-ring))
(insert (elt current 1)))
(t
(error
- "Unknown tag field: %s. Please submit a bug report."
+ "Unknown tag field: %s. Please submit a bug report"
bibtex-last-kill-command))))))
(defun bibtex-format-entry ()
non-empty-alternative)
(let ((end (copy-marker (bibtex-end-of-entry))))
(if (equal start (marker-position end))
- (error "Not on a known BibTeX entry.")
+ (error "Not on a known BibTeX entry")
(goto-char start)
(while (re-search-forward bibtex-field end t)
;; determine if reference has crossref entry and if at least
(not non-empty-alternative))
(progn
(goto-char beg)
- (error "All alternatives are empty.")))
+ (error "All alternatives are empty")))
(goto-char start)
(re-search-forward bibtex-reference-type end)
(let* ((begin-type (1+ (match-beginning 0)))
(goto-char begin-name)
(bibtex-remove-OPT-or-ALT)
(error
- "Mandatory field ``%s'' is empty." field-name))
+ "Mandatory field ``%s'' is empty" field-name))
;; field is optional
(delete-region begin-field end-field))
;; otherwise: not empty, delete "OPT"
(goto-char begin-text)
(forward-char)
(insert
- (buffer-substring-no-properties
+ (buffer-substring-no-properties
(1+ (match-beginning bibtex-text-in-field))
(1- (match-end bibtex-text-in-field))))))))
(if (progn
(assoc-ignore-case
field-name req)))
(error
- "Mandatory field ``%s'' is empty." field-name))))
+ "Mandatory field ``%s'' is empty" field-name))))
(if (memq 'unify-case format)
(let* ((fl
(car (cdr (assoc-ignore-case
(defun bibtex-autokey-abbrev (string len)
;; Returns an abbreviation of string with at least len
- ;; characters. String is aborted only after a consonant or at the
- ;; word end. If len is not a number, string is returned unchanged.
+ ;; characters. String is aborted only after a consonant or at the
+ ;; word end. If len is not a number, string is returned unchanged.
(cond ((or
(not (numberp len))
(<= (length string) len))
(bibtex-cfield "title" bibtex-field-text) max t)
(bibtex-autokey-change
(buffer-substring-no-properties
- (match-beginning bibtex-text-in-cfield)
- (match-end bibtex-text-in-cfield))
+ (1+ (match-beginning bibtex-text-in-cfield))
+ (1- (match-end bibtex-text-in-cfield)))
bibtex-autokey-titleword-change-strings)
"")))
(index 0)
titleword
bibtex-autokey-titleword-ignore)
(setq counter (1- counter))
- (setq
+ (setq
titleword
(funcall bibtex-autokey-titleword-case-convert titleword))
(if (or (not (numberp bibtex-autokey-titlewords))
used as the key.
17. If the value of `bibtex-autokey-edit-before-use' is non-nil,
the key is then presented in the minibuffer to the user,
- where it can be edited. The key given by the user is then
+ where it can be edited. The key given by the user is then
used."
(let* ((pnt (point))
(min (bibtex-beginning-of-entry))
(if verbose
(bibtex-progress-message))
(let (label
- label2)
+ label2)
(cond
((looking-at bibtex-reference-head)
(setq
label
- (buffer-substring-no-properties
+ (buffer-substring-no-properties
(match-beginning bibtex-key-in-head)
(match-end bibtex-key-in-head)))
(let ((p (point))
(try-completion part-of-word completions))))
(cond ((eq completion t)
(if complete-strings
- ;; remove double-quotes or braces if field is no concatenation
+ ;; remove double-quotes or braces if field is no concatenation
(save-excursion
(bibtex-inside-field)
(bibtex-enclosing-field)
(equal (match-end 0) end))
(bibtex-remove-delimiters))))))
((not completion)
- (error "Can't find completion for \"%s\"." part-of-word))
+ (error "Can't find completion for \"%s\"" part-of-word))
((not (string= part-of-word completion))
(delete-region beg end)
(insert completion)
from all non-empty optional or alternative fields, checks that no required
fields are empty, and does some formatting dependent on the value of
bibtex-entry-format.
-Note: some functions in BibTeX mode depend on entries being in a special
-format (all fields beginning on separate lines), so it is usually a bad
+Note: some functions in BibTeX mode depend on entries being in a special
+format (all fields beginning on separate lines), so it is usually a bad
idea to remove `realign' from bibtex-entry-format.
Use \\[bibtex-find-text] to position the cursor at the end of the current field.
Entry to BibTeX mode calls the value of `bibtex-mode-hook' if that value is
non-nil.
-\\{bibtex-mode-map}
-"
+\\{bibtex-mode-map}"
(interactive)
(kill-all-local-variables)
(use-local-map bibtex-mode-map)
(set-buffer curbuf)
(setq bibtex-strings compl))
(error
- "File %s not in paths defined by bibtex-string-file-path variable."
+ "File %s not in paths defined by bibtex-string-file-path variable"
filename))))
bibtex-string-files)
(if bibtex-maintain-sorted-entries
(message nil))))
(defun bibtex-entry (entry-type)
- "Inserts a new BibTeX entry.
+ "Insert a new BibTeX entry.
After insertion it calls the functions in `bibtex-add-entry-hook'."
(interactive (let* ((completion-ignore-case t)
(e-t (completing-read
(r-n-o (elt e 1))
(c-ref (elt e 2)))
(if (not e)
- (error "Bibtex entry type %s not defined." entry-type))
+ (error "Bibtex entry type %s not defined" entry-type))
(if (and
(member entry-type bibtex-include-OPTcrossref)
c-ref)
(fboundp bibtex-include-OPTkey))
(bibtex-make-optional-field
(list "key" nil bibtex-include-OPTkey))
- (bibtex-make-optional-field '("key"))))
+ (bibtex-make-optional-field '("key"))))
(mapcar 'bibtex-make-optional-field optional)
(mapcar 'bibtex-make-optional-field bibtex-user-optional-fields)
(if bibtex-comma-after-last-field
(bibtex-enclosing-field)
(search-failed
(goto-char pnt)
- (error "Not on BibTeX field.")))
+ (error "Not on BibTeX field")))
(let ((mb (match-beginning bibtex-name-in-field))
(me (match-end bibtex-name-in-field)))
(goto-char mb)
(defun bibtex-make-field (e-t &optional called-by-yank)
"Makes a field named E-T in current BibTeX entry.
-This function is for interactive and non-interactive purposes. To call
+This function is for interactive and non-interactive purposes. To call
it interactively, just give it no arguments and enter the field name
using the minibuffer."
(interactive "*P")
((fboundp init)
(funcall init))
(t
- (error "%s is neither a string nor a function." init))))
+ (error "%s is neither a string nor a function" init))))
(if called-by-yank
""
(bibtex-field-right-delimiter)))
If called from a program, this function returns the new location of point."
(interactive)
(let ((case-fold-search t)
- (valid-entry-head
+ (valid-entry-head
(concat "[ \t]*@[ \t]*\\("
(mapconcat
(lambda (type)
(if err
(progn
(goto-char pnt)
- (error "Syntactical incorrect entry starts here."))))
+ (error "Syntactical incorrect entry starts here"))))
(point))
-
+
(defun bibtex-reposition-window (arg)
"Make the current BibTeX entry visible."
(interactive "P")
(defun bibtex-count-entries (&optional count-string-entries)
"Count number of entries in current buffer or region.
-With prefix argument it counts all entries, otherwise it counts all
-except Strings.
+With prefix argument COUNT-STRING-ENTRIES it counts all entries,
+otherwise it counts all except Strings.
If mark is active it counts entries in region, if not in whole buffer."
(interactive "P")
(let ((pnt (point))
(if (not
(re-search-forward
(bibtex-cfield "abstract" bibtex-field-text) pnt t))
- (error "No abstract in entry.")))
+ (error "No abstract in entry")))
(ispell-region (match-beginning bibtex-text-in-cfield)
(match-end bibtex-text-in-cfield)))
(defun bibtex-hide-entry-bodies (&optional arg)
"Hide all lines between first and last BibTeX entries not beginning with @.
-With argument, show all text."
+With prefix argument ARG, show all text."
(interactive "P")
(save-excursion
(bibtex-beginning-of-first-entry)
(buffer-substring-no-properties
(match-beginning bibtex-key-in-head)
(match-end bibtex-key-in-head)))))))
-
+
(defun bibtex-find-entry-location (entry-name &optional ignore-dups)
"Looking for place to put the BibTeX entry named ENTRY-NAME.
Performs a binary search (therefore, buffer is assumed to be in sorted
order, without duplicates (see \\[bibtex-validate]), if it is
-not, bibtex-find-entry-location will fail). If entry-name is already
-used as a reference key, an error is signaled. However, if optional
+not, `bibtex-find-entry-location' will fail). If entry-name is already
+used as a reference key, an error is signaled. However, if optional
variable IGNORE-DUPS is non-nil, no error messages about duplicate
entries are signaled, but the error handling is assumed to be made in
the calling function.
(if (not ignore-dups)
(progn
(bibtex-beginning-of-entry)
- (error "Entry with key `%s' already exists." entry-name))))))
+ (error "Entry with key `%s' already exists" entry-name))))))
(if dup
(progn
(bibtex-beginning-of-entry)
(match-beginning bibtex-key-in-reference)
(match-end bibtex-key-in-reference))))
(if (or
- (not actual-key)
- (string-lessp actual-key entry-name))
+ (not actual-key)
+ (string-lessp actual-key entry-name))
;; buffer contains no valid entries or
;; greater than last entry --> append
(progn
(newline (forward-line 2)))
(beginning-of-line))
(goto-char right))
- t)))
+ t)))
(defun bibtex-validate (&optional test-thoroughly)
"Validate if buffer or region is syntactically correct.
error-list
(cons (list
(bibtex-current-line)
- "Syntax error (check esp. commas, braces, and quotes)")
+ "Syntax error (check esp. commas, braces, and quotes)")
error-list))
(forward-char)))))
(bibtex-progress-message 'done)
t)))
(defun bibtex-next-field (arg)
- "Finds end of text of next BibTeX field; with arg, to its beginning."
+ "Finds end of text of next BibTeX field; with ARG, to its beginning."
(interactive "P")
(bibtex-inside-field)
(let ((start (point)))
(match-end 0))))
(t
(if (not silent)
- (error "Not on BibTeX field."))))))
+ (error "Not on BibTeX field"))))))
(defun bibtex-remove-OPT-or-ALT ()
"Removes the string starting optional/alternative fields.
(defun bibtex-kill-field (&optional copy-only)
"Kills the entire enclosing BibTeX field.
-With prefix arg, copy the current field to `bibtex-field-kill-ring,'
+With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring,'
but do not actually kill it."
(interactive "P")
(let ((pnt (point))
(defun bibtex-kill-entry (&optional copy-only)
"Kill the entire enclosing BibTeX reference entry.
-With prefix arg copy the current reference entry to
+With prefix arg COPY-ONLY the current reference entry to
`bibtex-entry-kill-ring', but do not actually kill it."
(interactive "P")
(let ((pnt (point))
See also the command \\[bibtex-yank-pop]]."
(interactive "*p")
(bibtex-insert-current-kill (1- n))
- (setq this-command 'bibtex-yank))
+ (setq this-command 'bibtex-yank))
(defun bibtex-yank-pop (n)
"Replace just-yanked killed BibTeX item with a different.
This command is allowed only immediately after a `bibtex-yank' or a
`bibtex-yank-pop'.
At such a time, the region contains a reinserted previously killed
-BibTeX item. `bibtex-yank-pop' deletes that item and inserts in its
+BibTeX item. `bibtex-yank-pop' deletes that item and inserts in its
place a different killed BibTeX item.
With no argument, the previous kill is inserted.
(defun bibtex-pop-previous (arg)
"Replace text of current field with the similar field in previous entry.
-With arg, goes up ARG entries. Repeated, goes up so many times. May be
+With arg, goes up ARG entries. Repeated, goes up so many times. May be
intermixed with \\[bibtex-pop-next] (bibtex-pop-next)."
(interactive "p")
(bibtex-pop arg 'previous))
(defun bibtex-pop-next (arg)
"Replace text of current field with the text of similar field in next entry.
-With arg, goes down ARG entries. Repeated, goes down so many times. May be
+With arg, goes down ARG entries. Repeated, goes down so many times. May be
intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
(interactive "p")
(bibtex-pop arg 'next))
(re-search-forward bibtex-reference-head)
(if (not success)
(error
- "New inserted reference yields duplicate key."))))))))
+ "New inserted reference yields duplicate key"))))))))
(if (not called-by-reformat)
(save-excursion
(save-restriction
(defun bibtex-fill-entry ()
"Fill current entry.
-Realigns entry, so that every field starts on a separate line. Field
+Realigns entry, so that every field starts on a separate line. Field
names appear in column `bibtex-field-indentation', field text starts in
-column bibtex-text-indentation and continuation lines start here, too.
+column `bibtex-text-indentation' and continuation lines start here, too.
If `bibtex-align-at-equal-sign' is non-nil, align equal signs also."
(interactive "*")
(let ((pnt (copy-marker (point)))
(defun bibtex-reformat (&optional additional-options called-by-convert-alien)
"Reformat all BibTeX entries in buffer or region.
With prefix argument, read options for reformatting from minibuffer.
-With C-u C-u prefix argument, reuse previous answers (if any) again.
+With \\[universal-argument] \\[universal-argument] prefix argument, reuse previous answers (if any) again.
If mark is active it reformats entries in region, if not in whole buffer."
(interactive "*P")
(let* ((pnt (point))
(defun bibtex-complete-key ()
"Complete word fragment before point to longest prefix of a defined key.
-If point is not after the part of a word, all keys are listed. This
+If point is not after the part of a word, all keys are listed. This
function is most useful in completing crossref entries."
(interactive "*")
(if (not bibtex-keys)
(bibtex-complete bibtex-keys))
(defun bibtex-Article ()
+ "Insert a new BibTeX @Article entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Article"))
(defun bibtex-Book ()
+ "Insert a new BibTeX @Book entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Book"))
(defun bibtex-Booklet ()
+ "Insert a new BibTeX @Booklet entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Booklet"))
(defun bibtex-InBook ()
+ "Insert a new BibTeX @InBook entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "InBook"))
(defun bibtex-InCollection ()
+ "Insert a new BibTeX @InCollection entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "InCollection"))
(defun bibtex-InProceedings ()
+ "Insert a new BibTeX @InProceedings entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "InProceedings"))
(defun bibtex-Manual ()
+ "Insert a new BibTeX @Manual entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Manual"))
(defun bibtex-MastersThesis ()
+ "Insert a new BibTeX @MastersThesis entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "MastersThesis"))
(defun bibtex-Misc ()
+ "Insert a new BibTeX @Misc entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Misc"))
(defun bibtex-PhdThesis ()
+ "Insert a new BibTeX @PhdThesis entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "PhdThesis"))
(defun bibtex-Proceedings ()
+ "Insert a new BibTeX @Proceedings entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Proceedings"))
(defun bibtex-TechReport ()
+ "Insert a new BibTeX @TechReport entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "TechReport"))
(defun bibtex-Unpublished ()
+ "Insert a new BibTeX @Unpublished entry; see also `bibtex-entry'."
(interactive)
(bibtex-entry "Unpublished"))
(defun bibtex-String ()
+ "Insert a new BibTeX @String entry."
(interactive)
(if (not bibtex-keys)
(bibtex-parse-keys nil t))
(length "@String{")))))
(defun bibtex-Preamble ()
+ "Insert a new BibTeX @Preamble entry."
(interactive)
(bibtex-move-outside-of-entry)
(indent-to-column bibtex-entry-offset)