• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/textmodes/

Lines Matching +defs:entry +defs:format

62   "List of functions to call on entry to BibTeX mode."
72 (defcustom bibtex-entry-delimiters 'braces
73 "Type of entry delimiters. Allowed values are `braces' or `parentheses'."
98 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)."
106 (defcustom bibtex-entry-format
108 "Type of formatting performed by `bibtex-clean-entry'.
116 inherit-booktitle If entry contains a crossref field and the booktitle
118 of the title field of the crossreferenced entry.
122 last-comma Add or delete comma on end of last field in entry,
125 `bibtex-field-delimiters' and `bibtex-entry-delimiters'.
126 unify-case Change case of entry and field names.
144 (defcustom bibtex-clean-entry-hook nil
145 "List of functions to call when entry has been cleaned.
146 Functions are called with point inside the cleaned entry, and the buffer
147 narrowed to just the entry."
155 crossref All entries are sorted alphabetically unless an entry has a
157 alphabetical order immediately preceding the main entry.
158 entry-class The entries are divided into classes according to their
159 entry name, see `bibtex-sort-entry-class'. Within each class
166 (const entry-class)
169 '(lambda (a) (memq a '(nil t plain crossref entry-class))))
171 (defcustom bibtex-sort-entry-class
175 "List of classes of BibTeX entry names, used for sorting entries.
176 If value of `bibtex-maintain-sorted-entries' is `entry-class'
178 class contains a list of entry names. An entry `catch-all' applies
184 (put 'bibtex-sort-entry-class 'safe-local-variable
208 (defcustom bibtex-entry-kill-ring-max 20
209 "Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
225 (defcustom bibtex-entry-field-alist
232 ("number" "Number of the journal (only allowed if entry contains volume)")
436 "List of BibTeX entry types and their associated fields.
439 ENTRY-NAME is the name of a BibTeX entry. The remaining pairs contain
440 the required and optional fields of the BibTeX entry.
483 (put 'bibtex-entry-field-alist 'risky-local-variable t)
490 (defcustom bibtex-add-entry-hook nil
491 "List of functions to call when BibTeX entry has been inserted."
554 "List of BibTeX files that are searched for entry keys.
678 "If non-nil use fields from crossreferenced entry if necessary.
679 If this variable is non-nil and some field has no entry, but a
680 valid crossref entry, the field from the crossreferenced entry is used.
788 (defcustom bibtex-entry-offset 0
821 "If non-nil, a comma is put at end of last field in the entry template."
831 "Automatically fill fields if possible for those BibTeX entry types."
836 "Function to call for generating a summary of current BibTeX entry.
837 It takes no arguments. Point must be at beginning of entry.
845 "List of schemes for generating the URL of a BibTeX entry.
854 FIELD is a field name as returned by `bibtex-parse-entry'.
860 are passed through `format' using STRING as format control string.
917 (modify-syntax-entry ?\" "\"" st)
918 (modify-syntax-entry ?$ "$$ " st)
919 (modify-syntax-entry ?% "< " st)
920 (modify-syntax-entry ?' "w " st)
921 (modify-syntax-entry ?@ "w " st)
922 (modify-syntax-entry ?\\ "\\" st)
923 (modify-syntax-entry ?\f "> " st)
924 (modify-syntax-entry ?\n "> " st)
926 (modify-syntax-entry ?= "." st)
927 (modify-syntax-entry ?~ " " st)
940 (define-key km "\C-c\C-c" 'bibtex-clean-entry)
941 (define-key km "\C-c\C-q" 'bibtex-fill-entry)
942 (define-key km "\C-c\C-s" 'bibtex-find-entry)
950 (define-key km "\C-c\C-w" 'bibtex-kill-entry)
951 (define-key km "\C-c\M-w" 'bibtex-copy-entry-as-kill)
956 (define-key km "\C-c\C-u" 'bibtex-entry-update)
958 (define-key km "\M-\C-a" 'bibtex-beginning-of-entry)
959 (define-key km "\M-\C-e" 'bibtex-end-of-entry)
961 (define-key km "\C-\M-h" 'bibtex-mark-entry)
962 (define-key km "\C-c\C-b" 'bibtex-entry)
963 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry)
994 ["Beginning of Entry" bibtex-beginning-of-entry t]
995 ["End of Entry" bibtex-end-of-entry t]
999 ["Find Entry" bibtex-find-entry t]
1022 ["Fill Entry" bibtex-fill-entry t]
1023 ["Clean Entry" bibtex-clean-entry t]
1024 ["Update Entry" bibtex-entry-update t]
1026 ["Kill Entry" bibtex-kill-entry t]
1027 ["Copy Entry to Kill Ring" bibtex-copy-entry-as-kill t]
1034 ["Ispell Entry" bibtex-ispell-entry t]
1037 ["Narrow to Entry" bibtex-narrow-to-entry t]
1038 ["Mark Entry" bibtex-mark-entry t]
1053 bibtex-entry-menu bibtex-mode-map "Entry-Types Menu in BibTeX mode"
1077 "Next point where `bibtex-pop-previous' starts looking for a similar entry.")
1080 "Next point where `bibtex-pop-next' starts looking for a similar entry.")
1089 (defvar bibtex-entry-kill-ring nil
1091 At most `bibtex-entry-kill-ring-max' items are kept here.")
1093 (defvar bibtex-entry-kill-ring-yank-pointer nil
1094 "The tail of `bibtex-entry-kill-ring' whose car is the last item yanked.")
1097 "Type of the last kill command (either 'field or 'entry).")
1134 (defvar bibtex-entry-type-history nil
1135 "History list for reading entry types.")
1154 "Regexp matching the reference key part of a BibTeX entry.")
1159 (defvar bibtex-entry-type
1161 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)")
1162 "Regexp matching the name of a BibTeX entry.")
1164 (defvar bibtex-entry-head
1166 bibtex-entry-type
1170 "Regexp matching the header line of a BibTeX entry (including key).")
1172 (defvar bibtex-entry-maybe-empty-head
1173 (concat bibtex-entry-head "?")
1174 "Regexp matching the header line of a BibTeX entry (possibly without key).")
1176 (defconst bibtex-any-entry-maybe-empty-head
1179 "Regexp matching the header line of any BibTeX entry (possibly without key).")
1181 (defvar bibtex-any-valid-entry-type
1184 (mapcar 'car bibtex-entry-field-alist))) "\\)")
1185 "Regexp matching any valid BibTeX entry (including String and Preamble).")
1188 "Regexp subexpression number of the type part in `bibtex-entry-head'.")
1191 "Regexp subexpression number of the key part in `bibtex-entry-head'.")
1194 "Regexp matching the name of a BibTeX String entry.")
1198 "Regexp matching the header line of a BibTeX String entry.")
1202 "Regexp matching the prefix part of a BibTeX Preamble entry.")
1210 ;; entry type and reference key
1211 `((,bibtex-any-entry-maybe-empty-head
1234 (defvar bibtex-sort-entry-class-alist nil
1235 "Alist mapping entry types to their sorting index.
1236 Auto-generated from `bibtex-sort-entry-class'.
1237 Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
1256 "Parse a string of the format <left-hand-side = right-hand-side>.
1297 (modify-syntax-entry ?\{ "(}" st)
1298 (modify-syntax-entry ?\} "){" st)
1299 (modify-syntax-entry ?\[ "." st)
1300 (modify-syntax-entry ?\] "." st)
1301 (modify-syntax-entry ?\( "." st)
1302 (modify-syntax-entry ?\) "." st)
1303 (modify-syntax-entry ?\\ "." st)
1304 (modify-syntax-entry ?\" "." st)
1310 (modify-syntax-entry ?\\ "\\" st)
1311 (modify-syntax-entry ?\" "\"" st)
1381 by the end of the current entry. Do not move point."
1386 bibtex-any-entry-maybe-empty-head))
1393 ;; We found a new entry
1422 limited by the beginning of the current entry. Do not move point."
1425 (setq bound (save-excursion (bibtex-beginning-of-entry))))
1484 "Get content of field FIELD of current BibTeX entry.
1488 (let* ((end (if follow-crossref (bibtex-end-of-entry) t))
1489 (beg (bibtex-beginning-of-entry)) ; move point
1503 "Parse the prefix part of a BibTeX string entry, including reference key.
1523 "Parse the postfix part of a BibTeX string entry, including the text.
1526 character of the string entry. Move point past BibTeX string entry."
1538 "Parse a BibTeX string entry beginning at the position of point.
1539 If a syntactically correct entry is found, return a cons pair containing
1540 the boundaries of the reference key and text parts of the entry.
1547 "Search forward to find a BibTeX string entry.
1548 If a syntactically correct entry is found, a pair containing the boundaries of
1616 (defun bibtex-valid-entry (&optional empty-key)
1617 "Parse a valid BibTeX entry (maybe without key if EMPTY-KEY is t).
1618 A valid entry is a syntactical correct one with type contained in
1619 `bibtex-entry-field-alist'. Ignore @String and @Preamble entries.
1620 Return a cons pair with buffer positions of beginning and end of entry
1621 if a valid entry is found, nil otherwise. Do not move point.
1623 of the entry, see regexp `bibtex-entry-head'."
1625 (if (looking-at (if empty-key bibtex-entry-maybe-empty-head
1626 bibtex-entry-head))
1630 (let ((entry-closer
1634 ",?[ \t\n]*)" ;; entry opened with `('
1635 ",?[ \t\n]*}")) ;; entry opened with `{'
1642 (if (looking-at entry-closer) (setq end (match-end 0)))))
1645 (defun bibtex-skip-to-valid-entry (&optional backward)
1646 "Move point to beginning of the next valid BibTeX entry.
1647 Do not move if we are already at beginning of a valid BibTeX entry.
1649 beginning of previous valid one. A valid entry is a syntactical correct one
1650 with type contained in `bibtex-entry-field-alist' or, if
1652 entry. Return buffer position of beginning and end of entry if a valid
1653 entry is found, nil otherwise."
1658 ;; Loop till we look at a valid entry.
1660 (cond ((setq found (or (bibtex-valid-entry)
1671 "Call FUN for each BibTeX entry in buffer (possibly narrowed).
1672 FUN is called with three arguments, the key of the entry and the buffer
1673 positions of beginning and end of entry. Also, point is at beginning of
1674 entry and `match-data' corresponds to the header of the entry,
1675 see regexp `bibtex-entry-head'. If `bibtex-sort-ignore-string-entries'
1681 (while (setq found (bibtex-skip-to-valid-entry))
1682 (looking-at bibtex-any-entry-maybe-empty-head)
1722 (defun bibtex-entry-left-delimiter ()
1723 "Return a string dependent on `bibtex-entry-delimiters'."
1724 (if (eq bibtex-entry-delimiters 'braces)
1728 (defun bibtex-entry-right-delimiter ()
1729 "Return a string dependent on `bibtex-entry-delimiters'."
1730 (if (eq bibtex-entry-delimiters 'braces)
1735 "Flash at BibTeX entry head before point, if exists."
1739 (bibtex-beginning-of-entry)
1740 (when (and (looking-at bibtex-any-entry-maybe-empty-head)
1749 "Make an optional field named FIELD in current BibTeX entry."
1754 (defun bibtex-move-outside-of-entry ()
1755 "Make sure point is outside of a BibTeX entry."
1757 (bibtex-end-of-entry)
1759 ;; We moved backward, so we weren't inside an entry to begin with.
1769 (defun bibtex-beginning-of-first-entry ()
1770 "Go to beginning of line of first BibTeX entry in buffer.
1774 (bibtex-skip-to-valid-entry)
1800 Optional arg BEG is beginning of entry."
1801 (if beg (goto-char beg) (bibtex-beginning-of-entry))
1802 (looking-at bibtex-any-entry-maybe-empty-head)
1806 "Reinsert the Nth stretch of killed BibTeX text (field or entry).
1820 ;; insert past the current entry
1821 (bibtex-skip-to-valid-entry)
1824 (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer
1825 bibtex-entry-kill-ring)))))
1827 (defun bibtex-format-entry ()
1828 "Helper function for `bibtex-clean-entry'.
1829 Formats current entry according to variable `bibtex-entry-format'."
1832 (bibtex-narrow-to-entry)
1834 (format (if (eq bibtex-entry-format t)
1839 bibtex-entry-format))
1841 entry-list req-field-list field-list)
1843 ;; identify entry type
1845 (or (re-search-forward bibtex-entry-type nil t)
1846 (error "Not inside a BibTeX entry"))
1849 (setq entry-list (assoc-string (buffer-substring-no-properties
1851 bibtex-entry-field-alist
1854 ;; unify case of entry name
1855 (when (memq 'unify-case format)
1857 (insert (car entry-list)))
1859 ;; update left entry delimiter
1860 (when (memq 'delimiters format)
1864 (insert (bibtex-entry-left-delimiter))))
1866 ;; determine if entry has crossref field and if at least
1869 (let* ((fields-alist (bibtex-parse-entry t))
1875 (nth 0 (nth 2 entry-list)) ; crossref part
1876 (nth 0 (nth 1 entry-list)))) ; required part
1886 ((memq 'required-fields format)
1891 (memq 'required-fields format))
1912 ;; tasks done by bibtex-format-entry. However, they contain
1916 (if (memq 'opts-or-alts format)
1938 (when (and (memq 'numerical-fields format)
1947 (when (memq 'delimiters format)
1958 (if (and (memq 'page-dashes format)
1965 ;; use book title of crossref'd entry
1966 (if (and (memq 'inherit-booktitle format)
1973 (if (bibtex-find-entry crossref-key t)
1991 (memq 'required-fields format)
1996 (if (memq 'unify-case format)
1999 (append (nth 0 (nth 1 entry-list))
2000 (nth 1 (nth 1 entry-list))
2015 (if (memq 'required-fields format)
2035 (if (memq 'last-comma format)
2043 ;; update right entry delimiter
2046 (when (memq 'delimiters format)
2049 (insert (bibtex-entry-right-delimiter)))
2051 ;; fill entry
2052 (if (memq 'realign format)
2053 (bibtex-fill-entry))))))
2091 "Get contents of the name field of the current entry.
2206 "Generate automatically a key for a BibTeX entry.
2233 is absent, but the entry has a valid crossref field and
2235 crossreferenced entry instead.
2316 Find both entry keys and crossref entries. If ABORTABLE is non-nil abort
2331 (re (concat bibtex-entry-head "\\|"
2346 bibtex-entry-field-alist t)
2347 ;; This is an entry.
2565 "Display summary message on entry KEY after completion of a crossref key.
2569 (bibtex-find-entry key t))
2573 "Push summery of current BibTeX entry to kill ring.
2577 (bibtex-beginning-of-entry)
2578 (if (looking-at bibtex-entry-maybe-empty-head)
2580 (error "No entry found"))))
2583 "Return summary of current BibTeX entry.
2586 (if (looking-at bibtex-entry-maybe-empty-head)
2632 (bibtex-beginning-of-entry))
2633 (t (bibtex-end-of-entry)))
2637 ;; The search of BibTeX fields is not bounded by entry boundaries
2752 Use commands such as \\[bibtex-Book] to get a template for a specific entry.
2754 to field. After having filled in all desired fields in the entry, clean the
2755 new entry with the command \\[bibtex-clean-entry].
2761 with BibTeX mode and finished every new entry with \\[bibtex-clean-entry].
2769 A command such as \\[bibtex-Book] outlines the fields for a BibTeX book entry.
2783 The command \\[bibtex-clean-entry] cleans the current entry, i.e. it removes OPT/ALT
2786 of `bibtex-entry-format'. Furthermore, it can automatically generate a key
2787 for the BibTeX entry, see `bibtex-generate-autokey'.
2789 format (all fields beginning on separate lines), so it is usually a bad
2790 idea to remove `realign' from `bibtex-entry-format'.
2819 (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset
2836 (set-mark (bibtex-end-of-entry))
2837 (bibtex-beginning-of-entry)))))
2839 (list (list nil bibtex-entry-head bibtex-key-in-head))
2844 (easy-menu-add bibtex-entry-menu)
2847 (defun bibtex-field-list (entry-type)
2848 "Return list of allowed fields for entry ENTRY-TYPE.
2851 names for ENTRY-TYPE according to `bibtex-entry-field-alist',
2854 (let ((e (assoc-string entry-type bibtex-entry-field-alist t))
2857 (error "Fields for BibTeX entry type %s not defined" entry-type))
2858 (if (and (member-ignore-case entry-type bibtex-include-OPTcrossref)
2871 (if (member-ignore-case entry-type bibtex-include-OPTcrossref)
2872 (push '("crossref" "Reference key of the cross-referenced entry")
2877 (defun bibtex-entry (entry-type)
2878 "Insert a new BibTeX entry of type ENTRY-TYPE.
2879 After insertion call the value of `bibtex-add-entry-hook' if that value
2883 (list (completing-read "Entry Type: " bibtex-entry-field-alist
2884 nil t nil 'bibtex-entry-type-history))))
2886 (bibtex-read-key (format "%s key: " entry-type))))
2887 (field-list (bibtex-field-list entry-type)))
2888 (unless (bibtex-prepare-new-entry (list key nil entry-type))
2890 (indent-to-column bibtex-entry-offset)
2891 (insert "@" entry-type (bibtex-entry-left-delimiter))
2899 (indent-to-column bibtex-entry-offset)
2900 (insert (bibtex-entry-right-delimiter) "\n\n"))
2902 (if (member-ignore-case entry-type bibtex-autofill-types)
2903 (bibtex-autofill-entry))
2904 (run-hooks 'bibtex-add-entry-hook)))
2906 (defun bibtex-entry-update (&optional entry-type)
2907 "Update an existing BibTeX entry.
2908 In the BibTeX entry at point, make new fields for those items that may occur
2911 If ENTRY-TYPE is non-nil, change first the entry type to ENTRY-TYPE.
2916 (completing-read "New entry type: " bibtex-entry-field-alist
2917 nil t nil 'bibtex-entry-type-history)))))
2919 (bibtex-beginning-of-entry)
2920 (when (looking-at bibtex-entry-maybe-empty-head)
2922 (if entry-type
2924 (replace-match (concat "@" entry-type) nil nil nil 1))
2925 (setq entry-type (bibtex-type-in-head)))
2926 (let* ((field-list (bibtex-field-list entry-type))
2946 (defun bibtex-parse-entry (&optional content)
2947 "Parse entry at point, return an alist.
2954 (when (looking-at bibtex-entry-maybe-empty-head)
2965 (defun bibtex-autofill-entry ()
2966 "Try to fill fields of current BibTeX entry based on neighboring entries.
2967 The current entry must have a key. Determine the neighboring entry
2969 entry. For all empty fields of the current entry insert the corresponding
2970 field contents of the neighboring entry. Finally try to update the text
2972 entry (for example, the year parts of the keys)."
2975 (bibtex-beginning-of-entry)
2976 (when (looking-at bibtex-entry-head)
2985 ;; First see whether to use the previous or the next entry
2989 (bibtex-beginning-of-entry)
2990 (if (and (looking-at bibtex-entry-head)
2997 (bibtex-end-of-entry)
2998 (bibtex-skip-to-valid-entry)
2999 (if (and (looking-at bibtex-entry-head)
3009 ;; Then fill the new entry's fields with the chosen other entry.
3011 (setq other (save-excursion (goto-char other) (bibtex-parse-entry)))
3012 (setq key-end (point)) ;In case parse-entry changed the buffer.
3035 "Print helpful information about current FIELD in current BibTeX entry.
3048 (bibtex-beginning-of-entry)
3049 (looking-at bibtex-entry-maybe-empty-head)
3058 "Make a field named FIELD in current BibTeX entry.
3061 `bibtex-entry-field-alist'.
3071 (bibtex-beginning-of-entry)
3072 (looking-at bibtex-any-entry-maybe-empty-head)
3085 (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation))
3089 (indent-to-column (+ bibtex-entry-offset
3093 (indent-to-column (+ bibtex-entry-offset
3108 (defun bibtex-beginning-of-entry ()
3109 "Move to beginning of BibTeX entry (beginning of line).
3110 If inside an entry, move to the beginning of it, otherwise move to the
3111 beginning of the previous entry. If point is ahead of all BibTeX entries
3120 (defun bibtex-end-of-entry ()
3121 "Move to end of BibTeX entry (past the closing brace).
3122 If inside an entry, move to the end of it, otherwise move to the end
3123 of the previous entry. Do not move if ahead of first entry.
3128 (_ (bibtex-beginning-of-entry))
3129 (bounds (bibtex-valid-entry t)))
3130 (cond (bounds (goto-char (cdr bounds))) ; regular entry
3134 ((looking-at bibtex-any-valid-entry-type)
3135 ;; Parsing of entry failed
3136 (error "Syntactically incorrect BibTeX entry starts here."))
3137 (t (if (interactive-p) (message "Not on a known BibTeX entry."))
3150 "Make the current BibTeX entry visible.
3151 If entry is smaller than `window-body-height', entry is centered in window.
3152 Otherwise display the beginning of entry."
3155 (beg (line-number-at-pos (bibtex-beginning-of-entry)))
3156 (end (line-number-at-pos (bibtex-end-of-entry))))
3158 ;; entry fits in current window
3163 ;; entry too large for current window
3171 (defun bibtex-mark-entry ()
3172 "Put mark at beginning, point at end of current BibTeX entry."
3174 (set-mark (bibtex-beginning-of-entry))
3175 (bibtex-end-of-entry))
3192 (defun bibtex-ispell-entry ()
3193 "Check BibTeX entry for spelling errors."
3195 (ispell-region (save-excursion (bibtex-beginning-of-entry))
3196 (save-excursion (bibtex-end-of-entry))))
3199 "Check abstract of BibTeX entry for spelling errors."
3202 (bibtex-beginning-of-entry)
3207 (error "No abstract in entry"))))
3209 (defun bibtex-narrow-to-entry ()
3210 "Narrow buffer to current BibTeX entry."
3214 (narrow-to-region (bibtex-beginning-of-entry)
3215 (bibtex-end-of-entry))))
3217 (defun bibtex-entry-index ()
3218 "Return index of BibTeX entry head at or past position of point.
3222 of the head of the entry found. Return nil if no entry found."
3224 (if (re-search-forward bibtex-entry-maybe-empty-head nil t)
3226 ;; all entry names should be downcase (for ease of comparison)
3227 (entry-name (downcase (bibtex-type-in-head))))
3234 entry-name))
3235 (list key nil entry-name))))))
3237 (defun bibtex-init-sort-entry-class-alist ()
3238 (unless (local-variable-p 'bibtex-sort-entry-class-alist)
3239 (set (make-local-variable 'bibtex-sort-entry-class-alist)
3241 (dolist (class bibtex-sort-entry-class alist)
3243 (dolist (entry class)
3244 ;; All entry names should be downcase (for ease of comparison).
3245 (push (cons (if (stringp entry) (downcase entry) entry) i)
3265 ((eq bibtex-maintain-sorted-entries 'entry-class)
3266 (let ((n1 (cdr (or (assoc (nth 2 index1) bibtex-sort-entry-class-alist)
3267 (assoc 'catch-all bibtex-sort-entry-class-alist)
3269 (n2 (cdr (or (assoc (nth 2 index2) bibtex-sort-entry-class-alist)
3270 (assoc 'catch-all bibtex-sort-entry-class-alist)
3285 (bibtex-beginning-of-first-entry) ; Needed by `sort-subr'
3286 (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
3288 'bibtex-skip-to-valid-entry ; NEXTREC function
3289 'bibtex-end-of-entry ; ENDREC function
3290 'bibtex-entry-index ; STARTKEY function
3295 "Move point to the beginning of BibTeX entry CROSSREF-KEY.
3298 Return position of entry if CROSSREF-KEY is found or nil otherwise.
3299 If CROSSREF-KEY is in the same buffer like current entry but before it
3301 entry. It defaults to position of point. If optional arg SPLIT is non-nil,
3302 split window so that both the referencing and the crossrefed entry are
3305 entry and SPLIT is t."
3309 (bibtex-beginning-of-entry)
3317 (setq pos (bibtex-find-entry crossref-key t)
3331 (error "The referencing entry must precede the crossrefed entry!")))
3333 ;; clean-up of an entry. Then it is not possible to check
3334 ;; whether the current entry and the crossrefed entry have
3340 (defun bibtex-find-entry (key &optional global start display)
3341 "Move point to the beginning of BibTeX entry named KEY.
3342 Return position of entry if KEY is found or nil if not found.
3358 ;; `bibtex-find-entry' moves point if key found
3359 (setq found (bibtex-find-entry key)))))
3373 bibtex-entry-type
3385 (defun bibtex-prepare-new-entry (index)
3386 "Prepare a new BibTeX entry with index INDEX.
3388 Move point where the entry KEY should be placed.
3392 Return t if preparation was successful or nil if entry KEY already exists."
3393 (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
3399 (and (not (setq key-exist (bibtex-find-entry key)))
3401 (bibtex-move-outside-of-entry))
3403 ;; then point will be at beginning of entry named key.
3407 (left (save-excursion (bibtex-beginning-of-first-entry)))
3409 (bibtex-skip-to-valid-entry t)))
3417 (bibtex-skip-to-valid-entry t)
3418 (setq actual-index (bibtex-entry-index))
3420 (setq new (bibtex-beginning-of-entry))
3425 (bibtex-end-of-entry)
3426 (bibtex-skip-to-valid-entry)
3432 (bibtex-beginning-of-entry)
3433 (setq actual-index (save-excursion (bibtex-entry-index)))
3437 ;; greater than last entry --> append
3438 (bibtex-end-of-entry)
3450 Only check known entry types, so you can put comments outside of entries.
3466 (cond ((setq bounds (bibtex-valid-entry))
3471 ((looking-at bibtex-any-valid-entry-type)
3489 (setq current (bibtex-entry-index))
3493 (format "Duplicate key `%s'" key))
3511 (bibtex-find-entry (car key))
3513 (format "Duplicate key `%s' in %s" (car key)
3524 (let* ((entry-list (assoc-string (bibtex-type-in-head)
3525 bibtex-entry-field-alist t))
3526 (req (copy-sequence (elt (elt entry-list 1) 0)))
3527 (creq (copy-sequence (elt (elt entry-list 2) 0)))
3561 (format "Required field `%s' missing"
3565 ;; alternatives in a BibTeX entry, which isn't
3570 (format "Alternative fields `%s'/`%s' missing"
3590 (insert (format "%s:%d: %s\n" file (car err) (cdr err))))
3611 (let (entry-type key key-list)
3613 (while (re-search-forward bibtex-entry-head nil t)
3614 (setq entry-type (bibtex-type-in-head)
3616 (if (or (and strings (bibtex-string= entry-type "string"))
3617 (assoc-string entry-type bibtex-entry-field-alist t))
3619 (push (format "%s:%d: Duplicate key `%s'\n"
3633 (bibtex-find-entry key)
3634 (push (format "%s:%d: Duplicate key `%s' in %s\n"
3657 "Move point to end of text of next BibTeX field or entry head.
3662 end-of-entry)
3664 (setq end-of-entry t)
3667 (setq end-of-entry t)
3670 ;; end of entry
3671 (if (looking-at "[)}][ \t\n]*") (setq end-of-entry t))))
3672 (if (and end-of-entry
3673 (re-search-forward bibtex-any-entry-maybe-empty-head nil t))
3678 "Move point to end of text of current BibTeX field or entry head.
3699 "Find text part of current BibTeX field or entry head.
3701 or entry name, start and end of text, and end of field or entry head.
3703 is a BibTeX string constant. Return value is nil if field or entry head
3714 (bibtex-beginning-of-entry)
3737 ((looking-at bibtex-entry-maybe-empty-head)
3841 (defun bibtex-kill-entry (&optional copy-only)
3842 "Kill the entire enclosing BibTeX entry.
3843 With prefix arg COPY-ONLY, copy the current entry to `bibtex-entry-kill-ring',
3848 (beg (bibtex-beginning-of-entry))
3849 (end (progn (bibtex-end-of-entry)
3851 bibtex-any-entry-maybe-empty-head nil 'move)
3855 bibtex-entry-kill-ring)
3856 (if (> (length bibtex-entry-kill-ring) bibtex-entry-kill-ring-max)
3857 (setcdr (nthcdr (1- bibtex-entry-kill-ring-max)
3858 bibtex-entry-kill-ring)
3860 (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)
3863 (setq bibtex-last-kill-command 'entry))
3865 (defun bibtex-copy-entry-as-kill ()
3866 "Copy the entire enclosing BibTeX entry to `bibtex-entry-kill-ring'."
3868 (bibtex-kill-entry t))
3872 More precisely, reinsert the field or entry killed or yanked most recently.
3913 "Replace text of current field with the similar field in previous entry.
3920 "Replace text of current field with the text of similar field in next entry.
3926 (defun bibtex-clean-entry (&optional new-key called-by-reformat)
3927 "Finish editing the current BibTeX entry and clean it up.
3928 Check that no required fields are empty and formats entry dependent
3929 on the value of `bibtex-entry-format'.
3930 If the reference key of the entry is empty or a prefix argument is given,
3931 calculate a new reference key. (Note: this works only if fields in entry
3932 begin on separate lines prior to calling `bibtex-clean-entry' or if
3933 'realign is contained in `bibtex-entry-format'.)
3934 Don't call `bibtex-clean-entry' on @Preamble entries.
3936 `bibtex-clean-entry-hook' are called with region narrowed to entry."
3937 ;; Opt. arg called-by-reformat is t if bibtex-clean-entry
3941 (start (bibtex-beginning-of-entry))
3942 (_ (or (looking-at bibtex-any-entry-maybe-empty-head)
3943 (error "Not inside a BibTeX entry")))
3944 (entry-type (bibtex-type-in-head))
3947 (cond ((bibtex-string= entry-type "preamble")
3948 ;; (bibtex-format-preamble)
3950 ((bibtex-string= entry-type "string")
3951 (setq entry-type 'string))
3952 ;; (bibtex-format-string)
3953 (t (bibtex-format-entry)))
3959 (setq key (if (eq entry-type 'string)
3963 (re-search-forward (if (eq entry-type 'string)
3965 bibtex-entry-maybe-empty-head))
3973 (bibtex-end-of-entry)
3975 bibtex-entry-maybe-empty-head nil 'move)
3978 (entry (buffer-substring start end))
3981 (bibtex-entry-index))) ; moves point to end of head
3986 (eq entry-type 'string))))
3989 (setq error (not (bibtex-prepare-new-entry index))
3991 (save-excursion (insert entry)))
3992 (bibtex-find-entry key)
3994 (bibtex-find-entry key nil end))))
3996 (error "New inserted entry yields duplicate key"))
4003 (cond ((eq entry-type 'string)
4009 ;; We have a normal entry.
4024 (if bibtex-clean-entry-hook
4027 (bibtex-narrow-to-entry)
4028 (run-hooks 'bibtex-clean-entry-hook)))))))
4042 (indent-to-column (+ bibtex-entry-offset
4049 (+ bibtex-entry-offset (- bibtex-text-indentation 2)))
4071 (defun bibtex-fill-entry ()
4072 "Fill current BibTeX entry.
4073 Realign entry, so that every field starts on a separate line. Field
4079 (end (copy-marker (bibtex-end-of-entry)))
4080 (beg (bibtex-beginning-of-entry)) ; move point
4083 (indent-to-column bibtex-entry-offset)
4093 (indent-to-column bibtex-entry-offset)
4100 (entry-type (concat "[ \t\n]*\\(" bibtex-entry-type "\\)")))
4101 ;; No blank lines prior to the first entry if there no
4103 (when (looking-at entry-type)
4106 (while (re-search-forward entry-type nil t)
4108 ;; One blank line past the last entry if it is followed by
4111 (when (re-search-forward bibtex-entry-type nil t)
4112 (bibtex-end-of-entry)
4118 Without prefix argument, reformatting is based on `bibtex-entry-format'.
4128 (bibtex-entry-format
4139 " comma at end of entry? ") . 'last-comma)
4143 ("Unify case of entry types and field names? " . 'unify-case))))))
4145 ;; cannot handle the error messages of `bibtex-format-entry'.
4147 ((eq t bibtex-entry-format)
4151 (remove 'required-fields (push 'realign bibtex-entry-format)))))
4163 (if (memq 'realign bibtex-entry-format)
4168 (bibtex-clean-entry reformat-reference-keys t)))
4224 (bibtex-beginning-of-entry)
4239 ((and (looking-at bibtex-entry-maybe-empty-head)
4295 "Insert a new BibTeX @Article entry; see also `bibtex-entry'."
4297 (bibtex-entry "Article"))
4300 "Insert a new BibTeX @Book entry; see also `bibtex-entry'."
4302 (bibtex-entry "Book"))
4305 "Insert a new BibTeX @Booklet entry; see also `bibtex-entry'."
4307 (bibtex-entry "Booklet"))
4310 "Insert a new BibTeX @InBook entry; see also `bibtex-entry'."
4312 (bibtex-entry "InBook"))
4315 "Insert a new BibTeX @InCollection entry; see also `bibtex-entry'."
4317 (bibtex-entry "InCollection"))
4320 "Insert a new BibTeX @InProceedings entry; see also `bibtex-entry'."
4322 (bibtex-entry "InProceedings"))
4325 "Insert a new BibTeX @Manual entry; see also `bibtex-entry'."
4327 (bibtex-entry "Manual"))
4330 "Insert a new BibTeX @MastersThesis entry; see also `bibtex-entry'."
4332 (bibtex-entry "MastersThesis"))
4335 "Insert a new BibTeX @Misc entry; see also `bibtex-entry'."
4337 (bibtex-entry "Misc"))
4340 "Insert a new BibTeX @PhdThesis entry; see also `bibtex-entry'."
4342 (bibtex-entry "PhdThesis"))
4345 "Insert a new BibTeX @Proceedings entry; see also `bibtex-entry'."
4347 (bibtex-entry "Proceedings"))
4350 "Insert a new BibTeX @TechReport entry; see also `bibtex-entry'."
4352 (bibtex-entry "TechReport"))
4355 "Insert a new BibTeX @Unpublished entry; see also `bibtex-entry'."
4357 (bibtex-entry "Unpublished"))
4360 "Insert a new BibTeX @String entry with key KEY."
4366 (unless (bibtex-prepare-new-entry (list key nil "String"))
4369 (indent-to-column bibtex-entry-offset)
4371 (bibtex-entry-left-delimiter))
4380 (bibtex-entry-right-delimiter)
4385 "Insert a new BibTeX @Preamble entry."
4387 (bibtex-move-outside-of-entry)
4388 (indent-to-column bibtex-entry-offset)
4390 (bibtex-entry-left-delimiter)
4394 (bibtex-entry-right-delimiter)
4399 "Browse a URL for the BibTeX entry at point.
4400 Optional POS is the location of the BibTeX entry.
4407 (bibtex-beginning-of-entry)
4409 (let ((fields-alist (bibtex-parse-entry t))
4436 (if fmt (apply 'format fmt (nreverse obj))