diff options
author | Ryan Kavanagh <rak@debian.org> | 2020-02-23 11:48:57 -0500 |
---|---|---|
committer | Ryan Kavanagh <rak@debian.org> | 2020-02-23 11:48:57 -0500 |
commit | 1d3180d346e1f47a92964eab546099b7f5fbc9a1 (patch) | |
tree | 5e866dc25616844775be17d3c32c277b3f7e33dd /.emacs | |
parent | defer loading gnus (diff) |
patch bibtex-autokey-demangle-name to handle mac lane
Diffstat (limited to '.emacs')
-rw-r--r-- | .emacs | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -117,6 +117,41 @@ ;; Make all title words lowercase (bibtex-autokey-preserve-case 1) :config + ;; stolen from bibtex.el and modified to handle "Mac Lane" + (defun bibtex-autokey-demangle-name (fullname) + "Get the last part from a well-formed FULLNAME and perform abbreviations." + (let* (case-fold-search + (name (cond ((string-match "\\(Ma?c +[[:upper:]][^, ]*\\)[^,]*," fullname) + ;; Name is of the form "Mac Last, First" or + ;; "Mac Last, Jr, First" or "Mc Last, First" or + ;; "Mc Last, Jr, First" + ;; --> Take Mac Last or Mc Last, as appropriate + ;; and replace spaces by concatenation + (let ((mclast (match-string 1 fullname))) + (when (string-match split-string-default-separators mclast) + (replace-match "" nil nil mclast))) + ((string-match "\\([[:upper:]][^, ]*\\)[^,]*," fullname) + ;; Name is of the form "von Last, First" or + ;; "von Last, Jr, First" + ;; --> Take the first capital part before the comma + (match-string 1 fullname)) + ((string-match "\\([^, ]*\\)," fullname) + ;; Strange name: we have a comma, but nothing capital + ;; So we accept even lowercase names + (match-string 1 fullname)) + ((string-match "\\(\\<[[:lower:]][^ ]* +\\)+\\([[:upper:]][^ ]*\\)" + fullname) + ;; name is of the form "First von Last", "von Last", + ;; "First von von Last", or "d'Last" + ;; --> take the first capital part after the "von" parts + (match-string 2 fullname)) + ((string-match "\\([^ ]+\\) *\\'" fullname) + ;; name is of the form "First Middle Last" or "Last" + ;; --> take the last token + (match-string 1 fullname)) + (t (error "Name `%s' is incorrectly formed" fullname))))) + (funcall bibtex-autokey-name-case-convert-function + (bibtex-autokey-abbrev name bibtex-autokey-name-length))))) ;; Until https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36252 gets fixed (defun bibtex-autokey-get-year () "Return year field contents as a string obeying `bibtex-autokey-year-length'. |