Function: bibtex-mode

bibtex-mode is an autoloaded, interactive and byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-mode)

Documentation

Major mode for editing BibTeX files.

General information on working with BibTeX mode:

Use commands such as C-c C-e b (bibtex-Book) to get a template for a specific entry. Then fill in all desired fields using C-j (bibtex-next-field) to jump from field to field. After having filled in all desired fields in the entry, clean the new entry with the command C-c C-c (bibtex-clean-entry).

Some features of BibTeX mode are available only by setting the variable bibtex-maintain-sorted-entries to non-nil. However, then BibTeX mode works only with buffers containing valid (syntactically correct) and sorted entries. This is usually the case, if you have created a buffer completely with BibTeX mode and finished every new entry with C-c C-c (bibtex-clean-entry).

For third party BibTeX files, call the command M-x bibtex-convert-alien (bibtex-convert-alien) to fully take advantage of all features of BibTeX mode.

Special information:

A command such as C-c C-e b (bibtex-Book) outlines the fields for a BibTeX book entry.

The names of optional fields start with the string OPT, and are thus ignored by BibTeX. The names of alternative fields from which only one is required start with the string ALT. The OPT or ALT string may be removed from the name of a field with C-c C-o (bibtex-remove-OPT-or-ALT). C-c C-f (bibtex-make-field) inserts a new field after the current one. C-c C-k (bibtex-kill-field) kills the current field entirely. C-c C-y (bibtex-yank) yanks the last recently killed field after the current field. C-c } (bibtex-remove-delimiters) removes the double-quotes or braces around the text of the current field. C-c C-d (bibtex-empty-field) replaces the text of the current field with the default "" or {}. TAB (bibtex-find-text) moves point to the end of the current field. C-M-i (completion-at-point) completes word fragment before point according to context.

The command C-c C-c (bibtex-clean-entry) cleans the current entry, i.e. it removes OPT/ALT from the names of 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. Furthermore, it can automatically generate a key for the BibTeX entry, see bibtex-generate-autokey. 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.

BibTeX mode supports Imenu and hideshow minor mode (hs-minor-mode(var)/hs-minor-mode(fun)).

----------------------------------------------------------
Entry to BibTeX mode calls the value of bibtex-mode-hook if that value is non-nil.

C-M-a bibtex-beginning-of-entry
C-M-e bibtex-end-of-entry
C-M-h bibtex-mark-entry
C-M-i completion-at-point
C-M-l bibtex-reposition-window
C-c " bibtex-remove-delimiters
C-c $ bibtex-ispell-abstract
C-c & reftex-view-crossref-from-bibtex
C-c ? bibtex-print-help-message
C-c C-a bibtex-search-entries
C-c C-b bibtex-entry
C-c C-c bibtex-clean-entry
C-c C-d bibtex-empty-field
C-c C-e B bibtex-Booklet
C-c C-e C-a bibtex-Article
C-c C-e C-b bibtex-InBook
C-c C-e C-c bibtex-InCollection
C-c C-e C-p bibtex-InProceedings
C-c C-e C-s bibtex-String
C-c C-e C-t bibtex-TechReport
C-c C-e C-u bibtex-Unpublished
C-c C-e I bibtex-InBook
C-c C-e M bibtex-Misc
C-c C-e M-p bibtex-Preamble
C-c C-e P bibtex-PhdThesis
C-c C-e RET bibtex-Manual
C-c C-e TAB bibtex-InProceedings
C-c C-e b bibtex-Book
C-c C-e i bibtex-InCollection
C-c C-e m bibtex-MastersThesis
C-c C-e p bibtex-Proceedings
C-c C-f bibtex-make-field
C-c C-k bibtex-kill-field
C-c C-l bibtex-url
C-c C-n bibtex-pop-next
C-c C-o bibtex-remove-OPT-or-ALT
C-c C-p bibtex-pop-previous
C-c C-q bibtex-fill-entry
C-c C-r n bibtex-narrow-to-entry
C-c C-r w widen
C-c C-s bibtex-search-entry
C-c C-t bibtex-copy-summary-as-kill
C-c C-u bibtex-entry-update
C-c C-w bibtex-kill-entry
C-c C-x bibtex-search-crossref
C-c C-y bibtex-yank
C-c M-k bibtex-copy-field-as-kill
C-c M-w bibtex-copy-entry-as-kill
C-c M-y bibtex-yank-pop
C-c { bibtex-remove-delimiters
C-c } bibtex-remove-delimiters
C-j bibtex-next-field
M-{ bibtex-previous-entry
M-} bibtex-next-entry
TAB bibtex-find-text

Probably introduced at or before Emacs version 19.29.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
;; Interactive Functions:

;;;###autoload
(define-derived-mode bibtex-mode nil "BibTeX"
  "Major mode for editing BibTeX files.

General information on working with BibTeX mode:

Use commands such as \\<bibtex-mode-map>\\[bibtex-Book] to get a template for a specific entry.
Then fill in all desired fields using \\[bibtex-next-field] to jump from field
to field.  After having filled in all desired fields in the entry, clean the
new entry with the command \\[bibtex-clean-entry].

Some features of BibTeX mode are available only by setting the variable
`bibtex-maintain-sorted-entries' to non-nil.  However, then BibTeX mode
works only with buffers containing valid (syntactically correct) and sorted
entries.  This is usually the case, if you have created a buffer completely
with BibTeX mode and finished every new entry with \\[bibtex-clean-entry].

For third party BibTeX files, call the command \\[bibtex-convert-alien]
to fully take advantage of all features of BibTeX mode.


Special information:

A command such as \\[bibtex-Book] outlines the fields for a BibTeX book entry.

The names of optional fields start with the string OPT, and are thus ignored
by BibTeX.  The names of alternative fields from which only one is required
start with the string ALT.  The OPT or ALT string may be removed from
the name of a field with \\[bibtex-remove-OPT-or-ALT].
\\[bibtex-make-field] inserts a new field after the current one.
\\[bibtex-kill-field] kills the current field entirely.
\\[bibtex-yank] yanks the last recently killed field after the current field.
\\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field.
\\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}.
\\[bibtex-find-text] moves point to the end of the current field.
\\[completion-at-point] completes word fragment before point according to context.

The command \\[bibtex-clean-entry] cleans the current entry, i.e. it removes OPT/ALT
from the names of 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'.  Furthermore, it can automatically generate a key
for the BibTeX entry, see `bibtex-generate-autokey'.
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'.

BibTeX mode supports Imenu and hideshow minor mode (`hs-minor-mode').

----------------------------------------------------------
Entry to BibTeX mode calls the value of `bibtex-mode-hook'
if that value is non-nil.

\\{bibtex-mode-map}"
  (add-hook 'completion-at-point-functions
            #'bibtex-completion-at-point-function nil 'local)
  (make-local-variable 'bibtex-buffer-last-parsed-tick)
  ;; Install stealthy parse function if not already installed
  (unless bibtex-parse-idle-timer
    (setq bibtex-parse-idle-timer (run-with-idle-timer
                                   bibtex-parse-keys-timeout t
                                   'bibtex-parse-buffers-stealthily)))
  (setq-local paragraph-start "[ \f\n\t]*$")
  (setq-local comment-column 0)
  (setq-local defun-prompt-regexp "^[ \t]*@[[:alnum:]]+[ \t]*")
  (setq-local outline-regexp "[ \t]*@")
  (setq-local fill-paragraph-function #'bibtex-fill-field)
  (setq-local font-lock-defaults
              '(bibtex-font-lock-keywords
                nil t ((?$ . "\"")
                       ;; Mathematical expressions should be fontified as strings
                       (?\" . ".")
                       ;; Quotes are field delimiters and quote-delimited
                       ;; entries should be fontified in the same way as
                       ;; brace-delimited ones
                       )
                nil
                (font-lock-extra-managed-props . (category))
                (font-lock-mark-block-function
                 . (lambda ()
                     (set-mark (bibtex-end-of-entry))
                     (bibtex-beginning-of-entry)))))
  (setq-local syntax-propertize-function
              (syntax-propertize-via-font-lock
               bibtex-font-lock-syntactic-keywords))
  (let ((fun (lambda ()
               (bibtex-set-dialect)
               (setq-local comment-start bibtex-comment-start)
               (setq-local comment-start-skip
                           (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*"))
               (setq-local fill-prefix
                           (make-string (+ bibtex-entry-offset
                                           bibtex-contline-indentation)
                                        ?\s)))))
    (if (and buffer-file-name enable-local-variables)
        (add-hook 'hack-local-variables-hook fun nil t)
      (funcall fun))))