From cb1877321b8a04cdb9b890d76d99a9f5a7ed5bce Mon Sep 17 00:00:00 2001 From: Roland Winkler Date: Fri, 6 Mar 2020 09:37:55 +0100 Subject: [PATCH] Use regexp-opt to define bibtex-autokey-transcriptions. (Bug#39686) --- lisp/textmodes/bibtex.el | 50 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index a7be57e5a3f..670e763814c 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -1006,32 +1006,36 @@ See `bibtex-generate-autokey' for details." :type 'boolean) (defvar bibtex-autokey-transcriptions - '(;; language specific characters - ("\\\\aa" . "a") ; \aa -> a - ("\\\\AA" . "A") ; \AA -> A - ("\\\"a\\|\\\\\\\"a\\|\\\\ae" . "ae") ; "a,\"a,\ae -> ae - ("\\\"A\\|\\\\\\\"A\\|\\\\AE" . "Ae") ; "A,\"A,\AE -> Ae - ("\\\\i" . "i") ; \i -> i - ("\\\\j" . "j") ; \j -> j - ("\\\\l" . "l") ; \l -> l - ("\\\\L" . "L") ; \L -> L - ("\\\"o\\|\\\\\\\"o\\|\\\\o\\|\\\\oe" . "oe") ; "o,\"o,\o,\oe -> oe - ("\\\"O\\|\\\\\\\"O\\|\\\\O\\|\\\\OE" . "Oe") ; "O,\"O,\O,\OE -> Oe - ("\\\"s\\|\\\\\\\"s\\|\\\\3" . "ss") ; "s,\"s,\3 -> ss - ("\\\"u\\|\\\\\\\"u" . "ue") ; "u,\"u -> ue - ("\\\"U\\|\\\\\\\"U" . "Ue") ; "U,\"U -> Ue - ;; accents - ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "") - ;; braces, quotes, concatenation. - ("[`'\"{}#]" . "") - ("\\\\-" . "") ; \- -> - ;; spaces - ("\\\\?[ \t\n]+\\|~" . " ")) + (nconc + (mapcar (lambda (a) (cons (regexp-opt (car a)) (cdr a))) + '(;; language specific characters + (("\\aa") . "a") ; \aa -> a + (("\\AA") . "A") ; \AA -> A + (("\"a" "\\\"a" "\\ae") . "ae") ; "a,\"a,\ae -> ae + (("\"A" "\\\"A" "\\AE") . "Ae") ; "A,\"A,\AE -> Ae + (("\\i") . "i") ; \i -> i + (("\\j") . "j") ; \j -> j + (("\\l") . "l") ; \l -> l + (("\\L") . "L") ; \L -> L + (("\"o" "\\\"o" "\\o" "\\oe") . "oe") ; "o,\"o,\o,\oe -> oe + (("\"O" "\\\"O" "\\O" "\\OE") . "Oe") ; "O,\"O,\O,\OE -> Oe + (("\"s" "\\\"s" "\\3") . "ss") ; "s,\"s,\3 -> ss + (("\"u" "\\\"u") . "ue") ; "u,\"u -> ue + (("\"U" "\\\"U") . "Ue") ; "U,\"U -> Ue + ;; hyphen, accents + (("\\-" "\\`" "\\'" "\\^" "\\~" "\\=" "\\." "\\u" "\\v" + "\\H" "\\t" "\\c" "\\d" "\\b") . "") + ;; space + (("~") . " "))) + ;; more spaces + '(("[\s\t\n]*\\(?:\\\\\\)?[\s\t\n]+" . " ") + ;; braces, quotes, concatenation. + ("[`'\"{}#]" . ""))) "Alist of (OLD-REGEXP . NEW-STRING) pairs. -Used by the default values of `bibtex-autokey-name-change-strings' and +Used as default values of `bibtex-autokey-name-change-strings' and `bibtex-autokey-titleword-change-strings'. Defaults to translating some language specific characters to their ASCII transcriptions, and -removing any character accents.") +removing any accent characters.") (defcustom bibtex-autokey-name-change-strings bibtex-autokey-transcriptions -- 2.39.2