aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/bibtex.el137
1 files changed, 62 insertions, 75 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 2f97b1056e..93176bb9a8 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1943,81 +1943,68 @@ the value of `bibtex-text-indentation', minus 2."
(bibtex-autokey-get-titles titlestring)))
(defun bibtex-generate-autokey ()
- ;; Generates automatically a key from the author/editor and the
- ;; title field. This will only work for entries where each field
- ;; begins on a separate line.
- ;; The generation algorithm works as follows:
- ;; 1. Use the value of `bibtex-autokey-prefix-string' as a prefix.
- ;; 2. If there is a non-empty author (preferred) or editor field,
- ;; use it as the name part of the key.
- ;; 3. Change any substring found in
- ;; `bibtex-autokey-name-change-strings' to the corresponding new
- ;; one (see documentation of this variable for further detail).
- ;; 4. For every of at least first `bibtex-autokey-names' names in
- ;; the name field, determine the last name. If there are maximal
- ;; `bibtex-autokey-names' + `bibtex-autokey-names-stretch'
- ;; names, all names are used.
- ;; 5. From every last name, take at least
- ;; `bibtex-autokey-name-length' characters (abort only after a
- ;; consonant or at a word end).
- ;; 6. Unless `bibtex-autokey-preserve-case' is non-nil, convert all
- ;; last names to lowercase letters.
- ;; 7. Build the name part of the key by concatenating all
- ;; abbreviated last names with the string
- ;; `bibtex-autokey-name-separator' between any two. If there are
- ;; more names than are used in the name part, prepend the string
- ;; contained in `bibtex-autokey-additional-names'.
- ;; 8. Build the year part of the key by truncating the contents of
- ;; the year field to the rightmost `bibtex-autokey-year-length'
- ;; digits (useful values are 2 and 4). If the year field is
- ;; absent, but the entry has a valid crossref field and the
- ;; variable `bibtex-autokey-year-use-crossref-entry' is non-nil,
- ;; use the year field of the crossreferenced entry instead.
- ;; 9. For the title part of the key change the contents of the
- ;; title field of the reference according to
- ;; `bibtex-autokey-titleword-change-strings' to the
- ;; corresponding new one (see documentation of this variable for
- ;; further detail).
- ;; 10. Abbreviate the result to the string up to (but not including)
- ;; the first occurrence of a regexp matched by the items of
- ;; `bibtex-autokey-title-terminators' and delete the first
- ;; word if it appears in
- ;; `bibtex-autokey-titleword-first-ignore'. Build the title part
- ;; of the key by using at least the first
- ;; `bibtex-autokey-titlewords' capitalized words from this
- ;; abbreviated title. If the abbreviated title ends after
- ;; maximal `bibtex-autokey-titlewords' +
- ;; `bibtex-autokey-titlewords-stretch' capitalized words, all
- ;; capitalized words from the abbreviated title are used.
- ;; 11. Unless `bibtex-autokey-preserve-case' is non-nil, convert all
- ;; used titlewords to lowercase letters.
- ;; 12. For every used title word that appears in
- ;; `bibtex-autokey-titleword-abbrevs' use the corresponding
- ;; abbreviation (see documentation of this variable for further
- ;; detail).
- ;; 13. From every title word not generated by an abbreviation, take
- ;; at least `bibtex-autokey-titleword-length' characters (abort
- ;; only after a consonant or at a word end).
- ;; 14. Build the title part of the key by concatenating all
- ;; abbreviated title words with the string
- ;; `bibtex-autokey-titleword-separator' between any two.
- ;; 15. At least, to get the key, concatenate
- ;; `bibtex-autokey-prefix-string', the name part, the year part
- ;; and the title part with `bibtex-autokey-name-year-separator'
- ;; between the name part and the year part if both are non-empty
- ;; and `bibtex-autokey-year-title-separator' between the year
- ;; part and the title part if both are non-empty. If the year
- ;; part is empty, but not the other two parts,
- ;; `bibtex-autokey-year-title-separator' is used as well.
- ;; 16. If the value of `bibtex-autokey-before-presentation-hook' is
- ;; non-nil, it must be a function taking one argument. This
- ;; function is then called with the generated key as the
- ;; argument. The return value of this function (a string) is
- ;; 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
- ;; used.
+ "Automatically generate a key from the author/editor and the title field.
+This will only work for entries where each field begins on a separate line.
+The generation algorithm works as follows:
+ 1. Use the value of `bibtex-autokey-prefix-string' as a prefix.
+ 2. If there is a non-empty author (preferred) or editor field,
+ use it as the name part of the key.
+ 3. Change any substring found in `bibtex-autokey-name-change-strings'
+ to the corresponding new one (see documentation of this variable for
+ further detail).
+ 4. For each of at least the first `bibtex-autokey-names' names in
+ the name field, determine the last name. If there are at most
+ `bibtex-autokey-names' + `bibtex-autokey-names-stretch'
+ names, all names are used.
+ 5. From each last name, take at least `bibtex-autokey-name-length'
+ characters (abort only after a consonant or at a word end).
+ 6. Unless `bibtex-autokey-preserve-case' is non-nil, convert all
+ last names to lowercase letters.
+ 7. Build the name part of the key by concatenating all abbreviated last
+ names with the string `bibtex-autokey-name-separator' between any two.
+ If there are more names than are used in the name part, prepend the
+ string contained in `bibtex-autokey-additional-names'.
+ 8. Build the year part of the key by truncating the contents of
+ the year field to the rightmost `bibtex-autokey-year-length'
+ digits (useful values are 2 and 4). If the year field is
+ absent, but the entry has a valid crossref field and the
+ variable `bibtex-autokey-year-use-crossref-entry' is non-nil,
+ use the year field of the crossreferenced entry instead.
+ 9. For the title part of the key change the contents of the title field
+ of the reference according to `bibtex-autokey-titleword-change-strings'
+ to the corresponding new one (see documentation of this variable for
+ further detail).
+10. Abbreviate the result to the string up to (but not including)
+ the first occurrence of a regexp matched by the items of
+ `bibtex-autokey-title-terminators' and delete the first word if it
+ appears in `bibtex-autokey-titleword-first-ignore'. Use at least the
+ first `bibtex-autokey-titlewords' capitalized words from this
+ abbreviated title. If the abbreviated title ends after at most
+ `bibtex-autokey-titlewords' + `bibtex-autokey-titlewords-stretch'
+ capitalized words, all capitalized words from the abbreviated title are
+ used.
+11. Unless `bibtex-autokey-preserve-case' is non-nil, convert all
+ used title words to lowercase letters.
+12. For each word that appears in `bibtex-autokey-titleword-abbrevs', use
+ the corresponding abbreviation (see documentation of this variable for
+ further detail).
+13. From each title word not generated by an abbreviation, take at least
+ `bibtex-autokey-titleword-length' characters (abort only after a
+ consonant or at a word end).
+14. Build the title part of the key by concatenating all abbreviated title
+ words with the string `bibtex-autokey-titleword-separator' between any
+ two.
+15. Finally, to get the key, concatenate `bibtex-autokey-prefix-string';
+ the name part; `bibtex-autokey-name-year-separator' if the name and year
+ are both nonempty; the year part; `bibtex-autokey-year-title-separator'
+ if the title and either name or year are nonempty; and the title part.
+16. If the value of `bibtex-autokey-before-presentation-hook' is non-nil,
+ it must be a function taking one argument. This function is then
+ called with the generated key as the argument. The return value of
+ this function (a string) is 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 used."
(let* ((pnt (point))
(min (bibtex-beginning-of-entry))