bibtex mode: titlecase of authors
- From: Sean <seano@xxxxxxxxxxxxx>
- Date: Sun, 15 Jun 2008 15:53:09 -0700 (PDT)
hi,
This is a bibtex mode question.
Seems likely I'm trying to reinvent the wheel here, so all help
appreciated.
When editing a *.bib file under the excellent bibtex.el mode, I'd like
to have a function [called from the bibtex-clean-entry-hook]
which converts the list of authors into the correct case. The one
attached below works for most cases.
It fails when surnames have an accent
eg, M\"uller gets changed to M\"Uller.
And in general the accented letter is always converted to uppercase,
which is rarely correct.
Presumably the source of the problem lies in how the "capitalize-
region-as-title" function works.
I can add hardwired fixes for each case that happens, but that's an
ugly solution.
So any suggestions for a better/more general "bibtex-authorcase"
function?
Thanks
Sean
(defun bibtex-titlecase-author ()
"Normalize AUTHOR field to have titlecase form.
Called from bibtex-clean-entry-hook"
(interactive)
(goto-char (point-min))
(if (re-search-forward (bibtex-cfield "AUTHOR" bibtex-field-
text) )
;.. THEN
(progn
(capitalize-region-as-title
(match-beginning bibtex-text-in-cfield)
(match-end bibtex-text-in-cfield) )
(goto-char (point-min))
(replace-string ". And" ". and" t) ;.. 3rd-arg
non-nil => need word boundary to match
;.. Handle upcasing after accents: ^"'`~
; hardwired versions:
(replace-string "\\\"U" "\\\"u") ;.. eg, M
\"uller
(replace-string "\\~N" "\\~n") ;.. eg, Acu\~na
;.. Better to do something general.
;.. eg, use downcase \2 somehow (needs emacs version 22):
;; (replace-regexp-eval "\\\([\"^`'~]\)\([A-Z]\)" "\\
\1\,(downcase \2)")
)))
.
- Prev by Date: Re: living without the middle button
- Next by Date: BANKRUPTCY LAWYER
- Previous by thread: Bug about self-insert-command
- Next by thread: BANKRUPTCY LAWYER
- Index(es):