From b5d9e1c8c98872239089a6c02238107d4a51a38b Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 23 May 2020 22:52:50 +0100 Subject: [PATCH] (Emacs Lisp): Use `...?' rather than `\(...\|\)' in regular expressions. --- dot/emacs | 12 ++++---- dot/gnus-local.el.distorted | 6 ++-- el/dot-emacs.el | 68 ++++++++++++++++++++++----------------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/dot/emacs b/dot/emacs index e60294d..bd4d004 100644 --- a/dot/emacs +++ b/dot/emacs @@ -201,7 +201,7 @@ (setq mail-user-agent 'message-user-agent read-mail-command 'gnus) -(setq message-signature-separator "^-- \\(\\|\\[mdw\\]\\)$" +(setq message-signature-separator "^-- \\(\\[mdw\\]\\)?$" message-yank-prefix "> " message-yank-cited-prefix "> " message-send-mail-function 'message-send-mail-with-sendmail @@ -244,14 +244,14 @@ bbdb-user-mail-names (concat "^" "\\(" "\\(mdw\\|markw\\|root\\|postmaster\\)" - "\\([-+][^@]*\\|\\)" + "\\([-+][^@]*\\)?" "@\\(\\(dist\\|esc\\)orted\\.org\\.uk\\|odin\\.gg\\)" "\\|" "\\(" "\\(mdw\\|mwooding\\)" "\\(\\+[^@]*\\)?" "\\|" "0" "\\(mdw\\|mwooding\\)" "k\\.[^@]*" "\\)" "@" "\\(chiark\\|slimy\\|coriolis\\)\\.greenend\\.org\\.uk" - "\\|" "distorted\\.mdw@g\\(\\|oogle\\)mail.com" + "\\|" "distorted\\.mdw@g\\(oogle\\)?mail.com" "\\|" "mwooding@\\(good\\|blackberry\\)\\.com" "\\|" "mark\\.wooding@trustonic\\.com" "\\)$") @@ -891,9 +891,9 @@ ((executable-find "sudo") "sudo") (t "su"))) (this-host (concat "\\`\\(localhost\\|" - (system-name) "\\|\\)\\'")) + (system-name) "\\)?\\'")) (this-user (concat "\\`\\(" (user-login-name) "\\|" - (user-real-login-name) "\\|\\)\\'"))) + (user-real-login-name) "\\)?\\'"))) (setq tramp-default-method-alist `((,this-host nil ,rootlyness) (nil ,this-user "ssh") @@ -938,7 +938,7 @@ (setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *") (setq comint-password-prompt-regexp (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)" - "[Pp]assword\\|[Pp]ass ?phrase\\(\\| [-a-zA-Z0-9._]+\\)\\):") + "[Pp]assword\\|[Pp]ass ?phrase\\( [-a-zA-Z0-9._]+\\)?\\):") comint-file-name-chars "~/A-Za-z0-9+@:_.$#%,={}-" shell-file-name-chars comint-file-name-chars) diff --git a/dot/gnus-local.el.distorted b/dot/gnus-local.el.distorted index 7bfba60..5483fc6 100644 --- a/dot/gnus-local.el.distorted +++ b/dot/gnus-local.el.distorted @@ -36,7 +36,7 @@ "\\|" "evade\\.org\\.uk" "\\|" "fyvzl\\.net" "\\)$") . chiark-smtp) - ("@g\\(\\|oogle\\)mail\\.com$" . gmail-smtp)) + ("@g\\(oogle\\)?mail\\.com$" . gmail-smtp)) mdw-default-send-mail-method nil) ;;;-------------------------------------------------------------------------- @@ -155,7 +155,7 @@ ;; Mailing lists, not split out earlier. (to "python-list@python\\.org" "lists.python") (to ,(concat "\\(jump-\\(announce\\|discuss\\)\\)@" - "\\(lists\\.\\|\\)" "jump\\.net\\.uk") + "\\(lists\\.\\)?" "jump\\.net\\.uk") "lists.\\1") (to "cambridgecryptowhiskyclub@gmail\\.com" "lists.cambridge-crypto-whisky") @@ -188,7 +188,7 @@ ;; Other splits I've not given a per-sender address. (from "@\\(.*\\.\\)?lovefilm\\.com\\>" "crap.lovefilm" t) - (from "@\\(\\|.*\\.\\)amazon\\." "crap.amazon" t) + (from "@\\(.*\\.\\)?amazon\\." "crap.amazon" t) (from "@cineworldmail\\.com\\>" "crap.cineworld" t) (from "@picturehouses\\.co\\.uk\\>" "crap.picturehouse" t) (from "@nationwide" "crap.nationwide" t) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index d477859..8ca49a5 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -100,11 +100,11 @@ This may be at the expense of cool features.") (replace-match with t)))) (with-temp-buffer (insert-file-contents "~/.mdw.conf") - (replace "^[ \t]*\\(#.*\\|\\)\n" "") + (replace "^[ \t]*\\(#.*\\)?\n" "") (replace (concat "^[ \t]*" "\\([-a-zA-Z0-9_.]*\\)" "[ \t]*=[ \t]*" - "\\(.*[^ \t\n]\\|\\)" + "\\(.*[^ \t\n]\\)?" "[ \t]**\\(\n\\|$\\)") "(\\1 . \"\\2\")\n") (car (read-from-string @@ -2225,7 +2225,7 @@ name, as a symbol." ;; Fontify include files as strings. (list (concat "^[ \t]*\\#[ \t]*" "\\(include\\|import\\)" - "[ \t]*\\(<[^>]+\\(>\\|\\)\\)") + "[ \t]*\\(<[^>]+>?\\)") '(2 font-lock-string-face)) ;; Preprocessor directives are `references'?. @@ -2381,8 +2381,8 @@ name, as a symbol." ;; The following isn't quite right, but it's close enough. (list (concat "\\<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)" "[lLfFdD]?") '(0 mdw-number-face)) @@ -2440,8 +2440,8 @@ name, as a symbol." ;; The following isn't quite right, but it's close enough. (list (concat "\\_<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)" "[lLfFdD]?") '(0 mdw-number-face)) @@ -2498,8 +2498,8 @@ name, as a symbol." ;; As usual, not quite right. (list (concat "\\_<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)" "[lLfFdD]?") '(0 mdw-number-face)) @@ -2585,8 +2585,8 @@ name, as a symbol." ;; The following isn't quite right, but it's close enough. (list (concat "\\<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)" "[lLfFdD]?") '(0 mdw-number-face)) @@ -2777,8 +2777,8 @@ name, as a symbol." ;; The following isn't quite right, but it's close enough. (list (concat "\\<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)") + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)") '(0 mdw-number-face)) ;; And anything else is punctuation. @@ -2918,8 +2918,8 @@ name, as a symbol." ;; The following isn't quite right, but it's close enough. (list (concat "\\<\\(" "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" - "[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?\\)" "[uUlL]*") '(0 mdw-number-face)) @@ -2985,8 +2985,8 @@ name, as a symbol." ;; At least numbers are simpler than C. (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" - "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?" + "\\([eE][-+]?[0-9_]+\\)?") '(0 mdw-number-face)) ;; And anything else is punctuation. @@ -3037,8 +3037,8 @@ strip numbers instead." ;; At least numbers are simpler than C. (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO]?[0-7]+\\|[bB][01]+\\)\\|" - "\\_<[0-9][0-9]*\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|[lL]\\|\\)") + "\\_<[0-9][0-9]*\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\|[lL]\\)?") '(0 mdw-number-face)) ;; And anything else is punctuation. @@ -3223,8 +3223,8 @@ strip numbers instead." (setq font-lock-keywords (list (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" - "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?" + "\\([eE][-+]?[0-9_]+\\)?") '(0 mdw-number-face)) (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" '(0 mdw-punct-face))))) @@ -3469,12 +3469,12 @@ strip numbers instead." '(0 font-lock-keyword-face)) ;; At least numbers are simpler than C. - (list (concat "\\<\\(\\~\\|\\)" - "\\(0\\(\\([wW]\\|\\)[xX][0-9a-fA-F]+\\|" + (list (concat "\\<\\~?" + "\\(0\\([wW]?[xX][0-9a-fA-F]+\\|" "[wW][0-9]+\\)\\|" - "\\([0-9]+\\(\\.[0-9]+\\|\\)" - "\\([eE]\\(\\~\\|\\)" - "[0-9]+\\|\\)\\)\\)") + "\\([0-9]+\\(\\.[0-9]+\\)?" + "\\([eE]\\~?" + "[0-9]+\\)?\\)\\)") '(0 mdw-number-face)) ;; And anything else is punctuation. @@ -3559,8 +3559,8 @@ strip numbers instead." (list "\\_<[A-Z]\\(\\sw+\\|\\s_+\\)*\\_>" '(0 font-lock-variable-name-face)) (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO][0-7]+\\)\\|" - "\\_<[0-9]+\\(\\.[0-9]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)") + "\\_<[0-9]+\\(\\.[0-9]*\\)?" + "\\([eE][-+]?[0-9]+\\)?") '(0 mdw-number-face)) (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" '(0 mdw-punct-face)))))) @@ -3597,7 +3597,7 @@ strip numbers instead." '(0 font-lock-keyword-face)) (list (concat "^-\\sw+\\>") '(0 font-lock-keyword-face)) - (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>" + (list "\\<[0-9]+\\(#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)?\\>" '(0 mdw-number-face)) (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" '(0 mdw-punct-face)))))) @@ -3629,7 +3629,7 @@ strip numbers instead." '(2 font-lock-variable-name-face)) ;; Make sure we get comments properly. - (list "@c\\(\\|omment\\)\\( .*\\)?$" + (list "@c\\(omment\\)?\\( .*\\)?$" '(0 font-lock-comment-face)) ;; Command names are keywords. @@ -4067,7 +4067,7 @@ that character only to be normal punctuation.") (setq messages-mode-keywords (append (list (list (concat "^[ \t]*\\#[ \t]*" "\\(include\\|import\\)" - "[ \t]*\\(<[^>]+\\(>\\|\\)\\)") + "[ \t]*\\(<[^>]+\\(>\\)?\\)") '(2 font-lock-string-face)) (list (concat "^\\([ \t]*#[ \t]*\\(\\(" preprocessor-keywords @@ -4113,7 +4113,7 @@ that character only to be normal punctuation.") (list (list (concat "^%\\s *\\(}\\|\\(" keywords "\\)\\>\\).*$") '(0 font-lock-keyword-face)) - (list "^%\\s *\\(#.*\\|\\)$" + (list "^%\\s *\\(#.*\\)?$" '(0 font-lock-comment-face)) (list "^%" '(0 font-lock-keyword-face)) @@ -4297,8 +4297,8 @@ that character only to be normal punctuation.") (list "\\<[A-Z][a-zA-Z0-9]*\\>" '(0 font-lock-keyword-face)) (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" - "[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" - "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + "[0-9][0-9_]*\\(\\.[0-9_]*\\)?" + "\\([eE][-+]?[0-9_]+\\)?") '(0 mdw-number-face)) (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" '(0 mdw-punct-face))))) -- 2.11.0