unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Scan of regexp mistakes
@ 2019-03-03 18:01 Mattias Engdegård
  2019-03-05  2:04 ` Paul Eggert
  0 siblings, 1 reply; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-03 18:01 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

Here is a sweep of potential mistakes in regexp strings in elisp code in the Emacs tree: obsolete syntax, questionable constructs, and so on.

Most of the warnings are harmless, but some look like outright bugs. Perhaps those with knowledge of the code would be interested in taking a look. Some of the cases are quite entertaining.

The errors were gathered by the rather hacky trawl.el, attached (in case you want to run it on other code). It only requires xr (1.4 or later). To use, run trawl-directory or trawl-file.


[-- Attachment #2: trawl.log --]
[-- Type: application/octet-stream, Size: 26979 bytes --]

;; Trawling ~/emacs  -*- compilation -*-
emacs/admin/admin.el:91: In call to re-search-forward: Unescaped literal `+' (pos 3): "^\\(+++ *\\|--- *\\)$"
emacs/admin/admin.el:91: In call to re-search-forward: Repetition of repetition (pos 5): "^\\(+++ *\\|--- *\\)$"
emacs/lisp/calc/calc-graph.el:1074: In call to re-search-backward: Escaped non-special character `}' (pos 7): ":\\(.*\\)\\}"
emacs/lisp/calc/calc-graph.el:1181: In call to looking-at: Unescaped literal `*' (pos 0): "*"
emacs/lisp/calc/calc-help.el:140: In call to string-match: Escaped non-special character `L' (pos 7): "\\(DEL\\|\\LFD\\|RET\\|SPC\\|TAB\\)"
emacs/lisp/calc/calc-lang.el:740: In call to string-match: Escaped non-special character `h' (pos 0): "\\hbox{"
emacs/lisp/calc/calc-lang.el:740: In call to string-match: Escaped non-special character `t' (pos 0): "\\text{"
emacs/lisp/calc/calc-lang.el:1129: In call to string-match: Unescaped literal `+' (pos 8): "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^"
emacs/lisp/calc/calc.el:2392: In call to looking-at: Unescaped literal `+' (pos 0): "+"
emacs/lisp/cedet/ede/makefile-edit.el:98: In call to re-search-forward: Repetition of repetition (pos 4): "\\s-**\\([-a-zA-Z0-9./_@$%(){}]+\\)\\s-*"
emacs/lisp/cedet/ede/speedbar.el:274: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/cedet/semantic/sb.el:279: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/cedet/semantic/sb.el:325: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/emacs-lisp/chart.el:698: In call to re-search-forward: Escaped non-special character `-' (pos 0): "\\-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+"
emacs/lisp/emacs-lisp/eieio-opt.el:327: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/emacs-lisp/eieio-speedbar.el:348: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/emacs-lisp/rx.el:607: In call to string-match: Unescaped literal `^' (pos 4): "\\`\\[^"
emacs/lisp/emacs-lisp/rx.el:759: In call to string-match: Unescaped literal `^' (pos 4): "\\`\\[^?]?\\(?:\\[:[a-z]+:]\\|[^]]\\)*\\]\\'"
emacs/lisp/emulation/viper-ex.el:399: In call to looking-at: Unescaped literal `+' (pos 0): "+[-+]"
emacs/lisp/emulation/viper-ex.el:399: In call to looking-at: Unescaped literal `+' (pos 0): "+[\n|]"
emacs/lisp/emulation/viper-ex.el:399: In call to looking-at: Unescaped literal `+' (pos 0): "+[0-9]"
emacs/lisp/emulation/viper-ex.el:399: In call to looking-back: Duplicated `\' inside character alternative (pos 3): "[^\\\\]\\(\\\\\\\\\\)*\\\\/"
emacs/lisp/emulation/viper-ex.el:399: In call to looking-back: Duplicated `\' inside character alternative (pos 3): "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"
emacs/lisp/emulation/viper-ex.el:730: In call to looking-at: Duplicated `\' inside character alternative (pos 3): "[^\\\\\n]"
emacs/lisp/emulation/viper-ex.el:1673: In call to string-match: Duplicated `\' inside character alternative (pos 5): "^[ \\t\\n]*$"
emacs/lisp/erc/erc-speedbar.el:142: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/erc/erc-speedbar.el:184: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/erc/erc-speedbar.el:287: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/erc/erc.el:4285: In call to string-match: Escaped non-special character `A' (pos 2): "^\001\\ACTION.*\001$"
emacs/lisp/erc/erc.el:4472: In call to string-match: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/eshell/em-dirs.el:272: In call to looking-at: Duplicated `\' inside character alternative (pos 19): "\\([A-Za-z]:\\)\\([^/\\\\]\\|\\'\\)"
emacs/lisp/eshell/em-dirs.el:303: In call to string-match: Duplicated `\' inside character alternative (pos 13): "\\`[A-Za-z]:[\\\\/]\\'"
emacs/lisp/gnus/gnus-art.el:7380: In gnus-button-valid-localpart-regexp: Ranges `*-=' and `0-9' overlap (pos 10): "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
emacs/lisp/gnus/gnus.el:3735: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/gnus/message.el:1279: In call to looking-at: Duplicated `\' inside character alternative (pos 37): "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"
emacs/lisp/international/mule.el:2532: In call to re-search-forward: Reversed range `s-/' matches nothing (pos 101): "<meta\\s-+\\(http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*\\)?charset=[\"']?\\(.+?\\)[\"'\\s-/>]"
emacs/lisp/language/ethio-util.el:785: In call to re-search-forward: Duplicated `\' inside character alternative (pos 7): "\\ce[\273\\.\\?]\\|\253\\ce"
emacs/lisp/mail/rmail.el:2567: In call to looking-at: Unescaped literal `?' (pos 0): "?D"
emacs/lisp/mh-e/mh-alias.el:326: In call to string-match: Character `_' included in range `A-z' (pos 32): "^\\([-a-zA-Z0-9._]+\\)@[-a-zA-z0-9_]+\\.+[a-zA-Z0-9]+$"
emacs/lisp/mh-e/mh-comp.el:552: In call to re-search-forward: Unescaped literal `+' (pos 23): "^#forw \\[\\([^]]+\\)\\] \\(+\\S-+\\) \\(.*\\)$"
emacs/lisp/mh-e/mh-search.el:487: In call to re-search-backward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/mh-e/mh-search.el:487: In call to re-search-forward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/mh-e/mh-search.el:487: In call to re-search-backward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/mh-e/mh-search.el:487: In call to re-search-forward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/mh-e/mh-search.el:1425: In call to re-search-forward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/mh-e/mh-xface.el:190: In call to string-match: Unescaped literal `+' (pos 11): "\\([^+]*\\)\\(+.*\\)?@\\(.*\\)"
emacs/lisp/net/ange-ftp.el:2692: In call to string-match: Unescaped literal `*' (pos 0): "*\\'"
emacs/lisp/net/goto-addr.el:99: In goto-address-mail-regexp: Character `_' included in range `A-z' (pos 31): "[-a-zA-Z0-9=._+]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
emacs/lisp/net/goto-addr.el:245: In call to re-search-backward: Character `_' included in range `A-z' (pos 4): "[^-_A-z0-9.@]"
emacs/lisp/net/pop3.el:573: In call to looking-at: Unescaped literal `+' (pos 0): "+OK"
emacs/lisp/net/pop3.el:683: In call to string-match: Unescaped literal `+' (pos 0): "+OK"
emacs/lisp/net/pop3.el:690: In call to string-match: Unescaped literal `+' (pos 0): "+OK"
emacs/lisp/net/pop3.el:697: In call to string-match: Unescaped literal `+' (pos 0): "+OK"
emacs/lisp/net/tramp.el:873: In tramp-ipv6-regexp: Repetition of repetition (pos 22): "\\(?:\\(?:[a-zA-Z0-9]+\\)?:\\)+[a-zA-Z0-9.]+"
emacs/lisp/net/tramp.el:2082: In call to string-match: Unescaped literal `$' (pos 0): "$\\(\\w+\\)"
emacs/lisp/nxml/nxml-maint.el:32: In call to re-search-forward: Reversed range `a-F' matches nothing (pos 6): "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+"
emacs/lisp/nxml/nxml-maint.el:32: In call to re-search-forward: Reversed range `a-F' matches nothing (pos 3): "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)"
emacs/lisp/nxml/nxml-maint.el:32: In call to re-search-forward: Reversed range `a-F' matches nothing (pos 24): "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)"
emacs/lisp/nxml/nxml-maint.el:32: In call to re-search-forward: Reversed range `a-F' matches nothing (pos 46): "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)"
emacs/lisp/nxml/rng-uri.el:43: In call to replace-regexp-in-string: Duplicated `n' inside character alternative (pos 4): "[:nonascii:]"
emacs/lisp/nxml/rng-uri.el:43: In call to replace-regexp-in-string: Duplicated `i' inside character alternative (pos 9): "[:nonascii:]"
emacs/lisp/nxml/rng-uri.el:43: In call to replace-regexp-in-string: Duplicated `:' inside character alternative (pos 10): "[:nonascii:]"
emacs/lisp/nxml/rng-xsd.el:362: In call to string-match: Repetition of repetition (pos 38): "\\`\\(?:[^%]\\|%[0-9a-fA-F][0-9a-fA-F]\\)?*\\'"
emacs/lisp/obsolete/pgg.el:570: In call to string-match: Duplicated `\' inside character alternative (pos 10): "^[a-zA-Z\\+\\.\\\\-]+:"
emacs/lisp/obsolete/pgg.el:570: In call to string-match: Duplicated `\' inside character alternative (pos 13): "^[a-zA-Z\\+\\.\\\\-]+:"
emacs/lisp/obsolete/vip.el:2163: In call to looking-at: Unescaped literal `+' (pos 0): "+"
emacs/lisp/obsolete/vip.el:2163: In call to looking-at: Unescaped literal `+' (pos 0): "+[-+]"
emacs/lisp/obsolete/vip.el:2163: In call to looking-at: Unescaped literal `+' (pos 0): "+[\n|]"
emacs/lisp/obsolete/vip.el:2163: In call to looking-at: Unescaped literal `+' (pos 0): "+[0-9]"
emacs/lisp/obsolete/vip.el:2504: In call to looking-at: Unescaped literal `+' (pos 0): "+"
emacs/lisp/org/ob-core.el:2955: In call to string-match: Escaped non-special character `"' (pos 0): "\\\"\\(.+\\)\\\""
emacs/lisp/org/ob-core.el:2955: In call to string-match: Escaped non-special character `"' (pos 8): "\\\"\\(.+\\)\\\""
emacs/lisp/org/org-agenda.el:9437: In call to re-search-forward: Unescaped literal `*' (pos 1): "^*[ \t]+Anniversaries"
emacs/lisp/org/org-element.el:2105: In call to looking-at: Repetition of repetition (pos 14): "[ \t]*#\\+\\(\\S-+*\\):"
emacs/lisp/org/org-list.el:2625: In call to string-match: Unescaped literal `*' (pos 0): "*"
emacs/lisp/org/org-mhe.el:141: In call to re-search-forward: Unescaped literal `+' (pos 3): "^\\(+.*\\)$"
emacs/lisp/org/org-mobile.el:773: In call to re-search-forward: Unescaped literal `*' (pos 1): "^** Old value[ \t]*$"
emacs/lisp/org/org-mobile.el:773: In call to re-search-forward: Unescaped literal `*' (pos 1): "^** New value[ \t]*$"
emacs/lisp/org/org-mouse.el:620: In call to looking-at: Unescaped literal `+' (pos 11): "\\(  \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$"
emacs/lisp/org/org-plot.el:273: In call to re-search-forward: Unescaped literal `$' (pos 0): "$datafile"
emacs/lisp/org/org-protocol.el:306: In call to string-match: Ranges `A-z' and `a-z' overlap (pos 28): "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)"
emacs/lisp/org/org-protocol.el:306: In call to string-match: Character `_' included in range `A-z' (pos 41): "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)"
emacs/lisp/org/org-table.el:1120: In call to string-match: Repetition of repetition (pos 21): "\\([-+]\\)?\\(?:[0-9]+\\)?\\(?:.[0-9]+\\)?"
emacs/lisp/org/org-table.el:2309: In call to string-match: Unescaped literal `$' (pos 2): "\\`$[<>]"
emacs/lisp/org/org-table.el:2335: In call to string-match-p: Unescaped literal `$' (pos 2): "\\`$\\([0-9]+\\|[<>]+\\)\\'"
emacs/lisp/org/org-table.el:3178: In call to string-match: Unescaped literal `$' (pos 2): "\\`$[<>]"
emacs/lisp/org/org-table.el:3605: In call to string-match: Unescaped literal `$' (pos 2): "\\`$\\([0-9]+\\|[<>]+\\)\\'"
emacs/lisp/org/org.el:10456: In call to string-match: Repetition of repetition (pos 7): "^//\\(.?*\\)/\\(<.*>\\)$"
emacs/lisp/org/org.el:22836: In call to looking-at: Duplicated `\' inside character alternative (pos 12): "\\\\\\\\\\($\\|[^\\\\]\\)"
emacs/lisp/org/ox-ascii.el:1442: In call to replace-regexp-in-string: Unescaped literal `+' (pos 0): "+"
emacs/lisp/org/ox-ascii.el:1442: In call to replace-regexp-in-string: Unescaped literal `*' (pos 0): "*"
emacs/lisp/org/ox-latex.el:1614: In call to replace-regexp-in-string: Escaped non-special character `e' (pos 2): "\\(\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$"
emacs/lisp/org/ox.el:3270: In call to string-match: Repetition of repetition (pos 23): ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
emacs/lisp/org/ox.el:3270: In call to string-match: Repetition of repetition (pos 37): ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
emacs/lisp/progmodes/ada-xref.el:411: In call to string-match: Unescaped literal `$' (pos 18): "\\(-[^-$IO]*[IO]\\)?${\\([^}]+\\)}"
emacs/lisp/progmodes/cc-awk.el:133: In c-awk-harmless-char-re: Duplicated `\' inside character alternative (pos 12): "[^_#/\"{}();\\\\\n\r]"
emacs/lisp/progmodes/cc-awk.el:144: In c-awk-harmless-line-char-re: Duplicated `\' inside character alternative (pos 7): "[^_#/\"\\\\\n\r]"
emacs/lisp/progmodes/cc-awk.el:253: In c-awk-_-harmless-nonws-char-re: Duplicated `\' inside character alternative (pos 6): "[^#/\"\\\\\n\r \t]"
emacs/lisp/progmodes/cc-engine.el:5064: In call to looking-at: Unescaped literal `*' (pos 0): "*/"
emacs/lisp/progmodes/cc-mode.el:1270: In call to looking-at: Escaped non-special character `\r' (pos 11): "\\(\\\\\\(.\\|\n|\\\r\\)\\|[^\"]\\)*"
emacs/lisp/progmodes/cfengine.el:845: In cfengine2-font-lock-keywords: Unescaped literal `$' (pos 0): "$(\\([[:alnum:]_]+\\))"
emacs/lisp/progmodes/cfengine.el:845: In cfengine2-font-lock-keywords: Unescaped literal `$' (pos 0): "${\\([[:alnum:]_]+\\)}"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 17): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 26): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 39): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 48): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 17): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
emacs/lisp/progmodes/cperl-mode.el:3115: In call to re-search-forward: Duplicated `\' inside character alternative (pos 26): "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
emacs/lisp/progmodes/cperl-mode.el:3555: In call to looking-at: Escaped non-special character `e' (pos 7): "\\(cut\\|\\end\\)\\>"
emacs/lisp/progmodes/cperl-mode.el:3555: In call to re-search-forward: Escaped non-special character `e' (pos 10): "^\n=\\(cut\\|\\end\\)\\>"
emacs/lisp/progmodes/cperl-mode.el:3555: In call to re-search-forward: Escaped non-special character `e' (pos 9): "\n=\\(cut\\|\\end\\)\\>"
emacs/lisp/progmodes/cperl-mode.el:4953: In call to looking-at: Escaped non-special character `e' (pos 16): "[ \t]*}?[ \t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]"
emacs/lisp/progmodes/cperl-mode.el:4953: In call to looking-at: Escaped non-special character `e' (pos 20): "[ \t]*\\(}[ \t]*\\)?\\<\\(\\els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([ \t]+\\(state\\|my\\|local\\|our\\)\\)?[ \t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{"
emacs/lisp/progmodes/cperl-mode.el:7363: In call to re-search-backward: Character `-' included in range `,-.' (pos 17): "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
emacs/lisp/progmodes/cperl-mode.el:7363: In call to re-search-backward: Duplicated `\' inside character alternative (pos 26): "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
emacs/lisp/progmodes/cperl-mode.el:7363: In call to looking-at: Character `-' included in range `,-.' (pos 6): "[-!&*+,-./<=>?\\\\^|~]"
emacs/lisp/progmodes/cperl-mode.el:7363: In call to looking-at: Duplicated `\' inside character alternative (pos 15): "[-!&*+,-./<=>?\\\\^|~]"
emacs/lisp/progmodes/cperl-mode.el:8119: In call to re-search-forward: Duplicated `\' inside character alternative (pos 9): "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*[ \t\n#]"
emacs/lisp/progmodes/dcl-mode.el:1577: In call to re-search-forward: Unescaped literal `$' (pos 1): "^$[ \t]*"
emacs/lisp/progmodes/etags.el:1641: In call to looking-at: Repetition of repetition (pos 23): "[ \t()=,;]?\177\\(?:[0-9]+\\)?,\\(?:[0-9]+\\)?$"
emacs/lisp/progmodes/etags.el:1641: In call to looking-at: Repetition of repetition (pos 37): "[ \t()=,;]?\177\\(?:[0-9]+\\)?,\\(?:[0-9]+\\)?$"
emacs/lisp/progmodes/fortran.el:1991: In call to re-search-forward: Character `,' included in range `+-/' (pos 5): "[\t\n,'+-/*)=]"
emacs/lisp/progmodes/gdb-mi.el:1371: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/gdb-mi.el:4146: In call to string-match: Escaped non-special character `0' (pos 0): "\\0x"
emacs/lisp/progmodes/grep.el:455: In grep-mode-font-lock-keywords: Ranges `A-z' and `a-z' overlap (pos 10): "^Grep[/a-zA-z]* started.*"
emacs/lisp/progmodes/grep.el:455: In grep-mode-font-lock-keywords: Ranges `A-z' and `a-z' overlap (pos 10): "^Grep[/a-zA-z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?matches found\\)\\|\\(no matches found\\)\\).*"
emacs/lisp/progmodes/grep.el:455: In grep-mode-font-lock-keywords: Ranges `A-z' and `a-z' overlap (pos 10): "^Grep[/a-zA-z]* \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*"
emacs/lisp/progmodes/gud.el:2226: In call to string-match: Unescaped literal `$' (pos 0): "$.*"
emacs/lisp/progmodes/js.el:1819: In call to looking-at: Unescaped literal `+' (pos 0): "+\\+\\|--\\|/[/*]"
emacs/lisp/progmodes/m4-mode.el:65: In m4-font-lock-keywords: Escaped non-special character `@' (pos 2): "\\$\\@"
emacs/lisp/progmodes/meta-mode.el:662: In call to re-search-forward: Duplicated `\' inside character alternative (pos 3): "[^\\\\\"]%\\|\n\\|\\'"
emacs/lisp/progmodes/mixal-mode.el:1039: In mixal-font-lock-keywords: Reversed range `O-9' matches nothing (pos 22): "^[A-Z0-9a-z]*[ \t]+[A-ZO-9a-z]+[ \t]+\\(=.*=\\)"
emacs/lisp/progmodes/opascal.el:1512: In call to string-match: Duplicated `\' inside character alternative (pos 9): "^\\(.+\\)[\\\\/]$"
emacs/lisp/progmodes/pascal.el:120: In pascal-progbeg-re: Escaped non-special character `p' (pos 2): "\\<\\program\\>"
emacs/lisp/progmodes/ruby-mode.el:105: In ruby-expression-expansion-re: Duplicated `\' inside character alternative (pos 34): "\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z \n]\\)\\)"
emacs/lisp/progmodes/ruby-mode.el:105: In ruby-expression-expansion-re: Duplicated `\' inside character alternative (pos 47): "\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z \n]\\)\\)"
emacs/lisp/progmodes/ruby-mode.el:897: In call to looking-at: Character `_' included in range `A-z' (pos 18): "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"
emacs/lisp/progmodes/ruby-mode.el:897: In call to looking-at: Character `_' included in range `A-z' (pos 18): "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"
emacs/lisp/progmodes/ruby-mode.el:981: In call to looking-at: Unescaped literal `?' (pos 0): "?\\(\\\\C-\\|\\\\M-\\)*\\\\?."
emacs/lisp/progmodes/ruby-mode.el:1785: In call to replace-regexp-in-string: Duplicated `\' inside character alternative (pos 9): "\\(\\`\\|[^\\\\]\\)'"
emacs/lisp/progmodes/ruby-mode.el:1785: In call to replace-regexp-in-string: Duplicated `\' inside character alternative (pos 9): "\\(\\`\\|[^\\\\]\\)\""
emacs/lisp/progmodes/ruby-mode.el:2033: In ruby-font-lock-keywords: Duplicated `\' inside character alternative (pos 19): "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|\\(?:ARGV\\|C\\(?:HILD_STATUS\\|LASSPATH\\)\\|DE\\(?:BUG\\|FAULT_\\(?:\\(?:IN\\|OUT\\)PUT\\)\\)\\|E\\(?:NV_JAVA\\|RROR_\\(?:INFO\\|POSITION\\)\\)\\|F\\(?:I\\(?:ELD_SEPARATOR\\|LENAME\\)\\|S\\)\\|I\\(?:GNORECASE\\|NPUT_\\(?:\\(?:LINE_NUMBE\\|RECORD_SEPARATO\\)R\\)\\)\\|JRUBY_\\(?:\\(?:REVI\\|VER\\)SION\\)\\|L\\(?:AST_\\(?:MATCH_INFO\\|PAREN_MATCH\\|READ_LINE\\)\\|OAD\\(?:ED_FEATURES\\|_PATH\\)\\)\\|MATCH\\|NR\\|O\\(?:FS\\|RS\\|UTPUT_\\(?:\\(?:FIEL\\|RECOR\\)D_SEPARATOR\\)\\)\\|P\\(?:ID\\|OSTMATCH\\|R\\(?:EMATCH\\|O\\(?:CESS_ID\\|GRAM_NAME\\)\\)\\)\\|RS\\|SAFE\\|VERBOSE\\|std\\(?:err\\|in\\|out\\)\\)\\_>\\)"
emacs/lisp/progmodes/sql.el:3224: In call to string-match: Duplicated `\' inside character alternative (pos 11): "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*$"
emacs/lisp/progmodes/sql.el:3224: In call to string-match: Duplicated `\' inside character alternative (pos 15): "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*$"
emacs/lisp/progmodes/sql.el:3224: In call to string-match: Duplicated `\' inside character alternative (pos 11): "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*$"
emacs/lisp/progmodes/sql.el:3224: In call to string-match: Duplicated `\' inside character alternative (pos 15): "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*$"
emacs/lisp/progmodes/verilog-mode.el:2789: In verilog-coverpoint-re: Error: Unknown syntax code ‘*’: "\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)"
emacs/lisp/progmodes/verilog-mode.el:6541: In call to looking-at: Escaped non-special character `/' (pos 0): "\\/\\*"
emacs/lisp/progmodes/verilog-mode.el:8936: In call to looking-at: Duplicated `\' inside character alternative (pos 21): "\\s-*[a-zA-Z0-9`_$({}\\\\][^,]*"
emacs/lisp/progmodes/verilog-mode.el:9315: In call to looking-at: Reversed range `|--' matches nothing (pos 29): "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)"
emacs/lisp/progmodes/vhdl-mode.el:2475: In call to string-match: Unescaped literal `$' (pos 6): "\\(.*\\)${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)"
emacs/lisp/progmodes/vhdl-mode.el:15115: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/vhdl-mode.el:15137: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/vhdl-mode.el:15206: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/vhdl-mode.el:15266: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/vhdl-mode.el:15324: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/progmodes/vhdl-mode.el:15730: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/textmodes/dns-mode.el:116: In dns-mode-font-lock-keywords: Unescaped literal `$' (pos 1): "^$[a-z0-9A-Z]+"
emacs/lisp/textmodes/flyspell.el:907: In call to looking-at: Escaped non-special character `-' (pos 0): "\\-"
emacs/lisp/textmodes/flyspell.el:907: In call to looking-at: Escaped non-special character `-' (pos 0): "\\-"
emacs/lisp/textmodes/ispell.el:3398: In call to string-match: Duplicated `\' inside character alternative (pos 2): "[\\\\][]()[]\\|\\\\begin\\|\\$"
emacs/lisp/textmodes/reftex-cite.el:169: In call to re-search-forward: Escaped non-special character `e' (pos 11): "\\\\bibitem\\|\\end{thebibliography}"
emacs/lisp/textmodes/reftex-cite.el:442: In call to string-match: Duplicated `\' inside character alternative (pos 9): "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+"
emacs/lisp/textmodes/reftex-ref.el:307: In call to string-match: Escaped non-special character `%' (pos 0): "\\%\\([a-zA-Z]\\)"
emacs/lisp/url/url-parse.el:111: In call to looking-at: Unescaped literal `?' (pos 0): "?"
emacs/lisp/url/url-util.el:496: In call to string-match: Unescaped literal `?' (pos 0): "?"
emacs/lisp/vc/diff-mode.el:974: In call to re-search-forward: Unescaped literal `+' (pos 1): "^+"
emacs/lisp/vc/vc-bzr.el:334: In vc-bzr-error-regexp-alist: Unescaped literal `+' (pos 11): "^\\( M[* ]\\|+N \\|-D \\|\\|  \\*\\|R[M ] \\) \\(.+\\)"
emacs/lisp/vc/vc-cvs.el:906: In call to looking-at: Unescaped literal `?' (pos 0): "? \\(.*\\)"
emacs/lisp/allout.el:5759: In call to string-match: Escaped non-special character `e' (pos 0): "\\end{verbatim}"
emacs/lisp/arc-mode.el:1536: In call to string-match: Duplicated `\' inside character alternative (pos 3): "[:\\\\/]"
emacs/lisp/arc-mode.el:2008: In call to re-search-forward: Repetition of repetition (pos 9): "^\\( +=+ ?+\\)+\n"
emacs/lisp/comint.el:3086: In call to string-match: Duplicated `\' inside character alternative (pos 6): "%\\([^\\\\/]*\\)%"
emacs/lisp/dired.el:328: In dired-re-inode-size: Duplicated ` ' inside character alternative (pos 5): "[0-9  \t]*[.,0-9]*[BkKMGTPEZY]?[ \t]*"
emacs/lisp/epg.el:1145: In call to string-match: Reversed range `a-F' matches nothing (pos 43): "\\`\\([DCS]\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9A-Fa-F][0-9A-Fa-F]\\) \\(.*\\) "
emacs/lisp/epg.el:1145: In call to string-match: Reversed range `a-F' matches nothing (pos 54): "\\`\\([DCS]\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9A-Fa-F][0-9A-Fa-F]\\) \\(.*\\) "
emacs/lisp/find-dired.el:129: In call to string-match: Unescaped literal `+' (pos 19): "\\`\\(.*\\) {} \\(\\\\;\\|+\\)\\'"
emacs/lisp/frame.el:1061: In call to string-match: Escaped non-special character `r' (pos 10): "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)"
emacs/lisp/generic-x.el:291: In define-generic-mode apache-log-generic-mode: Ranges `A-z' and `a-z' overlap (pos 8): "^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
emacs/lisp/ibuffer.el:152: In call to string-match: Unescaped literal `*' (pos 1): "^*"
emacs/lisp/ido.el:3779: In call to string-match: Unescaped literal `$' (pos 0): "$\\'"
emacs/lisp/ido.el:3779: In call to string-match: Unescaped literal `$' (pos 0): "$\\'"
emacs/lisp/info-xref.el:71: In call to string-match: Escaped non-special character `/' (pos 6): "\\(\\`\\|\\/\\)\\.#"
emacs/lisp/info.el:1483: In call to re-search-forward: Unescaped literal `*' (pos 1): "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
emacs/lisp/info.el:1601: In call to string-match: Duplicated `\' inside character alternative (pos 14): "[^\\\"]*\\(\\\\\\)[\\\\\"]"
emacs/lisp/info.el:1613: In call to string-match: Duplicated `\' inside character alternative (pos 54): "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
emacs/lisp/info.el:5202: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/isearch.el:2828: In call to string-match-p: Unescaped literal `^' (pos 1): "^^"
emacs/lisp/minibuffer.el:2310: In completion--embedded-envvar-re: Unescaped literal `$' (pos 24): "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"
emacs/lisp/speedbar.el:3351: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/speedbar.el:3400: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/speedbar.el:3442: In call to string-match: Unescaped literal `+' (pos 0): "+"
emacs/lisp/woman.el:2617: In call to looking-at: Error: Invalid \{\} syntax: "[ \t]*\\{"
emacs/lisp/woman.el:2631: In call to looking-at: Error: Invalid \{\} syntax: "[ \t]*\\{"
emacs/lisp/woman.el:3258: In call to re-search-forward: Escaped non-special character `f' (pos 14): "^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)"
emacs/lisp/xdg.el:117: In call to string-match: Unescaped literal `$' (pos 1): "^$HOME/"
emacs/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el:115: (invalid-read-syntax "#")
emacs/test/lisp/emacs-lisp/cl-print-tests.el:219: (invalid-read-syntax "#")
emacs/test/lisp/emacs-lisp/seq-tests.el:414: (invalid-read-syntax "#")
emacs/test/src/json-tests.el:54: (invalid-read-syntax "#")
Finished.

[-- Attachment #3: trawl.el --]
[-- Type: application/octet-stream, Size: 9870 bytes --]

;;; -*- lexical-binding: t -*-

;; Scan elisp code for regexp errors.
;; License: GPL

(require 'xr)

(defconst trawl--error-buffer-name "*trawl-catch*")

(defun trawl--error-buffer ()
  (let ((buf (get-buffer trawl--error-buffer-name)))
    (or buf
        (let ((buf (get-buffer-create trawl--error-buffer-name)))
          (with-current-buffer buf
            (compilation-mode))
          buf))))

(defvar trawl--error-count)

(defun trawl--add-to-error-buffer (string)
  (with-current-buffer (trawl--error-buffer)
    (goto-char (point-max))
    (let ((inhibit-read-only t))
      (insert string))))

(defun trawl--report (file pos message)
  (let ((line
         (save-excursion
           (goto-char pos)
           (when (looking-at (rx (1+ (or blank "\n" "\f"
                                         (seq ";" (0+ nonl))))))
             (goto-char (match-end 0)))
           (line-number-at-pos (point) t))))
    (trawl--add-to-error-buffer
     (format "%s:%d: %s\n" file line message)))
  (setq trawl--error-count (1+ trawl--error-count)))

(defun trawl--quote-string (str)
  (concat "\""
          (replace-regexp-in-string
           (rx (any cntrl "\177-\377" ?\\ ?\"))
           (lambda (s)
             (let ((c (logand (string-to-char s) #xff)))
               (or (cdr (assq c
                              '((?\" . "\\\"")
                                (?\\ . "\\\\")
                                (?\b . "\\b")
                                (?\t . "\\t")
                                (?\n . "\\n")
                                (?\v . "\\v")
                                (?\f . "\\f")
                                (?\r . "\\r")
                                (?\e . "\\e"))))
                   (format "\\%03o" c))))
           str t t)
          "\""))

(defun trawl--check-re-string (re name file pos)
  (let ((complaints
         (condition-case err
	     (mapcar (lambda (warning)
                       (format "In %s: %s (pos %d): %s"
                               name (cdr warning) (car warning)
			       (trawl--quote-string re)))
		     (xr-lint re))
	   (error (list (format "In %s: Error: %s: %s"
				name  (cadr err)
                                (trawl--quote-string re)))))))
    (mapc (lambda (msg) (trawl--report file pos msg))
          complaints)))
  
(defun trawl--remove-comma (form)
  (cond
   ((not (consp form)) form)
   ((eq (car form) '\,) (trawl--remove-comma (cadr form)))
   (t
    (cons (trawl--remove-comma (car form))
          (trawl--remove-comma (cdr form))))))

;; Return a value peeled of irrelevancies.
(defun trawl--peel (form)
  (cond
   ((not (consp form)) form)
   ((eq (car form) 'list)
    (trawl--peel (cdr form)))
   ((memq (car form) '(quote purecopy))
    (trawl--peel (cadr form)))
   ((eq (car form) 'eval-when-compile)
    (trawl--peel (car (last form))))
   ((eq (car form) '\`)
    (trawl--peel (trawl--remove-comma (cadr form))))
   (t form)))

;; A list peeled of irrelevancies, or nil.
(defun trawl--peel-list (form)
  (let ((peeled (trawl--peel form)))
    (and (consp peeled) peeled)))

;; Convert something to a list of strings, or nil.
(defun trawl--get-string-list (form)
  (let ((parts (mapcar #'trawl--get-string (trawl--peel-list form))))
    (if (memq nil parts)
        nil
      parts)))

;; Convert something to a string, or nil.
(defun trawl--get-string (form)
  (setq form (trawl--peel form))
  (cond
   ((stringp form) form)
   ((not (consp form)) nil)
   ((eq (car form) 'concat)
    (let ((parts (trawl--get-string-list (cdr form))))
      (and parts (apply #'concat parts))))
   ((eq (car form) 'regexp-opt)
    (let ((arg (trawl--get-string-list (cadr form))))
      (and arg (regexp-opt arg))))
   ((eq (car form) 'regexp-quote)
    (let ((arg (trawl--get-string (cadr form))))
      (and arg (regexp-quote arg))))))

(defun trawl--check-re (form name file pos)
  (let ((re (trawl--get-string form)))
    (when re
      (trawl--check-re-string re name file pos))))

(defun trawl--check-list (form name file pos)
  (mapc (lambda (elem) (trawl--check-re-string elem name file pos))
        (trawl--get-string-list form)))

(defun trawl--check-list-car (form name file pos)
  (mapc (lambda (elem)
          (when (consp elem)
            (trawl--check-re (car elem) name file pos)))
        form))

(defun trawl--check-font-lock-keywords (form name file pos)
  (mapc (lambda (elem)
          (let* ((thing (trawl--peel elem))
                 (str (trawl--get-string thing)))
            (cond (str
                   (trawl--check-re-string str name file pos))
                  ((consp thing)
                   (trawl--check-re (car thing) name file pos)))))
        (trawl--peel-list form)))

(defun trawl--check-form-recursively (form file pos)
  (when (consp form)
    (pcase form
;      (`(apply ,(or `nconc `(quote nconc) `(function nconc)) (mapcar . ,_))
;       (trawl--report file pos
;                     "use mapcan instead of (apply nconc (mapcar...))"))
;      (`(lambda (,var1) (,_ ,var2))
;       (when (eq var1 var2)
;        (trawl--report file pos
;                       "lambda expression can be η-reduced")))
;      (`(lambda (,var1) ,var2)
;       (when (eq var1 var2)
;	 (trawl--report file pos
;			"lambda expression is #'identity")))
;      (`(defun ,name ,_ . ,body)
;       (let ((f body))
;         (while (and f (consp (car f)) (eq (caar f) 'declare))
;           (setq f (cdr f)))
;         (when (and f (consp (car f)))
;           (setq f (cdr f))
;           (while (cdr f)
;             (when (stringp (car f))
;               (trawl--report file pos
;			      (format "defun %s: misplaced doc string" name)))
;             (setq f (cdr f))))))
      (`(,(or `looking-at `re-search-forward `re-search-backward
              `string-match `string-match-p `looking-back `looking-at-p
              `replace-regexp-in-string 'replace-regexp
              `query-replace-regexp
              `posix-looking-at `posix-search-backward `posix-search-forward
              `posix-string-match)
         ,re-arg . ,_)
       (trawl--check-re re-arg (format "call to %s" (car form)) file pos))
      (`(,(or `defvar `defconst 'defcustom)
	 ,name ,re-arg . ,rest)
       (when (symbolp name)
         (cond
          ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern") eos)
			   (symbol-name name))
	   (trawl--check-re re-arg name file pos))
          ((string-match-p (rx (or "-regexps" "-regexes" "-patterns") eos)
			   (symbol-name name))
           (trawl--check-list re-arg name file pos))
          ((string-match-p (rx "-font-lock-keywords" eos)
                           (symbol-name name))
           (trawl--check-font-lock-keywords re-arg name file pos))
          ;; special case
          ((eq name 'compilation-error-regexp-alist-alist)
           (mapc
            (lambda (elem)
	      (trawl--check-re (cadr elem)
                               (format "%s (%s)" name (car elem)) file pos))
            (trawl--peel-list re-arg)))
          ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
                               "-alist" eos)
                           (symbol-name name))
           (trawl--check-list-car (trawl--peel-list re-arg) name file pos))
          ;; Doc string starting with "regexp"?
          ((and (stringp (car rest))
                (let ((case-fold-search t))
                  (string-match-p (rx bos "regexp") (car rest))))
	   (trawl--check-re re-arg name file pos))
          )))
      (`(define-generic-mode ,name ,_ ,_ ,font-lock-list ,auto-mode-list . ,_)
       (let ((origin (format "define-generic-mode %s" name)))
         (trawl--check-font-lock-keywords font-lock-list origin file pos)
         (trawl--check-list auto-mode-list origin file pos)))
      )
    (while (consp form)
      (trawl--check-form-recursively (car form) file pos)
      (setq form (cdr form)))))

(defun trawl--check-toplevel-form (form file pos)
  (trawl--check-form-recursively form file pos))
                      
(defun trawl--show-errors ()
  (let ((pop-up-windows t))
    (display-buffer (trawl--error-buffer))
    (sit-for 0)))

(defun trawl--single-file (file)
  (let ((errors-before trawl--error-count))
    (with-temp-buffer
      (insert-file-contents file)
      (goto-char (point-min))
      (let ((pos nil)
            (read-circle nil))
        (condition-case err
            (while t
              (setq pos (point))
              (let ((form (read (current-buffer))))
                (trawl--check-toplevel-form form file pos)))
          (end-of-file nil)
          (error (trawl--report file pos (prin1-to-string err))))))
    (when (> trawl--error-count errors-before)
      (trawl--show-errors))))
        
(defun trawl--init (file-or-dir dir)
  (with-current-buffer (trawl--error-buffer)
    (let ((inhibit-read-only t))
      (erase-buffer)
      (insert (format ";; Trawling %s  -*- compilation -*-\n" file-or-dir)))
    (setq trawl--error-count 0)
    (cd dir)))

(defun trawl--finish ()
  (trawl--add-to-error-buffer "Finished.\n")
  (let ((errors trawl--error-count))
    (message "trawl: %d error%s found." errors (if (= errors 1) "" "s"))))

(defun trawl-file (file)
  (interactive "fTrawl elisp file: ")
  (trawl--init file (file-name-directory file))
  (trawl--single-file file)
  (trawl--finish))
        
(defun trawl-directory (dir)
  (interactive "DTrawl directory: ")
  (trawl--init dir dir)
  (dolist (file (directory-files-recursively
                 dir (rx bos (not (any ".")) (* anything) ".el" eos)))
    (trawl--single-file file))
  (trawl--finish))

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-03 18:01 Scan of regexp mistakes Mattias Engdegård
@ 2019-03-05  2:04 ` Paul Eggert
  2019-03-05  4:30   ` Clément Pit-Claudel
  2019-03-05 15:06   ` Mattias Engdegård
  0 siblings, 2 replies; 14+ messages in thread
From: Paul Eggert @ 2019-03-05  2:04 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

On 3/3/19 10:01 AM, Mattias Engdegård wrote:
> The errors were gathered by the rather hacky trawl.el, attached (in case you want to run it on other code). It only requires xr (1.4 or later). To use, run trawl-directory or trawl-file.

Thanks for reporting that. I fixed the glitches as best I could by
applying the attached patch. I didn't see any false alarms, which is good.

It'd be nice if we could catch such typos on a regular basis. Is there
some easy way to do that? A simple way might be for you to run your
trawler once a month (say) and report back here. A nicer way would be
for "make check" to run the trawler.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-regular-expression-glitches-and-typos.patch --]
[-- Type: text/x-patch; name="0001-Fix-regular-expression-glitches-and-typos.patch", Size: 93699 bytes --]

From cbaad88e158b14d9b19971ed68b3f55183a440b2 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 4 Mar 2019 18:00:00 -0800
Subject: [PATCH] Fix regular-expression glitches and typos
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problems reported by Mattias Engdegård in:
https://lists.gnu.org/r/emacs-devel/2019-03/msg00085.html
* admin/admin.el (set-version):
* lisp/allout.el (allout-latexify-one-item):
* lisp/arc-mode.el (archive-arc-rename-entry)
(archive-rar-summarize):
* lisp/calc/calc-graph.el (calc-graph-set-styles)
(calc-graph-hide):
* lisp/calc/calc-help.el (calc-describe-key):
* lisp/calc/calc-lang.el (math-compose-tex-func, eqn):
* lisp/calc/calc.el (calcDigit-key):
* lisp/cedet/ede/makefile-edit.el (makefile-macro-file-list):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/comint.el (comint-substitute-in-file-name):
* lisp/dired.el (dired-actual-switches):
* lisp/emacs-lisp/chart.el (chart-rmail-from):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/rx.el (rx-not, rx-atomic-p):
* lisp/emulation/viper-ex.el (viper-get-ex-token)
(viper-get-ex-pat, ex-set-read-variable):
* lisp/epg.el (epg--status-SIG_CREATED):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-user):
(erc-speedbar-expand-channel, erc-speedbar-expand-server)
* lisp/erc/erc.el (erc-is-message-ctcp-and-not-action-p)
(erc-banlist-update):
* lisp/eshell/em-dirs.el (eshell-parse-drive-letter, eshell/pwd):
* lisp/find-dired.el (find-dired):
* lisp/frame.el (frame-set-background-mode):
* lisp/generic-x.el (apache-log-generic-mode):
* lisp/gnus/gnus-art.el (gnus-button-valid-localpart-regexp):
* lisp/gnus/gnus.el (gnus-short-group-name):
* lisp/gnus/message.el (message-mailer-swallows-blank-line):
* lisp/ibuffer.el (ibuffer-fontification-alist):
* lisp/ido.el (ido-set-matches-1):
* lisp/info-xref.el (info-xref-lock-file-p):
* lisp/info.el (Info-dir-remove-duplicates)
(Info-unescape-quotes, Info-split-parameter-string)
(Info-speedbar-expand-node):
* lisp/international/mule.el (sgml-html-meta-auto-coding-function):
* lisp/isearch.el (isearch-pre-command-hook):
* lisp/language/ethio-util.el (ethio-fidel-to-tex-buffer):
* lisp/mail/rmail.el (rmail-collect-deleted):
* lisp/mh-e/mh-alias.el (mh-alias-suggest-alias):
* lisp/mh-e/mh-comp.el (mh-forward):
* lisp/mh-e/mh-search.el (mh-index-next-folder)
(mh-index-create-imenu-index):
* lisp/mh-e/mh-xface.el (mh-picon-get-image):
* lisp/minibuffer.el (completion--embedded-envvar-re):
* lisp/net/ange-ftp.el (ange-ftp-ls-parser):
* lisp/net/goto-addr.el (goto-address-mail-regexp)
(goto-address-find-address-at-point):
* lisp/net/pop3.el (pop3-read-response, pop3-user)
(pop3-pass, pop3-apop):
* lisp/net/tramp.el (tramp-ipv6-regexp)
(tramp-replace-environment-variables):
* lisp/nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* lisp/nxml/rng-uri.el (rng-uri-escape-multibyte):
* lisp/nxml/rng-xsd.el (rng-xsd-convert-any-uri):
* lisp/obsolete/pgg.el (pgg-fetch-key):
* lisp/obsolete/vip.el (vip-get-ex-token):
* lisp/org/ob-core.el (org-babel-string-read):
* lisp/org/org-agenda.el:
(org-agenda-add-entry-to-org-agenda-diary-file):
* lisp/org/org-element.el (org-element-keyword-parser):
* lisp/org/org-list.el (org-list-indent-item-generic):
* lisp/org/org-mhe.el (org-mhe-get-message-folder-from-index):
* lisp/org/org-mobile.el (org-mobile-apply):
* lisp/org/org-mouse.el (org-mouse-context-menu):
* lisp/org/org-plot.el (org-plot/gnuplot):
* lisp/org/org-protocol.el (org-protocol-flatten-greedy):
* lisp/org/org-table.el (org-table-copy-down)
(org-table-formula-make-cmp-string)
(org-table-get-stored-formulas, org-table-recalculate)
(org-table-edit-formulas):
* lisp/org/org.el (org-translate-link-from-planner)
(org-fill-line-break-nobreak-p):
* lisp/org/ox-ascii.el (org-ascii-item):
* lisp/org/ox-latex.el (org-latex-clean-invalid-line-breaks):
* lisp/org/ox.el (org-export-expand-include-keyword):
* lisp/progmodes/ada-xref.el (ada-treat-cmd-string):
* lisp/progmodes/cfengine.el (cfengine2-font-lock-keywords):
* lisp/progmodes/cperl-mode.el (cperl-to-comment-or-eol)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-have-help-regexp, cperl-word-at-point-hard)
(cperl-make-regexp-x):
* lisp/progmodes/dcl-mode.el (dcl-option-value-offset):
* lisp/progmodes/etags.el (tag-implicit-name-match-p):
* lisp/progmodes/fortran.el (fortran-fill):
* lisp/progmodes/gdb-mi.el (gdb-speedbar-expand-node)
(gdb-locals-handler-custom):
* lisp/progmodes/grep.el (grep-mode-font-lock-keywords):
* lisp/progmodes/gud.el (gud-jdb-find-source-using-classpath):
* lisp/progmodes/js.el (js--continued-expression-p):
* lisp/progmodes/m4-mode.el (m4-font-lock-keywords):
* lisp/progmodes/meta-mode.el (meta-indent-level-count):
* lisp/progmodes/mixal-mode.el (mixal-font-lock-keywords):
* lisp/progmodes/opascal.el (opascal-find-unit-in-directory):
* lisp/progmodes/pascal.el (pascal-progbeg-re):
* lisp/progmodes/ruby-mode.el (ruby-expression-expansion-re)
(ruby-expr-beg, ruby-parse-partial)
(ruby-toggle-string-quotes, ruby-font-lock-keywords):
* lisp/progmodes/sql.el (sql--make-help-docstring):
* lisp/progmodes/verilog-mode.el (verilog-coverpoint-re)
(verilog-skip-forward-comment-p)
(verilog-read-sub-decls-gate)
(verilog-read-auto-template-middle):
* lisp/progmodes/vhdl-mode.el (vhdl-resolve-env-variable)
(vhdl-speedbar-expand-project, vhdl-speedbar-expand-entity)
(vhdl-speedbar-expand-architecture)
(vhdl-speedbar-expand-config, vhdl-speedbar-expand-package)
(vhdl-speedbar-dired):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/textmodes/dns-mode.el (dns-mode-font-lock-keywords):
* lisp/textmodes/flyspell.el (flyspell-debug-signal-word-checked):
* lisp/textmodes/ispell.el (ispell-process-line):
* lisp/textmodes/reftex-cite.el (reftex-end-of-bib-entry):
* lisp/textmodes/reftex-ref.el (reftex-replace-prefix-escapes):
* lisp/url/url-parse.el (url-generic-parse-url):
* lisp/url/url-util.el (url-truncate-url-for-viewing):
* lisp/vc/diff-mode.el (diff-unified->context):
* lisp/vc/vc-bzr.el (vc-bzr-error-regexp-alist):
* lisp/vc/vc-cvs.el (vc-cvs-parse-status):
* lisp/woman.el (woman0-el, woman-if-ignore)
(woman-change-fonts):
* lisp/xdg.el (xdg--substitute-home-env):
Fix regular-expression infelicities and typos.

Fix regular expression typos
Fix typos reported by Mattias Engdegård in:
that occurred in preloaded modules.
* lisp/frame.el (frame-set-background-mode):
* lisp/international/mule.el (sgml-html-meta-auto-coding-function):
* lisp/isearch.el (isearch-pre-command-hook):
* lisp/minibuffer.el (completion--embedded-envvar-re):
---
 admin/admin.el                    |  2 +-
 lisp/allout.el                    |  2 +-
 lisp/arc-mode.el                  |  4 ++--
 lisp/calc/calc-graph.el           |  4 ++--
 lisp/calc/calc-help.el            |  2 +-
 lisp/calc/calc-lang.el            |  6 +++---
 lisp/calc/calc.el                 |  2 +-
 lisp/cedet/ede/makefile-edit.el   |  2 +-
 lisp/cedet/ede/speedbar.el        |  2 +-
 lisp/cedet/semantic/sb.el         |  4 ++--
 lisp/comint.el                    |  2 +-
 lisp/dired.el                     |  2 +-
 lisp/emacs-lisp/chart.el          |  2 +-
 lisp/emacs-lisp/eieio-opt.el      |  2 +-
 lisp/emacs-lisp/eieio-speedbar.el |  2 +-
 lisp/emacs-lisp/rx.el             |  4 ++--
 lisp/emulation/viper-ex.el        | 16 ++++++++--------
 lisp/epg.el                       |  2 +-
 lisp/erc/erc-speedbar.el          |  6 +++---
 lisp/erc/erc.el                   |  4 ++--
 lisp/eshell/em-dirs.el            |  4 ++--
 lisp/find-dired.el                |  2 +-
 lisp/frame.el                     |  2 +-
 lisp/generic-x.el                 |  2 +-
 lisp/gnus/gnus-art.el             |  2 +-
 lisp/gnus/gnus.el                 |  2 +-
 lisp/gnus/message.el              |  2 +-
 lisp/ibuffer.el                   |  2 +-
 lisp/ido.el                       |  4 ++--
 lisp/info-xref.el                 |  2 +-
 lisp/info.el                      |  8 ++++----
 lisp/international/mule.el        |  2 +-
 lisp/isearch.el                   |  3 ++-
 lisp/language/ethio-util.el       |  2 +-
 lisp/mail/rmail.el                |  2 +-
 lisp/mh-e/mh-alias.el             |  2 +-
 lisp/mh-e/mh-comp.el              |  2 +-
 lisp/mh-e/mh-search.el            | 10 +++++-----
 lisp/mh-e/mh-xface.el             |  2 +-
 lisp/minibuffer.el                |  2 +-
 lisp/net/ange-ftp.el              |  2 +-
 lisp/net/goto-addr.el             |  4 ++--
 lisp/net/pop3.el                  |  8 ++++----
 lisp/net/tramp.el                 |  4 ++--
 lisp/nxml/nxml-maint.el           |  4 ++--
 lisp/nxml/rng-uri.el              |  2 +-
 lisp/nxml/rng-xsd.el              |  2 +-
 lisp/obsolete/pgg.el              |  2 +-
 lisp/obsolete/vip.el              | 10 +++++-----
 lisp/org/ob-core.el               |  2 +-
 lisp/org/org-agenda.el            |  2 +-
 lisp/org/org-element.el           |  2 +-
 lisp/org/org-list.el              |  2 +-
 lisp/org/org-mhe.el               |  2 +-
 lisp/org/org-mobile.el            |  4 ++--
 lisp/org/org-mouse.el             |  2 +-
 lisp/org/org-plot.el              |  2 +-
 lisp/org/org-protocol.el          |  2 +-
 lisp/org/org-table.el             | 11 ++++++-----
 lisp/org/org.el                   |  4 ++--
 lisp/org/ox-ascii.el              |  4 ++--
 lisp/org/ox-latex.el              |  2 +-
 lisp/org/ox.el                    |  2 +-
 lisp/progmodes/ada-xref.el        |  2 +-
 lisp/progmodes/cfengine.el        |  4 ++--
 lisp/progmodes/cperl-mode.el      | 24 ++++++++++++------------
 lisp/progmodes/dcl-mode.el        |  2 +-
 lisp/progmodes/etags.el           |  2 +-
 lisp/progmodes/fortran.el         |  2 +-
 lisp/progmodes/gdb-mi.el          |  4 ++--
 lisp/progmodes/grep.el            |  6 +++---
 lisp/progmodes/gud.el             |  2 +-
 lisp/progmodes/js.el              |  2 +-
 lisp/progmodes/m4-mode.el         |  2 +-
 lisp/progmodes/meta-mode.el       |  2 +-
 lisp/progmodes/mixal-mode.el      |  2 +-
 lisp/progmodes/opascal.el         |  2 +-
 lisp/progmodes/pascal.el          |  2 +-
 lisp/progmodes/ruby-mode.el       | 14 +++++++-------
 lisp/progmodes/sql.el             |  4 ++--
 lisp/progmodes/verilog-mode.el    |  8 ++++----
 lisp/progmodes/vhdl-mode.el       | 14 +++++++-------
 lisp/speedbar.el                  |  6 +++---
 lisp/textmodes/dns-mode.el        |  4 ++--
 lisp/textmodes/flyspell.el        |  4 ++--
 lisp/textmodes/ispell.el          |  2 +-
 lisp/textmodes/reftex-cite.el     |  4 ++--
 lisp/textmodes/reftex-ref.el      |  2 +-
 lisp/url/url-parse.el             |  2 +-
 lisp/url/url-util.el              |  2 +-
 lisp/vc/diff-mode.el              |  2 +-
 lisp/vc/vc-bzr.el                 |  2 +-
 lisp/vc/vc-cvs.el                 |  2 +-
 lisp/woman.el                     |  6 +++---
 lisp/xdg.el                       |  2 +-
 95 files changed, 177 insertions(+), 175 deletions(-)

diff --git a/admin/admin.el b/admin/admin.el
index 90aac3d43d..650cf47b80 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -144,7 +144,7 @@ set-version
     (unless (> (length newversion) 2)   ; pretest or release candidate?
       (with-temp-buffer
         (insert-file-contents newsfile)
-        (if (re-search-forward "^\\(+++ *\\|--- *\\)$" nil t)
+        (if (re-search-forward "^\\(\\+\\+\\+ *\\|--- *\\)$" nil t)
             (display-warning 'admin
                              "NEWS file still contains temporary markup.
 Documentation changes might not have been completed!"))))
diff --git a/lisp/allout.el b/lisp/allout.el
index c2b3187e8a..b3b87e533b 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -5788,7 +5788,7 @@ allout-latexify-one-item
 					; "\end{verbatim}" in text,
 					; it's special:
 	(if (and body-content
-		 (setq bop (string-match "\\end{verbatim}" curr-line)))
+		 (setq bop (string-match "\\\\end{verbatim}" curr-line)))
 	    (setq curr-line (concat (substring curr-line 0 bop)
 				    ">"
 				    (substring curr-line bop))))
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 8de0103019..2afde7ee75 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -1534,7 +1534,7 @@ archive-arc-summarize
     (apply #'vector (nreverse files))))
 
 (defun archive-arc-rename-entry (newname descr)
-  (if (string-match "[:\\\\/]" newname)
+  (if (string-match "[:\\/]" newname)
       (error "File names in arc files must not contain a directory component"))
   (if (> (length newname) 12)
       (error "File names in arc files are limited to 12 characters"))
@@ -2016,7 +2016,7 @@ archive-rar-summarize
       (call-process "lsar" nil t nil "-l" (or file copy))
       (if copy (delete-file copy))
       (goto-char (point-min))
-      (re-search-forward "^\\(\s+=+\s?+\\)+\n")
+      (re-search-forward "^\\(\s+=+\s+\\)+\n")
       (while (looking-at (concat "^\s+[0-9.]+\s+D?-+\s+"   ; Flags
                                  "\\([0-9-]+\\)\s+"        ; Size
                                  "\\([-0-9.%]+\\|-+\\)\s+" ; Ratio
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index 317f403ead..56f11c6711 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -1121,7 +1121,7 @@ calc-graph-set-styles
                  (eval (intern
                         (concat "var-"
                                 (save-excursion
-                                  (re-search-backward ":\\(.*\\)\\}")
+				  (re-search-backward ":\\(.*\\)}")
                                   (match-string 1))))))
               (error nil)))
       (if yerr
@@ -1186,7 +1186,7 @@ calc-graph-hide
 	 (or (looking-at "{")
 	     (error "Can't hide this curve (wrong format)"))
 	 (forward-char 1)
-	 (if (looking-at "*")
+	 (if (looking-at "\\*")
 	     (if (or (null flag) (<= (prefix-numeric-value flag) 0))
 		 (delete-char 1))
 	   (if (or (null flag) (> (prefix-numeric-value flag) 0))
diff --git a/lisp/calc/calc-help.el b/lisp/calc/calc-help.el
index cf7574e738..d9e8fe779b 100644
--- a/lisp/calc/calc-help.el
+++ b/lisp/calc/calc-help.el
@@ -172,7 +172,7 @@ calc-describe-key
 	  (setq desc (concat "M-" (substring desc 4))))
       (while (string-match "^M-# \\(ESC \\|C-\\)" desc)
 	(setq desc (concat "M-# " (substring desc (match-end 0)))))
-      (if (string-match "\\(DEL\\|\\LFD\\|RET\\|SPC\\|TAB\\)" desc)
+      (if (string-match "\\(DEL\\|LFD\\|RET\\|SPC\\|TAB\\)" desc)
           (setq desc (replace-match "<\\&>" nil nil desc)))
       (if briefly
 	  (let ((msg (with-current-buffer (get-buffer-create "*Calc Summary*")
diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index 3f55fb15d5..ee107df39c 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -753,8 +753,8 @@ math-compose-tex-func
                  right " \\right)"))
           ((and (eq (aref func 0) ?\\)
                 (not (or
-                      (string-match "\\hbox{" func)
-                      (string-match "\\text{" func)))
+                      (string-match "\\\\hbox{" func)
+                      (string-match "\\\\text{" func)))
                 (= (length a) 2)
                 (or (Math-realp (nth 1 a))
                     (memq (car (nth 1 a)) '(var *))))
@@ -1127,7 +1127,7 @@ math-eqn-ignore-words
                  (math-read-token)))))))
 
 (put 'eqn 'math-lang-read
-     '((eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^"
+     '((eq (string-match "->\\|<-\\|\\+-\\|\\\\dots\\|~\\|\\^"
                          math-exp-str math-exp-pos)
            math-exp-pos)
        (progn
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 7390ea350e..35f13f9656 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -2430,7 +2430,7 @@ calcDigit-key
 	  (beep)
 	(and (not (calc-minibuffer-contains "[-+]?\\(1[5-9]\\|[2-9][0-9]\\)#.*"))
 	     (search-forward "e" nil t))
-	(if (looking-at "+")
+	(if (looking-at "\\+")
 	    (delete-char 1))
 	(if (looking-at "-")
 	    (delete-char 1)
diff --git a/lisp/cedet/ede/makefile-edit.el b/lisp/cedet/ede/makefile-edit.el
index 7d8a44bd9a..1472108ad5 100644
--- a/lisp/cedet/ede/makefile-edit.el
+++ b/lisp/cedet/ede/makefile-edit.el
@@ -105,7 +105,7 @@ makefile-macro-file-list
 	(let ((e (save-excursion
 		   (makefile-end-of-command)
 		   (point))))
-	  (while (re-search-forward "\\s-**\\([-a-zA-Z0-9./_@$%(){}]+\\)\\s-*" e t)
+	  (while (re-search-forward "\\s-*\\([-a-zA-Z0-9./_@$%(){}]+\\)\\s-*" e t)
 	    (let ((var nil)(varexp nil)
 		  (match (buffer-substring-no-properties
 			  (match-beginning 1)
diff --git a/lisp/cedet/ede/speedbar.el b/lisp/cedet/ede/speedbar.el
index cd56228498..a5ccb66664 100644
--- a/lisp/cedet/ede/speedbar.el
+++ b/lisp/cedet/ede/speedbar.el
@@ -276,7 +276,7 @@ ede-tag-expand
 Etags does not support this feature.  TEXT will be the button
 string.  TOKEN will be the list, and INDENT is the current indentation
 level."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
diff --git a/lisp/cedet/semantic/sb.el b/lisp/cedet/semantic/sb.el
index 6227ac618a..83d11e1658 100644
--- a/lisp/cedet/semantic/sb.el
+++ b/lisp/cedet/semantic/sb.el
@@ -279,7 +279,7 @@ semantic-sb-detail-parent
 (defun semantic-sb-show-extra (text token indent)
   "Display additional information about the token as an expansion.
 TEXT TOKEN and INDENT are the details."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
@@ -325,7 +325,7 @@ semantic-sb-token-jump
 (defun semantic-sb-expand-group (text token indent)
   "Expand a group which has semantic tokens.
 TEXT TOKEN and INDENT are the details."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
diff --git a/lisp/comint.el b/lisp/comint.el
index a51413dc65..a5fca7ea2a 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3092,7 +3092,7 @@ comint-substitute-in-file-name
 	(let (env-var-name
 	      env-var-val)
 	  (save-match-data
-	    (while (string-match "%\\([^\\\\/]*\\)%" name)
+	    (while (string-match "%\\([^\\/]*\\)%" name)
 	      (setq env-var-name (match-string 1 name))
 	      (setq env-var-val (or (getenv env-var-name) ""))
 	      (setq name (replace-match env-var-val t t name))))))
diff --git a/lisp/dired.el b/lisp/dired.el
index 3cb645eea7..98f493ecc6 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -325,7 +325,7 @@ dired-actual-switches
 
 (put 'dired-actual-switches 'safe-local-variable 'dired-safe-switches-p)
 
-(defvar dired-re-inode-size "[0-9  \t]*[.,0-9]*[BkKMGTPEZY]?[ \t]*"
+(defvar dired-re-inode-size "[0-9 \t]*[.,0-9]*[BkKMGTPEZY]?[ \t]*"
   "Regexp for optional initial inode and file size as made by `ls -i -s'.")
 
 ;; These regexps must be tested at beginning-of-line, but are also
diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el
index 708f41237b..9c29297da0 100644
--- a/lisp/emacs-lisp/chart.el
+++ b/lisp/emacs-lisp/chart.el
@@ -704,7 +704,7 @@ chart-rmail-from
 	(cntlst nil))
     (save-excursion
       (goto-char (point-min))
-      (while (re-search-forward "\\-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t)
+      (while (re-search-forward "-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t)
 	(let* ((nam (buffer-substring (match-beginning 1) (match-end 1)))
 	       (m (member nam nmlst)))
 	  (message "Scanned username %s" nam)
diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el
index e93d317d93..193f92bc2c 100644
--- a/lisp/emacs-lisp/eieio-opt.el
+++ b/lisp/emacs-lisp/eieio-opt.el
@@ -327,7 +327,7 @@ eieio-class-button
 (defun eieio-sb-expand (text class indent)
   "For button TEXT, expand CLASS at the current location.
 Argument INDENT is the depth of indentation."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
diff --git a/lisp/emacs-lisp/eieio-speedbar.el b/lisp/emacs-lisp/eieio-speedbar.el
index 52dd6fea3f..2dd9a5eda6 100644
--- a/lisp/emacs-lisp/eieio-speedbar.el
+++ b/lisp/emacs-lisp/eieio-speedbar.el
@@ -348,7 +348,7 @@ eieio-speedbar-object-click
 (defun eieio-speedbar-object-expand (text token indent)
   "Expand object represented by TEXT.
 TOKEN is the object.  INDENT is the current indentation level."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (oset token expanded t)
 	 (speedbar-with-writable
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index ca756efb49..f6deb45d44 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -609,7 +609,7 @@ rx-not
   (rx-check form)
   (let ((result (rx-form (cadr form) '!))
 	case-fold-search)
-    (cond ((string-match "\\`\\[^" result)
+    (cond ((string-match "\\`\\[\\^" result)
 	   (cond
 	    ((equal result "[^]") "[^^]")
 	    ((and (= (length result) 4) (null (eq rx-parent '!)))
@@ -787,7 +787,7 @@ rx-atomic-p
      ((= l 3) (string-match "\\`\\(?:\\\\[cCsS_]\\|\\[[^^]\\]\\)" r))
      ((null lax)
       (cond
-       ((string-match "\\`\\[^?\]?\\(?:\\[:[a-z]+:]\\|[^]]\\)*\\]\\'" r))
+       ((string-match "\\`\\[\\^?]?\\(?:\\[:[a-z]+:]\\|[^]]\\)*]\\'" r))
        ((string-match "\\`\\\\(\\(?:[^\\]\\|\\\\[^)]\\)*\\\\)\\'" r)))))))
 
 
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 41c9a3973a..4496f1cf7d 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -427,18 +427,18 @@ viper-get-ex-token
 	     (forward-char 1)
 	     (setq ex-token-type 'whole))
 	    ((= char ?+)
-	     (cond ((or (looking-at "+[-+]") (looking-at "+[\n|]"))
+	     (cond ((looking-at "\\+[-+\n|]")
 		    (forward-char 1)
 		    (insert "1")
 		    (backward-char 1)
 		  (setq ex-token-type 'plus))
-		   ((looking-at "+[0-9]")
+		   ((looking-at "\\+[0-9]")
 		    (forward-char 1)
 		    (setq ex-token-type 'plus))
 		   (t
 		    (error viper-BadAddress))))
 	    ((= char ?-)
-	     (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]"))
+	     (cond ((looking-at "-[-+\n|]")
 		    (forward-char 1)
 		    (insert "1")
 		    (backward-char 1)
@@ -455,7 +455,7 @@ viper-get-ex-token
 	       (while (and (not (eolp)) cont)
 		 ;;(re-search-forward "[^/]*/")
 		 (re-search-forward "[^/]*\\(/\\|\n\\)")
-		 (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"
+		 (if (not (looking-back "[^\\]\\(\\\\\\\\\\)*\\\\/"
                                         (line-beginning-position 0)))
 		     (setq cont nil))))
 	     (backward-char 1)
@@ -469,7 +469,7 @@ viper-get-ex-token
 	       (while (and (not (eolp)) cont)
 		 ;;(re-search-forward "[^\\?]*\\?")
 		 (re-search-forward "[^\\?]*\\(\\?\\|\n\\)")
-		 (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"
+		 (if (not (looking-back "[^\\]\\(\\\\\\\\\\)*\\\\\\?"
                                         (line-beginning-position 0)))
 		     (setq cont nil))
 		 (backward-char 1)
@@ -744,7 +744,7 @@ viper-get-ex-pat
 	     (error
 	      "Global regexp must be inside matching non-alphanumeric chars"))
 	    ((= c ??) (error "`?' is not an allowed pattern delimiter here")))
-      (if (looking-at "[^\\\\\n]")
+      (if (looking-at "[^\\\n]")
 	  (progn
 	    (forward-char 1)
 	    (set-mark (point))
@@ -757,7 +757,7 @@ viper-get-ex-pat
 			(error "Missing closing delimiter for global regexp")
 		      (goto-char (point-max))))
 		(if (not (looking-back
-			  (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c)
+			  (format "[^\\]\\(\\\\\\\\\\)*\\\\%c" c)
                           (line-beginning-position 0)))
 		    (setq cont nil)
 		  ;; we are at an escaped delimiter: unescape it and continue
@@ -1686,7 +1686,7 @@ ex-set-read-variable
     (message ":set  <Variable> [= <Value>]")
     (or batch (sit-for 2))
 
-    (while (string-match "^[ \\t\\n]*$"
+    (while (string-match "^[ \t\n]*$"
 			 (setq str
 			       (completing-read ":set " ex-variable-alist)))
       (message ":set <Variable> [= <Value>]")
diff --git a/lisp/epg.el b/lisp/epg.el
index dd490ad0b2..e06cc06a7d 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1144,7 +1144,7 @@ epg--status-DELETE_PROBLEM
 
 (defun epg--status-SIG_CREATED (context string)
   (if (string-match "\\`\\([DCS]\\) \\([0-9]+\\) \\([0-9]+\\) \
-\\([0-9A-Fa-F][0-9A-Fa-F]\\) \\(.*\\) " string)
+\\([0-9A-Fa-f][0-9A-Fa-f]\\) \\(.*\\) " string)
       (epg-context-set-result-for
        context 'sign
        (cons (epg-make-new-signature
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index 3d43457dd2..0a1e38fe24 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -140,7 +140,7 @@ erc-speedbar-server-buttons
 	t))))
 
 (defun erc-speedbar-expand-server (text server indent)
-  (cond ((string-match "+" text)
+  (cond ((string-match "\\+" text)
 	 (speedbar-change-expand-button-char ?-)
 	 (if (speedbar-with-writable
 	       (save-excursion
@@ -185,7 +185,7 @@ erc-speedbar-expand-channel
   "For the line matching TEXT, in CHANNEL, expand or contract a line.
 INDENT is the current indentation level."
   (cond
-   ((string-match "+" text)
+   ((string-match "\\+" text)
     (speedbar-change-expand-button-char ?-)
     (speedbar-with-writable
      (save-excursion
@@ -285,7 +285,7 @@ erc-speedbar-update-channel
 	(erc-speedbar-expand-channel "+" buffer 1)))))
 
 (defun erc-speedbar-expand-user (text token indent)
-  (cond ((string-match "+" text)
+  (cond ((string-match "\\+" text)
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 101a5a05bf..bcaa3e4525 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -4285,7 +4285,7 @@ erc-is-message-ctcp-p
 (defun erc-is-message-ctcp-and-not-action-p (message)
   "Check if MESSAGE is a CTCP message or not."
   (and (erc-is-message-ctcp-p message)
-       (not (string-match "^\C-a\\ACTION.*\C-a$" message))))
+       (not (string-match "^\C-aACTION.*\C-a$" message))))
 
 (defun erc-format-privmessage (nick msg privp msgp)
   "Format a PRIVMSG in an insertable fashion."
@@ -4491,7 +4491,7 @@ erc-banlist-update
                                     (mapcar #'upcase
                                             (cdr (split-string mode)))))
                         erc-channel-banlist)))
-                ((string-match "^+" mode)
+                ((string-match "^\\+" mode)
                  ;; Add the banned mask(s) to the ban list
                  (mapc
                   (lambda (mask)
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 8e79189acf..31588a472a 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -272,7 +272,7 @@ eshell-parse-user-reference
 (defun eshell-parse-drive-letter ()
   "An argument beginning with X:[^/] is a drive letter reference."
   (when (and (not eshell-current-argument)
-	     (looking-at "\\([A-Za-z]:\\)\\([^/\\\\]\\|\\'\\)"))
+	     (looking-at "\\([A-Za-z]:\\)\\([^/\\]\\|\\'\\)"))
     (goto-char (match-end 1))
     (let* ((letter (match-string 1))
 	   (regexp (concat "\\`" letter))
@@ -307,7 +307,7 @@ eshell/pwd
     (if (and (> len 1)
 	     (eq (aref path (1- len)) ?/)
 	     (not (and (eshell-under-windows-p)
-		       (string-match "\\`[A-Za-z]:[\\\\/]\\'" path))))
+		       (string-match "\\`[A-Za-z]:[\\/]\\'" path))))
 	(setq path (substring path 0 (1- (length path)))))
     (if eshell-pwd-convert-function
 	(funcall eshell-pwd-convert-function path)
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 1935db00f2..ef137be9bb 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -175,7 +175,7 @@ find-dired
 			  " " args " "
 			  (shell-quote-argument ")")
 			  " "))
-		       (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|+\\)\\'"
+		       (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|\\+\\)\\'"
 					 (car find-ls-option))
 			   (format "%s %s %s"
 				   (match-string 1 (car find-ls-option))
diff --git a/lisp/frame.el b/lisp/frame.el
index 7fe3282eb5..d71a3fe5e8 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1072,7 +1072,7 @@ frame-set-background-mode
 	   (default-bg-mode
 	     (if (or (window-system frame)
 		     (and tty-type
-			  (string-match "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)"
+			  (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
 					tty-type)))
 		 'light
 	       'dark))
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 47dfd2822d..c430be78ab 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -294,7 +294,7 @@ apache-log-generic-mode
   nil
   nil
   ;; Hostname ? user date request return-code number-of-bytes
-  '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
+  '(("^\\([-a-zA-Z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
      (1 font-lock-constant-face)
      (2 font-lock-variable-name-face)))
   '("access_log\\'")
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 06f7be3da7..fa3abfac58 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -7378,7 +7378,7 @@ gnus-button-valid-fqdn-regexp
 
 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
 (defcustom gnus-button-valid-localpart-regexp
-  "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
+  "[a-z$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
   "Regular expression that matches a localpart of mail addresses or MIDs."
   :version "22.1"
   :group 'gnus-article-buttons
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index e5574d4f4f..0bd15f3e39 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -3751,7 +3751,7 @@ gnus-short-group-name
     ;; otherwise collapse to select method.
     (let* ((colon (string-match ":" group))
 	   (server (and colon (substring group 0 colon)))
-	   (plus (and server (string-match "+" server))))
+	   (plus (and server (string-match "\\+" server))))
       (when server
 	(if plus
 	    (setq foreign (substring server (+ 1 plus)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 0085337940..d490f0ca74 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -1288,7 +1288,7 @@ message-mailer-swallows-blank-line
       ;; According to RFC 822 and its successors, the field name must
       ;; consist of printable US-ASCII characters other than colon,
       ;; i.e., decimal 33-56 and 59-126.
-      '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\\\^_`a-z{|}~]+:"))
+      '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>?@A-Z\\^_`a-z{|}~]+:"))
   "Set this non-nil if the system's mailer runs the header and body together.
 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
 The value should be an expression to test whether the problem will
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index f34930af8e..2d3c140536 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -155,7 +155,7 @@ ibuffer-fontification-alist
 	     (string-match ibuffer-compressed-file-name-regexp
 			   buffer-file-name))
 	font-lock-doc-face)
-    (20 (string-match "^*" (buffer-name)) font-lock-keyword-face)
+    (20 (string-match "^\\*" (buffer-name)) font-lock-keyword-face)
     (25 (and (string-match "^ " (buffer-name))
 	     (null buffer-file-name))
 	italic)
diff --git a/lisp/ido.el b/lisp/ido.el
index 8078d184db..c268289a18 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3788,13 +3788,13 @@ ido-set-matches-1
 		       (not (and (eq ido-cur-item 'buffer)
 				 ido-buffer-disable-smart-matches))
 		       (not ido-enable-regexp)
-		       (not (string-match "$\\'" rex0))
+		       (not (string-match "\\$\\'" rex0))
 		       (concat "\\`" rex0 (if slash "/" "") "\\'")))
 	 (suffix-re (and do-full slash
 			 (not (and (eq ido-cur-item 'buffer)
 				   ido-buffer-disable-smart-matches))
 			 (not ido-enable-regexp)
-			 (not (string-match "$\\'" rex0))
+			 (not (string-match "\\$\\'" rex0))
 			 (concat rex0 "/\\'")))
 	 (prefix-re (and full-re (not ido-enable-prefix)
 			 (concat "\\`" rexq)))
diff --git a/lisp/info-xref.el b/lisp/info-xref.el
index e8750a7db7..c55398b73f 100644
--- a/lisp/info-xref.el
+++ b/lisp/info-xref.el
@@ -71,7 +71,7 @@ info-xref-case-fold
 (defun info-xref-lock-file-p (filename)
   "Return non-nil if FILENAME is an Emacs lock file.
 A lock file is \".#foo.txt\" etc per `lock-buffer'."
-  (string-match "\\(\\`\\|\\/\\)\\.#" filename))
+  (string-match "\\(\\`\\|/\\)\\.#" filename))
 
 (defun info-xref-subfile-p (filename)
   "Return t if FILENAME is an info subfile.
diff --git a/lisp/info.el b/lisp/info.el
index 6038273c37..c650d88257 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1531,7 +1531,7 @@ Info-dir-remove-duplicates
 	    (save-restriction
 	      (narrow-to-region start (point))
 	      (goto-char (point-min))
-	      (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)" nil 'move)
+	      (while (re-search-forward "^\\* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)" nil 'move)
 		;; Fold case straight away; `member-ignore-case' here wasteful.
 		(let ((x (downcase (match-string 1))))
 		  (if (member x seen)
@@ -1602,7 +1602,7 @@ Info-unescape-quotes
   "Unescape double quotes and backslashes in VALUE."
   (let ((start 0)
 	(unquote value))
-    (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start)
+    (while (string-match "[^\\\"]*\\(\\\\\\)[\\\"]" unquote start)
       (setq unquote (replace-match "" t t unquote 1))
       (setq start (- (match-end 0) 1)))
     unquote))
@@ -1619,7 +1619,7 @@ Info-split-parameter-string
   (let ((start 0)
 	(parameter-alist))
     (while (string-match
-	    "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
+	    "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\"]\\)*\\)\"\\)\\)"
 	    parameter-string start)
       (setq start (match-end 0))
       (push (cons (match-string 1 parameter-string)
@@ -5204,7 +5204,7 @@ Info-speedbar-expand-node
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node (NAME . FILE).
 INDENT is the current indentation depth."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (if (speedbar-with-writable
 	      (save-excursion
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 023fcbc5d1..5393958013 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -2545,7 +2545,7 @@ sgml-html-meta-auto-coding-function
     ;; (allowing for whitespace at bob).  Note: 'DOCTYPE NETSCAPE' is
     ;; useful for Mozilla bookmark files.
     (when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t)
-	       (re-search-forward "<meta\\s-+\\(http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*\\)?charset=[\"']?\\(.+?\\)[\"'\\s-/>]" size t))
+	       (re-search-forward "<meta\\s-+\\(http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*\\)?charset=[\"']?\\(.+?\\)[\"'[:space:]/>]" size t))
       (let* ((match (match-string 2))
 	     (sym (intern (downcase match))))
 	(if (coding-system-p sym)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index b9441336f9..6280afebdc 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2874,7 +2874,8 @@ isearch-pre-command-hook
            (or (eq (get this-command 'isearch-move) 'enabled)
                (and (eq isearch-yank-on-move t)
                     (stringp (nth 1 (interactive-form this-command)))
-                    (string-match-p "^^" (nth 1 (interactive-form this-command))))
+                    (string-match-p "^\\^"
+				    (nth 1 (interactive-form this-command))))
                (and (eq isearch-yank-on-move 'shift)
                     this-command-keys-shift-translated)))
       (setq this-command-keys-shift-translated nil)
diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index afc2239fbf..512d49b9c5 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -804,7 +804,7 @@ ethio-fidel-to-tex-buffer
 
     ;; Special Ethiopic punctuation.
     (goto-char (point-min))
-    (while (re-search-forward "\\ce[»\\.\\?]\\|«\\ce" nil t)
+    (while (re-search-forward "\\ce[»\\.?]\\|«\\ce" nil t)
       (cond
        ((= (setq ch (preceding-char)) ?\»)
 	(delete-char -1)
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 7f7f0e967d..91291b8d33 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2575,7 +2575,7 @@ rmail-collect-deleted
   (save-excursion
     (setq deleted-head
 	  (cons (if (and (search-forward (concat rmail-attribute-header ": ") message-end t)
-			 (looking-at "?D"))
+			 (looking-at "\\?D"))
 		    ?D
 		  ?\s) deleted-head))))
 
diff --git a/lisp/mh-e/mh-alias.el b/lisp/mh-e/mh-alias.el
index 49f55475a7..c6cdfc40c9 100644
--- a/lisp/mh-e/mh-alias.el
+++ b/lisp/mh-e/mh-alias.el
@@ -338,7 +338,7 @@ mh-alias-suggest-alias
     ;; Two words -> first.last
     (downcase
      (format "%s.%s" (match-string 1 string) (match-string 2 string))))
-   ((string-match "^\\([-a-zA-Z0-9._]+\\)@[-a-zA-z0-9_]+\\.+[a-zA-Z0-9]+$"
+   ((string-match "^\\([-a-zA-Z0-9._]+\\)@[-a-zA-Z0-9_]+\\.+[a-zA-Z0-9]+$"
                   string)
     ;; email only -> downcase username
     (downcase (match-string 1 string)))
diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el
index 706e64dd77..b96ef74538 100644
--- a/lisp/mh-e/mh-comp.el
+++ b/lisp/mh-e/mh-comp.el
@@ -612,7 +612,7 @@ mh-forward
               (goto-char (mh-mail-header-end))
               (while
                   (re-search-forward
-                   "^#forw \\[\\([^]]+\\)\\] \\(+\\S-+\\) \\(.*\\)$"
+                   "^#forw \\[\\([^]]+\\)\\] \\(\\+\\S-+\\) \\(.*\\)$"
                    (point-max) t)
                 (let ((description (if (equal (match-string 1)
                                               "forwarded messages")
diff --git a/lisp/mh-e/mh-search.el b/lisp/mh-e/mh-search.el
index 1a14f4f3dc..c017baec66 100644
--- a/lisp/mh-e/mh-search.el
+++ b/lisp/mh-e/mh-search.el
@@ -495,16 +495,16 @@ mh-index-next-folder
     (let ((point (point)))
       (forward-line (if backward-flag 0 1))
       (cond ((if backward-flag
-                 (re-search-backward "^+" (point-min) t)
-               (re-search-forward "^+" (point-max) t))
+                 (re-search-backward "^\\+" (point-min) t)
+               (re-search-forward "^\\+" (point-max) t))
              (beginning-of-line))
             ((and (if backward-flag
                       (goto-char (point-max))
                     (goto-char (point-min)))
                   nil))
             ((if backward-flag
-                 (re-search-backward "^+" (point-min) t)
-               (re-search-forward "^+" (point-max) t))
+                 (re-search-backward "^\\+" (point-min) t)
+               (re-search-forward "^\\+" (point-max) t))
              (beginning-of-line))
             (t (goto-char point))))))
 
@@ -1429,7 +1429,7 @@ mh-index-create-imenu-index
         (setq which-func-mode t))
     (let ((alist ()))
       (goto-char (point-min))
-      (while (re-search-forward "^+" nil t)
+      (while (re-search-forward "^\\+" nil t)
         (save-excursion
           (beginning-of-line)
           (push (cons (buffer-substring-no-properties
diff --git a/lisp/mh-e/mh-xface.el b/lisp/mh-e/mh-xface.el
index 9a03fef110..ddb001ac8f 100644
--- a/lisp/mh-e/mh-xface.el
+++ b/lisp/mh-e/mh-xface.el
@@ -197,7 +197,7 @@ mh-picon-get-image
                         (mh-funcall-if-exists ietf-drums-parse-address
                                               from-field))))
            (host (and from
-                      (string-match "\\([^+]*\\)\\(+.*\\)?@\\(.*\\)" from)
+                      (string-match "\\([^+]*\\)\\(\\+.*\\)?@\\(.*\\)" from)
                       (downcase (match-string 3 from))))
            (user (and host (downcase (match-string 1 from))))
            (canonical-address (format "%s@%s" user host))
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 9fe961d748..c5d714846d 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2311,7 +2311,7 @@ completion--embedded-envvar-re
   ;; We can't reuse env--substitute-vars-regexp because we need to match only
   ;; potentially-unfinished envvars at end of string.
   (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)"
-          "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
+          "\\$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
 
 (defun completion--embedded-envvar-table (string _pred action)
   "Completion table for envvars embedded in a string.
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index f2ee895049..428bf32947 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -2728,7 +2728,7 @@ ange-ftp-ls-parser
 	    ;; seem to believe in the F-switch
 	    (if (or (and symlink (string-match "@\\'" file))
 		    (and directory (string-match "/\\'" file))
-		    (and executable (string-match "*\\'" file))
+		    (and executable (string-match "\\*\\'" file))
 		    (and socket (string-match "=\\'" file)))
 		(setq file (substring file 0 -1)))))
       (puthash file (or symlink directory) tbl)
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 43659d2820..c25d787391 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -98,7 +98,7 @@ goto-address-fontify-maximum-size
 
 (defvar goto-address-mail-regexp
   ;; Actually pretty much any char could appear in the username part.  -stef
-  "[-a-zA-Z0-9=._+]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
+  "[-a-zA-Z0-9=._+]+@\\([-a-zA-Z0-9_]+\\.\\)+[a-zA-Z0-9]+"
   "A regular expression probably matching an e-mail address.")
 
 (defvar goto-address-url-regexp
@@ -246,7 +246,7 @@ goto-address-find-address-at-point
   "Find e-mail address around or before point.
 Then search backwards to beginning of line for the start of an e-mail
 address.  If no e-mail address found, return nil."
-  (re-search-backward "[^-_A-z0-9.@]" (line-beginning-position) 'lim)
+  (re-search-backward "[^-_A-Za-z0-9.@]" (line-beginning-position) 'lim)
   (if (or (looking-at goto-address-mail-regexp)	; already at start
 	  (and (re-search-forward goto-address-mail-regexp
 				  (line-end-position) 'lim)
diff --git a/lisp/net/pop3.el b/lisp/net/pop3.el
index cd6a113bff..599e2305f7 100644
--- a/lisp/net/pop3.el
+++ b/lisp/net/pop3.el
@@ -585,7 +585,7 @@ pop3-read-response
       (goto-char pop3-read-point)
       (if (looking-at "-ERR")
 	  (error "%s" (buffer-substring (point) (- match-end 2)))
-	(if (not (looking-at "+OK"))
+	(if (not (looking-at "\\+OK"))
 	    (progn (setq pop3-read-point match-end) nil)
 	  (setq pop3-read-point match-end)
 	  (if return
@@ -684,14 +684,14 @@ pop3-user
   "Send USER information to POP3 server."
   (pop3-send-command process (format "USER %s" user))
   (let ((response (pop3-read-response process t)))
-    (if (not (and response (string-match "+OK" response)))
+    (if (not (and response (string-match "\\+OK" response)))
 	(error "USER %s not valid" user))))
 
 (defun pop3-pass (process)
   "Send authentication information to the server."
   (pop3-send-command process (format "PASS %s" pop3-password))
   (let ((response (pop3-read-response process t)))
-    (if (not (and response (string-match "+OK" response)))
+    (if (not (and response (string-match "\\+OK" response)))
 	(pop3-quit process))))
 
 (defun pop3-apop (process user)
@@ -704,7 +704,7 @@ pop3-apop
 	(let ((hash (md5 (concat pop3-timestamp pass) nil nil 'binary)))
 	  (pop3-send-command process (format "APOP %s %s" user hash))
 	  (let ((response (pop3-read-response process t)))
-	    (if (not (and response (string-match "+OK" response)))
+	    (if (not (and response (string-match "\\+OK" response)))
 		(pop3-quit process)))))
     ))
 
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 420a72d42e..b35b36eac7 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -870,7 +870,7 @@ tramp-prefix-ipv6-regexp
 ;; The following regexp is a bit sloppy.  But it shall serve our
 ;; purposes.  It covers also IPv4 mapped IPv6 addresses, like in
 ;; "::ffff:192.168.0.1".
-(defconst tramp-ipv6-regexp "\\(?:\\(?:[a-zA-Z0-9]+\\)?:\\)+[a-zA-Z0-9.]+"
+(defconst tramp-ipv6-regexp "\\(?:[a-zA-Z0-9]*:\\)+[a-zA-Z0-9.]+"
   "Regexp matching IPv6 addresses.")
 
 (defconst tramp-postfix-ipv6-format-alist
@@ -2087,7 +2087,7 @@ tramp-replace-environment-variables
        (tramp-compat-funcall 'substitute-env-vars filename 'only-defined))
      ;; We need an own implementation.
      (save-match-data
-       (let ((idx (string-match "$\\(\\w+\\)" filename)))
+       (let ((idx (string-match "\\$\\(\\w+\\)" filename)))
 	 ;; `$' is coded as `$$'.
 	 (when (and idx
 		    (or (zerop idx) (not (eq ?$ (aref filename (1- idx)))))
diff --git a/lisp/nxml/nxml-maint.el b/lisp/nxml/nxml-maint.el
index 2570e51af5..2956efb736 100644
--- a/lisp/nxml/nxml-maint.el
+++ b/lisp/nxml/nxml-maint.el
@@ -34,10 +34,10 @@ nxml-insert-target-repertoire-glyph-set
   (let (lst head)
     (with-current-buffer (find-file-noselect file)
       (goto-char (point-min))
-      (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t)
+      (while (re-search-forward "^ *\\([a-fA-F0-9]\\{2\\}\\)[ \t]+" nil t)
 	(let ((row (match-string 1))
 	      (eol (line-end-position)))
-	  (while (re-search-forward "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" eol t)
+	  (while (re-search-forward "\\([a-fA-F0-9]\\{2\\}\\)-\\([a-fA-F0-9]\\{2\\}\\)\\|\\([a-fA-F0-9]\\{2\\}\\)" eol t)
 	    (setq lst
 		  (cons (if (match-beginning 3)
 			    (concat "#x" row (match-string 3))
diff --git a/lisp/nxml/rng-uri.el b/lisp/nxml/rng-uri.el
index 0e458cfd2f..d8f2884f5e 100644
--- a/lisp/nxml/rng-uri.el
+++ b/lisp/nxml/rng-uri.el
@@ -42,7 +42,7 @@ rng-file-name-uri
 
 (defun rng-uri-escape-multibyte (uri)
   "Escape multibyte characters in URI."
-  (replace-regexp-in-string "[:nonascii:]"
+  (replace-regexp-in-string "[[:nonascii:]]"
 			    'rng-percent-encode
 			    (encode-coding-string uri 'utf-8)))
 
diff --git a/lisp/nxml/rng-xsd.el b/lisp/nxml/rng-xsd.el
index 6cd1688fe4..f308b049f3 100644
--- a/lisp/nxml/rng-xsd.el
+++ b/lisp/nxml/rng-xsd.el
@@ -360,7 +360,7 @@ rng-xsd-base64-binary-length
       n)))
 
 (defun rng-xsd-convert-any-uri (string)
-  (and (string-match "\\`\\(?:[^%]\\|%[0-9a-fA-F][0-9a-fA-F]\\)?*\\'" string)
+  (and (string-match "\\`\\(?:[^%]\\|%[0-9a-fA-F][0-9a-fA-F]\\)*\\'" string)
        (string-match "\\`[^#]*\\(?:#[^#]*\\)?\\'" string)
        (string-match "\\`\\(?:[a-zA-Z][-+.A-Za-z0-9]*:.+\\|[^:]*\\(?:[#/?].*\\)?\\)\\'" string)
        string))
diff --git a/lisp/obsolete/pgg.el b/lisp/obsolete/pgg.el
index 86f30a3cf9..18b63fc3ee 100644
--- a/lisp/obsolete/pgg.el
+++ b/lisp/obsolete/pgg.el
@@ -572,7 +572,7 @@ pgg-fetch-key
   (with-current-buffer (get-buffer-create pgg-output-buffer)
     (buffer-disable-undo)
     (erase-buffer)
-    (let ((proto (if (string-match "^[a-zA-Z\\+\\.\\\\-]+:" keyserver)
+    (let ((proto (if (string-match "^[a-zA-Z\\+.-]+:" keyserver)
 		     (substring keyserver 0 (1- (match-end 0))))))
       (save-excursion
 	(funcall pgg-insert-url-function
diff --git a/lisp/obsolete/vip.el b/lisp/obsolete/vip.el
index 9260ee92e5..0360db9bca 100644
--- a/lisp/obsolete/vip.el
+++ b/lisp/obsolete/vip.el
@@ -2187,19 +2187,19 @@ vip-get-ex-token
 	  ((looking-at "%")
 	   (forward-char 1)
 	   (setq ex-token-type "whole"))
-	  ((looking-at "+")
-	   (cond ((or (looking-at "+[-+]") (looking-at "+[\n|]"))
+	  ((looking-at "\\+")
+	   (cond ((looking-at "\\+[-+\n|]")
 		  (forward-char 1)
 		  (insert "1")
 		  (backward-char 1)
 		  (setq ex-token-type "plus"))
-		 ((looking-at "+[0-9]")
+		 ((looking-at "\\+[0-9]")
 		  (forward-char 1)
 		  (setq ex-token-type "plus"))
 		 (t
 		  (error "Badly formed address"))))
 	  ((looking-at "-")
-	   (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]"))
+	   (cond ((looking-at "-[-+\n|]")
 		  (forward-char 1)
 		  (insert "1")
 		  (backward-char 1)
@@ -2520,7 +2520,7 @@ vip-get-ex-file
 		ex-variant t)
 	  (forward-char 2)
 	  (skip-chars-forward " \t")))
-    (if (looking-at "+")
+    (if (looking-at "\\+")
 	(progn
 	  (forward-char 1)
 	  (set-mark (point))
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index 93b8c13aa2..b6c54a92ab 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -2955,7 +2955,7 @@ org-babel-import-elisp-from-file
 (defun org-babel-string-read (cell)
   "Strip nested \"s from around strings."
   (org-babel-read (or (and (stringp cell)
-                           (string-match "\\\"\\(.+\\)\\\"" cell)
+                           (string-match "\"\\(.+\\)\"" cell)
                            (match-string 1 cell))
                       cell) t))
 
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 6593c6d8fa..e416f5f062 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -9446,7 +9446,7 @@ org-agenda-add-entry-to-org-agenda-diary-file
     (goto-char (point-min))
     (cond
      ((eq type 'anniversary)
-      (or (re-search-forward "^*[ \t]+Anniversaries" nil t)
+      (or (re-search-forward "^\\*[ \t]+Anniversaries" nil t)
 	  (progn
 	    (or (org-at-heading-p t)
 		(progn
diff --git a/lisp/org/org-element.el b/lisp/org/org-element.el
index 690dcd139e..04e2fda55e 100644
--- a/lisp/org/org-element.el
+++ b/lisp/org/org-element.el
@@ -2119,7 +2119,7 @@ org-element-keyword-parser
     ;; this corner case.
     (let ((begin (or (car affiliated) (point)))
 	  (post-affiliated (point))
-	  (key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):")
+	  (key (progn (looking-at "[ \t]*#\\+\\(\\S-*\\):")
 		      (upcase (match-string-no-properties 1))))
 	  (value (org-trim (buffer-substring-no-properties
 			    (match-end 0) (point-at-eol))))
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 96c8f55d3a..ef85b402f0 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -2678,7 +2678,7 @@ org-list-indent-item-generic
 		(error "Cannot outdent beyond margin")
 	      ;; Change bullet if necessary.
 	      (when (and (= (+ top-ind offset) 0)
-			 (string-match "*"
+			 (string-match "\\*"
 				       (org-list-get-bullet beg struct)))
 		(org-list-set-bullet beg struct
 				     (org-list-bullet-string "-")))
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el
index 969bff3cc6..a37c41ad06 100644
--- a/lisp/org/org-mhe.el
+++ b/lisp/org/org-mhe.el
@@ -142,7 +142,7 @@ org-mhe-get-message-folder-from-index
   "Return the name of the message folder in an index folder buffer."
   (save-excursion
     (mh-index-previous-folder)
-    (if (re-search-forward "^\\(+.*\\)$" nil t)
+    (if (re-search-forward "^\\(\\+.*\\)$" nil t)
 	(message "%s" (match-string 1)))))
 
 (defun org-mhe-get-message-folder ()
diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
index 1ff6358403..83dcc7b0d1 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -845,11 +845,11 @@ org-mobile-apply
 	    (cl-incf cnt-error)
 	    (throw 'next t))
 	  (move-marker bos-marker (point))
-	  (if (re-search-forward "^** Old value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\*\\* Old value[ \t]*$" eos t)
 	      (setq old (buffer-substring
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading) (point)))))
-	  (if (re-search-forward "^** New value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\*\\* New value[ \t]*$" eos t)
 	      (setq new (buffer-substring
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading)
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el
index ac75decb92..a3dcb77554 100644
--- a/lisp/org/org-mouse.el
+++ b/lisp/org/org-mouse.el
@@ -643,7 +643,7 @@ org-mouse-context-menu
 	 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
 					'org-mode-restart))))
      ((or (eolp)
-	  (and (looking-at "\\(  \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$")
+	  (and (looking-at "\\(  \\|\t\\)\\(\\+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$")
 	       (looking-back "  \\|\t" (- (point) 2)
 			     (line-beginning-position))))
       (org-mouse-popup-global-menu))
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el
index aa34e4011a..a5635e326d 100644
--- a/lisp/org/org-plot.el
+++ b/lisp/org/org-plot.el
@@ -336,7 +336,7 @@ org-plot/gnuplot
                    (insert "\n")
                    (insert-file-contents (plist-get params :script))
                    (goto-char (point-min))
-                   (while (re-search-forward "$datafile" nil t)
+                   (while (re-search-forward "\\$datafile" nil t)
                      (replace-match data-file nil nil)))
 	  (insert (org-plot/gnuplot-script data-file num-cols params)))
 	;; Graph table.
diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el
index c31ac66bac..016105ef53 100644
--- a/lisp/org/org-protocol.el
+++ b/lisp/org/org-protocol.el
@@ -331,7 +331,7 @@ org-protocol-flatten-greedy
 	 (len 0)
 	 dir
 	 ret)
-    (when (string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" trigger)
+    (when (string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-Z0-9][-_a-zA-Z0-9]*:/+\\)\\(.*\\)" trigger)
       (setq dir (match-string 1 trigger))
       (setq len (length dir))
       (setcar l (concat dir (match-string 3 trigger))))
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 765a1ee5c9..b6e864fc9c 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -1182,7 +1182,7 @@ org-table-copy-down
 			      (- (org-time-string-to-absolute txt)
 				 (org-time-string-to-absolute txt-up)))
 			     ((string-match org-ts-regexp3 txt) 1)
-			     ((string-match "\\([-+]\\)?\\(?:[0-9]+\\)?\\(?:\.[0-9]+\\)?" txt-up)
+			     ((string-match "\\([-+]\\)?[0-9]*\\(?:\\.[0-9]+\\)?" txt-up)
 			      (- (string-to-number txt)
 				 (string-to-number (match-string 0 txt-up))))
 			     (t 1)))
@@ -2307,7 +2307,7 @@ org-table-store-formulas
 	      "\n"))))
 
 (defsubst org-table-formula-make-cmp-string (a)
-  (when (string-match "\\`$[<>]" a)
+  (when (string-match "\\`\\$[<>]" a)
     (let ((arrow (string-to-char (substring a 1))))
       ;; Fake a high number to make sure this is sorted at the end.
       (setq a (org-table-formula-handle-first/last-rc a))
@@ -2355,7 +2355,7 @@ org-table-get-stored-formulas
 		       (cond
 			((not (match-end 2)) m)
 			;; Is it a column reference?
-			((string-match-p "\\`$\\([0-9]+\\|[<>]+\\)\\'" m) m)
+			((string-match-p "\\`\\$\\([0-9]+\\|[<>]+\\)\\'" m) m)
 			;; Since named columns are not possible in
 			;; LHS, assume this is a named field.
 			(t (match-string 2 string)))))
@@ -3216,7 +3216,7 @@ org-table-recalculate
 		    (cond
 		     ((string-match "\\`@-?I+" old-lhs)
 		      (user-error "Can't assign to hline relative reference"))
-		     ((string-match "\\`$[<>]" old-lhs)
+		     ((string-match "\\`\\$[<>]" old-lhs)
 		      (let ((new (org-table-formula-handle-first/last-rc
 				  old-lhs)))
 			(when (assoc new eqlist)
@@ -3639,7 +3639,8 @@ org-table-edit-formulas
       (setq startline (org-current-line))
       (dolist (entry eql)
 	(let* ((type (cond
-		      ((string-match "\\`$\\([0-9]+\\|[<>]+\\)\\'" (car entry))
+		      ((string-match "\\`\\$\\([0-9]+\\|[<>]+\\)\\'"
+				     (car entry))
 		       'column)
 		      ((equal (string-to-char (car entry)) ?@) 'field)
 		      (t 'named)))
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 8a11a8f75e..3a434d12df 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -10467,7 +10467,7 @@ org-translate-link-from-planner
    ((and (equal type "lisp") (string-match "^/" path))
     ;; Planner has a slash, we do not.
     (setq type "elisp" path (substring path 1)))
-   ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
+   ((string-match "^//\\(.*\\)/\\(<.*>\\)$" path)
     ;; A typical message link.  Planner has the id after the final slash,
     ;; we separate it with a hash mark
     (setq path (concat (match-string 1 path) "#"
@@ -22838,7 +22838,7 @@ org-fill-line-break-nobreak-p
   (save-excursion
     (skip-chars-backward "[ \t]")
     (skip-chars-backward "\\\\")
-    (looking-at "\\\\\\\\\\($\\|[^\\\\]\\)")))
+    (looking-at "\\\\\\\\\\($\\|[^\\]\\)")))
 
 (defun org-fill-paragraph-with-timestamp-nobreak-p ()
   "Non-nil when a new line at point would split a timestamp."
diff --git a/lisp/org/ox-ascii.el b/lisp/org/ox-ascii.el
index c20536184e..7c9920f64c 100644
--- a/lisp/org/ox-ascii.el
+++ b/lisp/org/ox-ascii.el
@@ -1474,8 +1474,8 @@ org-ascii-item
 		   (replace-regexp-in-string
 		    "-" "•"
 		    (replace-regexp-in-string
-		     "+" "⁃"
-		     (replace-regexp-in-string "*" "‣" bul))))))))
+		     "\\+" "⁃"
+		     (replace-regexp-in-string "\\*" "‣" bul))))))))
 	 (indentation (if (eq list-type 'descriptive) org-ascii-quote-margin
 			(string-width bullet))))
     (concat
diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el
index d3e6286149..d711530bf7 100644
--- a/lisp/org/ox-latex.el
+++ b/lisp/org/ox-latex.el
@@ -1613,7 +1613,7 @@ org-latex-math-block-options-filter
 
 (defun org-latex-clean-invalid-line-breaks (data _backend _info)
   (replace-regexp-in-string
-   "\\(\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
+   "\\(\\\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
    data))
 
 \f
diff --git a/lisp/org/ox.el b/lisp/org/ox.el
index 8813968332..58bc9b0ffb 100644
--- a/lisp/org/ox.el
+++ b/lisp/org/ox.el
@@ -3322,7 +3322,7 @@ org-export-expand-include-keyword
 			   (setq value (replace-match "" nil nil value)))))
 		   (lines
 		    (and (string-match
-			  ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
+			  ":lines +\"\\([0-9]*-[0-9]*\\)\""
 			  value)
 			 (prog1 (match-string 1 value)
 			   (setq value (replace-match "" nil nil value)))))
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el
index 7f0e166328..28c52b0653 100644
--- a/lisp/progmodes/ada-xref.el
+++ b/lisp/progmodes/ada-xref.el
@@ -416,7 +416,7 @@ ada-treat-cmd-string
 file, minus extension but with directory, and ${full_current} is
 replaced by the name including the extension."
 
-  (while (string-match "\\(-[^-$IO]*[IO]\\)?${\\([^}]+\\)}" cmd-string)
+  (while (string-match "\\(-[^-$IO]*[IO]\\)?\\${\\([^}]+\\)}" cmd-string)
     (let (value
 	  (name (match-string 2 cmd-string)))
       (cond
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index a86cb53ceb..efe648bc03 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -852,8 +852,8 @@ cfengine2-font-lock-keywords
     ;; Classes.
     ("^[ \t]*\\([[:alnum:]_().|!]+\\)::" 1 font-lock-function-name-face)
     ;; Variables.
-    ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
-    ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
+    ("\\$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
+    ("\\${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
     ;; Variable definitions.
     ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
     ;; File, acl &c in group:   { token ... }
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index cb69a43b63..0fe4b106c5 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3145,12 +3145,12 @@ cperl-to-comment-or-eol
 		  (cond
 		   ((looking-at "\\(s\\|tr\\)\\>")
 		    (or (re-search-forward
-			 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
+			 "\\=\\w+[ \t]*#\\([^\n\\#]\\|\\\\[\\#]\\)*#\\([^\n\\#]\\|\\\\[\\#]\\)*"
 			 lim 'move)
 			(setq stop-in t)))
 		   ((looking-at "\\(m\\|q\\([qxwr]\\)?\\)\\>")
 		    (or (re-search-forward
-			 "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
+			 "\\=\\w+[ \t]*#\\([^\n\\#]\\|\\\\[\\#]\\)*#"
 			 lim 'move)
 			(setq stop-in t)))
 		   (t			; It was fair comment
@@ -3749,7 +3749,7 @@ cperl-find-pods-heres
 			     state-point b nil nil state)
 		      state-point b)
 		(if (or (nth 3 state) (nth 4 state)
-			(looking-at "\\(cut\\|\\end\\)\\>"))
+			(looking-at "\\(cut\\|end\\)\\>"))
 		    (if (or (nth 3 state) (nth 4 state) ignore-max)
 			nil		; Doing a chunk only
 		      (message "=cut is not preceded by a POD section")
@@ -3762,10 +3762,10 @@ cperl-find-pods-heres
 			b1 nil)		; error condition
 		  ;; We do not search to max, since we may be called from
 		  ;; some hook of fontification, and max is random
-		  (or (re-search-forward "^\n=\\(cut\\|\\end\\)\\>" stop-point 'toend)
+		  (or (re-search-forward "^\n=\\(cut\\|end\\)\\>" stop-point 'toend)
 		      (progn
 			(goto-char b)
-			(if (re-search-forward "\n=\\(cut\\|\\end\\)\\>" stop-point 'toend)
+			(if (re-search-forward "\n=\\(cut\\|end\\)\\>" stop-point 'toend)
 			    (progn
 			      (message "=cut is not preceded by an empty line")
 			      (setq b1 t)
@@ -5003,7 +5003,7 @@ cperl-fix-line-spacing
 	;; Looking at:
 	;; else   {
 	(if (looking-at
-	     "[ \t]*}?[ \t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]")
+	     "[ \t]*}?[ \t]*\\<\\(els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]")
 	    (progn
 	      (forward-word-strictly 1)
 	      (delete-horizontal-space)
@@ -5031,7 +5031,7 @@ cperl-fix-line-spacing
 	;; Looking at (with or without "}" at start, ending after "({"):
 	;; } foreach my $var ()         OR   {
 	(if (looking-at
-	     "[ \t]*\\(}[ \t]*\\)?\\<\\(\\els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([ \t]+\\(state\\|my\\|local\\|our\\)\\)?[ \t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{")
+	     "[ \t]*\\(}[ \t]*\\)?\\<\\(els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([ \t]+\\(state\\|my\\|local\\|our\\)\\)?[ \t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{")
 	    (progn
 	      (setq ml (match-beginning 8)) ; "(" or "{" after control word
 	      (re-search-forward "[({]")
@@ -7347,7 +7347,7 @@ cperl-have-help-regexp
      "-[a-zA-Z]"			; File test
      "\\\\[a-zA-Z0]"			; Special chars
      "^=[a-z][a-zA-Z0-9_]*"		; POD sections
-     "[-!&*+,-./<=>?\\\\^|~]+"		; Operator
+     "[-!&*+,./<=>?\\^|~]+"		; Operator
      "[a-zA-Z_0-9:]+"			; symbol or number
      "x="
      "#!")
@@ -7364,7 +7364,7 @@ cperl-word-at-point-hard
   ;; Does not save-excursion
   ;; Get to the something meaningful
   (or (eobp) (eolp) (forward-char 1))
-  (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
+  (re-search-backward "[-a-zA-Z0-9_:!&*+,./<=>?\\^|~$%@]"
 		      (point-at-bol)
 		      'to-beg)
   ;;  (cond
@@ -7391,8 +7391,8 @@ cperl-word-at-point-hard
     (forward-char -1))
    ((and (looking-at "\\^") (eq (preceding-char) ?\$)) ; $^I
     (forward-char -1))
-   ((looking-at "[-!&*+,-./<=>?\\\\^|~]")
-    (skip-chars-backward "-!&*+,-./<=>?\\\\^|~")
+   ((looking-at "[-!&*+,./<=>?\\^|~]")
+    (skip-chars-backward "-!&*+,./<=>?\\^|~")
     (cond
      ((and (eq (preceding-char) ?\$)
 	   (not (eq (char-after (- (point) 2)) ?\$))) ; $-
@@ -8145,7 +8145,7 @@ cperl-make-regexp-x
       ;; Protect fragile " ", "#"
       (if have-x nil
 	(goto-char (1+ b))
-	(while (re-search-forward "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*[ \t\n#]" e t) ; Need to include (?#) too?
+	(while (re-search-forward "\\(\\=\\|[^\\]\\)\\(\\\\\\\\\\)*[ \t\n#]" e t) ; Need to include (?#) too?
 	  (forward-char -1)
 	  (insert "\\")
 	  (forward-char 1)))
diff --git a/lisp/progmodes/dcl-mode.el b/lisp/progmodes/dcl-mode.el
index 17137cf303..d5803c77bb 100644
--- a/lisp/progmodes/dcl-mode.el
+++ b/lisp/progmodes/dcl-mode.el
@@ -1580,7 +1580,7 @@ dcl-option-value-offset
 Returns the column offset."
   (save-excursion
     (beginning-of-line)
-    (re-search-forward "^$[ \t]*" nil t)
+    (re-search-forward "^\\$[ \t]*" nil t)
     (current-column)))
 
 
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index a2392328ba..c2715be537 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1645,7 +1645,7 @@ tag-implicit-name-match-p
   ;; a textual description of the four rules.
   (and (string-match "^[^ \t()=,;]+$" tag) ;rule #1
        ;; Rules #2 and #4, and a check that there's no explicit name.
-       (looking-at "[ \t()=,;]?\177\\(?:[0-9]+\\)?,\\(?:[0-9]+\\)?$")
+       (looking-at "[ \t()=,;]?\177[0-9]*,[0-9]*$")
        (save-excursion
 	 (backward-char (1+ (length tag)))
 	 (looking-at "[\n \t()=,;]"))))	;rule #3
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index be272c0922..c1a267f4c5 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -2052,7 +2052,7 @@ fortran-fill
                 (when (<= (point) bos)
                   (move-to-column (1+ fill-column))
                   ;; What is this doing???
-                  (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
+                  (or (re-search-forward "[-\t\n,'+./*)=]" eol t)
                       (goto-char bol)))
                 (if (bolp)
                     (re-search-forward "[ \t]" opoint t))
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index b9654dd5c2..75e2deaa4c 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1373,7 +1373,7 @@ gdb-speedbar-expand-node
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node.
 INDENT is the current indentation depth."
-  (cond ((string-match "+" text)        ;expand this node
+  (cond ((string-match "\\+" text)        ;expand this node
 	 (let* ((var (assoc token gdb-var-list))
 		(expr (nth 1 var)) (children (nth 2 var)))
 	   (if (or (<= (string-to-number children) gdb-max-children)
@@ -4153,7 +4153,7 @@ gdb-locals-handler-custom
         (when (not value)
           (setq value "<complex data type>"))
         (if (or (not value)
-                (string-match "\\0x" value))
+                (string-match "0x" value))
             (add-text-properties 0 (length name)
                                  `(mouse-face highlight
                                               help-echo "mouse-2: create watch expression"
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 3fd2a7e701..a5427dd8b7 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -457,13 +457,13 @@ grep-mode-font-lock-keywords
      (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$"
       1 grep-error-face)
      ;; remove match from grep-regexp-alist before fontifying
-     ("^Grep[/a-zA-z]* started.*"
+     ("^Grep[/a-zA-Z]* started.*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t))
-     ("^Grep[/a-zA-z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?matches found\\)\\|\\(no matches found\\)\\).*"
+     ("^Grep[/a-zA-Z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?matches found\\)\\|\\(no matches found\\)\\).*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
       (1 compilation-info-face nil t)
       (2 compilation-warning-face nil t))
-     ("^Grep[/a-zA-z]* \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*"
+     ("^Grep[/a-zA-Z]* \\(exited abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code \\([0-9]+\\)\\)?.*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
       (1 grep-error-face)
       (2 grep-error-face nil t))
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index d8cae41899..92f5205a6d 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2237,7 +2237,7 @@ gud-jdb-find-source-using-classpath
 		    (split-string
 		     ;; Eliminate any subclass references in the class
 		     ;; name string. These start with a "$"
-                     (if (string-match "$.*" p)
+                     (if (string-match "\\$.*" p)
                          (replace-match "" t t p) p)
 		     "\\.") "/")
 	 ".java"))
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 532739daae..f1ec5ceea5 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1838,7 +1838,7 @@ js--continued-expression-p
                   (save-excursion (backward-char) (not (looking-at "[/*]/\\|=>")))
                   (js--looking-at-operator-p)
                   (and (progn (backward-char)
-                              (not (looking-at "+\\+\\|--\\|/[/*]"))))))))))
+                              (not (looking-at "\\+\\+\\|--\\|/[/*]"))))))))))
 
 (defun js--skip-term-backward ()
   "Skip a term before point; return t if a term was skipped."
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el
index 9c9bee1c51..98b812f52f 100644
--- a/lisp/progmodes/m4-mode.el
+++ b/lisp/progmodes/m4-mode.el
@@ -65,7 +65,7 @@ m4-program-options
 (defvar m4-font-lock-keywords
   '(("\\(\\_<\\(m4_\\)?dnl\\_>\\).*$" . font-lock-comment-face)
     ("\\$[*#@0-9]" . font-lock-variable-name-face)
-    ("\\$\\@" . font-lock-variable-name-face)
+    ("\\$@" . font-lock-variable-name-face)
     ("\\$\\*" . font-lock-variable-name-face)
     ("\\_<\\(m4_\\)?\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|ivert\\)\\|ix\\)\\)\\_>" . font-lock-keyword-face))
   "Default `font-lock-keywords' for M4 mode.")
diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el
index 34b8bbbd39..8d3745be7c 100644
--- a/lisp/progmodes/meta-mode.el
+++ b/lisp/progmodes/meta-mode.el
@@ -666,7 +666,7 @@ meta-indent-level-count
       (let ((count 0))
         (narrow-to-region
          (point) (save-excursion
-                   (re-search-forward "[^\\\\\"]%\\|\n\\|\\'" nil t)
+                   (re-search-forward "[^\\\"]%\\|\n\\|\\'" nil t)
                    (backward-char) (point)))
         (while (re-search-forward "\\<\\sw+\\>\\|(\\|)" nil t)
           (save-excursion
diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el
index 1ea4b33093..a759709b5c 100644
--- a/lisp/progmodes/mixal-mode.el
+++ b/lisp/progmodes/mixal-mode.el
@@ -1044,7 +1044,7 @@ mixal-font-lock-keywords
      . mixal-font-lock-operation-code-face)
     (,(regexp-opt mixal-assembly-pseudoinstructions 'words)
      . mixal-font-lock-assembly-pseudoinstruction-face)
-    ("^[A-Z0-9a-z]*[ \t]+[A-ZO-9a-z]+[ \t]+\\(=.*=\\)"
+    ("^[A-Z0-9a-z]*[ \t]+[A-Z0-9a-z]+[ \t]+\\(=.*=\\)"
      (1 font-lock-constant-face)))
   "Keyword highlighting specification for `mixal-mode'.")
 ;; (makunbound 'mixal-font-lock-keywords)
diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el
index 7cc6882f8b..7d51816bf4 100644
--- a/lisp/progmodes/opascal.el
+++ b/lisp/progmodes/opascal.el
@@ -1519,7 +1519,7 @@ opascal-find-unit-in-directory
         (setq dir-name (match-string 1 dir-name)
               recurse t))
     ;; Ensure the trailing slash is removed.
-    (if (string-match "^\\(.+\\)[\\\\/]$" dir-name)
+    (if (string-match "^\\(.+\\)[\\/]$" dir-name)
         (setq dir-name (match-string 1 dir-name)))
     (opascal-search-directory unit dir-name recurse)))
 
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index 81fff826bc..cae514aa75 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -117,7 +117,7 @@ pascal-symbol-re
 (defconst pascal-beg-block-re   "\\<\\(begin\\|case\\|record\\|repeat\\)\\>")
 (defconst pascal-end-block-re   "\\<\\(end\\|until\\)\\>")
 (defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>")
-(defconst pascal-progbeg-re     "\\<\\program\\>")
+(defconst pascal-progbeg-re     "\\<program\\>")
 (defconst pascal-defun-re       "\\<\\(function\\|procedure\\|program\\)\\>")
 (defconst pascal-sub-block-re   "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>")
 (defconst pascal-noindent-re    "\\<\\(begin\\|end\\|until\\|else\\)\\>")
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index e83778af94..e575d6cc16 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -108,7 +108,7 @@ ruby-singleton-class-re
   "Regexp to match the beginning of a heredoc.")
 
   (defconst ruby-expression-expansion-re
-    "\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z \n]\\)\\)"))
+    "\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\]*\\(\\\\.[^}\n\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z \n]\\)\\)"))
 
 (defun ruby-here-doc-end-match ()
   "Return a regexp to find the end of a heredoc.
@@ -929,9 +929,9 @@ ruby-expr-beg
                    (goto-char (match-end 0))
                    (not (looking-at "\\s_")))
                   ((eq option 'expr-qstr)
-                   (looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"))
+                   (looking-at "[a-zA-Z][a-zA-Z0-9_]* +%[^ \t]"))
                   ((eq option 'expr-re)
-                   (looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"))
+                   (looking-at "[a-zA-Z][a-zA-Z0-9_]* +/[^ \t]"))
                   (t nil)))))))))
 
 (defun ruby-forward-string (term &optional end no-error expand)
@@ -1047,7 +1047,7 @@ ruby-parse-partial
        ((looking-at "\\?")              ;skip ?char
         (cond
          ((and (ruby-expr-beg)
-               (looking-at "?\\(\\\\C-\\|\\\\M-\\)*\\\\?."))
+               (looking-at "\\?\\(\\\\C-\\|\\\\M-\\)*\\\\?."))
           (goto-char (match-end 0)))
          (t
           (goto-char pnt))))
@@ -1794,8 +1794,8 @@ ruby-toggle-string-quotes
             (buffer-substring-no-properties (1+ min) (1- max))))
       (setq content
             (if (equal string-quote "'")
-                (replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)'" "\\1\\\\'" content))
-              (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)\"" "\\1\\\\\"" content))))
+                (replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content))
+              (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content))))
       (let ((orig-point (point)))
         (delete-region min max)
         (insert
@@ -2178,7 +2178,7 @@ ruby-font-lock-keywords
           font-lock-constant-face)
         nil t))
     ;; Special globals.
-    (,(concat "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
+    (,(concat "\\$\\(?:[:\"!@;,/._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
               (regexp-opt '("LOAD_PATH" "LOADED_FEATURES" "PROGRAM_NAME"
                             "ERROR_INFO" "ERROR_POSITION"
                             "FS" "FIELD_SEPARATOR"
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 2a42e7f451..6d91d84fa7 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -3225,11 +3225,11 @@ sql--make-help-docstring
   "Return a docstring for `sql-help' listing loaded SQL products."
   (let ((doc sql--help-docstring))
     ;; Insert FREE software list
-    (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*$" doc 0)
+    (when (string-match "^\\(\\s-*\\)[\\][\\]FREE\\s-*$" doc 0)
       (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t)
 			       t t doc 0)))
     ;; Insert non-FREE software list
-    (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*$" doc 0)
+    (when (string-match "^\\(\\s-*\\)[\\][\\]NONFREE\\s-*$" doc 0)
       (setq doc (replace-match (sql-help-list-products (match-string 1 doc) nil)
 			       t t doc 0)))
     doc))
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index a949a461c1..e1003378b2 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -2786,7 +2786,7 @@ verilog-inst-comment-re
 (defconst verilog-behavioral-block-beg-re
   (eval-when-compile (verilog-regexp-words '("initial" "final" "always" "always_comb" "always_latch" "always_ff"
                                              "function" "task"))))
-(defconst verilog-coverpoint-re "\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)"  )
+(defconst verilog-coverpoint-re "\\w+\\s-*:\\s-*\\(coverpoint\\|cross\\constraint\\)"  )
 (defconst verilog-in-constraint-re  ; keywords legal in constraint blocks starting a statement/block
   (eval-when-compile (verilog-regexp-words '("if" "else" "solve" "foreach"))))
 
@@ -6559,7 +6559,7 @@ verilog-skip-forward-comment-p
     (skip-chars-forward " \t\n\f")
     (while
 	(cond
-	 ((looking-at "\\/\\*")
+	 ((looking-at "/\\*")
 	  (progn
 	    (setq h (point))
 	    (goto-char (match-end 0))
@@ -8952,7 +8952,7 @@ verilog-read-sub-decls-gate
 		   (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
 	      ;; On pins, parse and advance to next pin
 	      ;; Looking at pin, but *not* an // Output comment, or ) to end the inst
-	      ((looking-at "\\s-*[a-zA-Z0-9`_$({}\\\\][^,]*")
+	      ((looking-at "\\s-*[a-zA-Z0-9`_$({}\\][^,]*")
 	       (goto-char (match-end 0))
 	       (setq verilog-read-sub-decls-gate-ios (or (car iolist) "input")
 		     iolist (cdr iolist))
@@ -9357,7 +9357,7 @@ verilog-read-auto-template-middle
 	      ;; Regexp form??
 	      ((looking-at
 		;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
-		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
+		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
 	       (setq rep (match-string-no-properties 3))
 	       (goto-char (match-end 0))
 	       (setq tpl-wild-list
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index b8297c4847..1dc0c61d06 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -2474,7 +2474,7 @@ vhdl-project-p
 
 (defun vhdl-resolve-env-variable (string)
   "Resolve environment variables in STRING."
-  (while (string-match "\\(.*\\)${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)" string)
+  (while (string-match "\\(.*\\)\\${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)" string)
     (setq string (concat (match-string 1 string)
 			 (getenv (match-string 2 string))
 			 (match-string 4 string))))
@@ -15115,7 +15115,7 @@ vhdl-speedbar-expand-all
 (defun vhdl-speedbar-expand-project (text token indent)
   "Expand/contract the project under the cursor."
   (cond
-   ((string-match "+" text)		; expand project
+   ((string-match "\\+" text)		; expand project
     (speedbar-change-expand-button-char ?-)
     (unless (member token vhdl-speedbar-shown-project-list)
       (setq vhdl-speedbar-shown-project-list
@@ -15137,7 +15137,7 @@ vhdl-speedbar-expand-project
 (defun vhdl-speedbar-expand-entity (text token indent)
   "Expand/contract the entity under the cursor."
   (cond
-   ((string-match "+" text)		; expand entity
+   ((string-match "\\+" text)		; expand entity
     (let* ((key (vhdl-speedbar-line-key indent))
 	   (ent-alist (vhdl-aget vhdl-entity-alist key))
 	   (ent-entry (vhdl-aget ent-alist token))
@@ -15206,7 +15206,7 @@ vhdl-speedbar-expand-entity
 (defun vhdl-speedbar-expand-architecture (text token indent)
   "Expand/contract the architecture under the cursor."
   (cond
-   ((string-match "+" text)		; expand architecture
+   ((string-match "\\+" text)		; expand architecture
     (let* ((key (vhdl-speedbar-line-key (1- indent)))
 	   (ent-alist (vhdl-aget vhdl-entity-alist key))
 	   (conf-alist (vhdl-aget vhdl-config-alist key))
@@ -15266,7 +15266,7 @@ vhdl-speedbar-expand-architecture
 (defun vhdl-speedbar-expand-config (text token indent)
   "Expand/contract the configuration under the cursor."
   (cond
-   ((string-match "+" text)		; expand configuration
+   ((string-match "\\+" text)		; expand configuration
     (let* ((key (vhdl-speedbar-line-key indent))
 	   (conf-alist (vhdl-aget vhdl-config-alist key))
 	   (conf-entry (vhdl-aget conf-alist token))
@@ -15324,7 +15324,7 @@ vhdl-speedbar-expand-config
 (defun vhdl-speedbar-expand-package (text token indent)
   "Expand/contract the package under the cursor."
   (cond
-   ((string-match "+" text)		; expand package
+   ((string-match "\\+" text)		; expand package
     (let* ((key (vhdl-speedbar-line-key indent))
 	   (pack-alist (vhdl-aget vhdl-package-alist key))
 	   (pack-entry (vhdl-aget pack-alist token))
@@ -15729,7 +15729,7 @@ vhdl-speedbar-insert-dirs
 
 (defun vhdl-speedbar-dired (text token indent)
   "Speedbar click handler for directory expand button in hierarchy mode."
-  (cond ((string-match "+" text)	; we have to expand this dir
+  (cond ((string-match "\\+" text)	; we have to expand this dir
 	 (setq speedbar-shown-directories
 	       (cons (expand-file-name
 		      (concat (speedbar-line-directory indent) token "/"))
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 5a8f300195..46b3f2ea90 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -3353,7 +3353,7 @@ speedbar-dired
 Clicking this button expands or contracts a directory.  TEXT is the
 button clicked which has either a + or -.  TOKEN is the directory to be
 expanded.  INDENT is the current indentation level."
-  (cond ((string-match "+" text)	;we have to expand this dir
+  (cond ((string-match "\\+" text)	;we have to expand this dir
 	 (setq speedbar-shown-directories
 	       (cons (expand-file-name
 		      (concat (speedbar-line-directory indent) token "/"))
@@ -3402,7 +3402,7 @@ speedbar-tag-file
 The parameter TEXT and TOKEN are required, where TEXT is the button
 clicked, and TOKEN is the file to expand.  INDENT is the current
 indentation level."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (let* ((fn (expand-file-name (concat (speedbar-line-directory indent)
 					      token)))
 		(lst (speedbar-fetch-dynamic-tags fn)))
@@ -3443,7 +3443,7 @@ speedbar-tag-expand
   "Expand a tag sublist.  Imenu will return sub-lists of specialized tag types.
 Etags does not support this feature.  TEXT will be the button string.
 TOKEN will be the list, and INDENT is the current indentation level."
-  (cond ((string-match "+" text)	;we have to expand this file
+  (cond ((string-match "\\+" text)	;we have to expand this file
 	 (speedbar-change-expand-button-char ?-)
 	 (speedbar-with-writable
 	   (save-excursion
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index 07463e4e39..b303e1918e 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -114,9 +114,9 @@ dns-mode-class-face
 			"26.1" 'set)
 
 (defcustom dns-mode-font-lock-keywords
-  `((,(concat "^$" (regexp-opt dns-mode-control-entities))
+  `((,(concat "^\\$" (regexp-opt dns-mode-control-entities))
      0 ,dns-mode-control-entity-face)
-    ("^$[a-z0-9A-Z]+" 0 ,dns-mode-bad-control-entity-face)
+    ("^\\$[a-z0-9A-Z]+" 0 ,dns-mode-bad-control-entity-face)
     (,(regexp-opt dns-mode-classes) 0 ,dns-mode-class-face)
     (,(regexp-opt dns-mode-types) 0 ,dns-mode-type-face))
   "Font lock keywords used to highlight text in DNS master file mode."
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 5e6ea52bff..d18916dfd0 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -929,7 +929,7 @@ flyspell-debug-signal-word-checked
                           (or (string= "" ispell-otherchars)
                               (not (looking-at ispell-otherchars)))
                           (or flyspell-consider-dash-as-word-delimiter-flag
-                              (not (looking-at "\\-")))
+                              (not (looking-at "-")))
                           2)))))
        (format "  because    : %S\n"
                (cond
@@ -947,7 +947,7 @@ flyspell-debug-signal-word-checked
                             (or (string= "" ispell-otherchars)
                                 (not (looking-at ispell-otherchars)))
                             (or flyspell-consider-dash-as-word-delimiter-flag
-                                (not (looking-at "\\-")))))))
+                                (not (looking-at "-")))))))
                  ;; Yes because we have reached or typed a word delimiter.
                  'separator)
                 ((not (integerp flyspell-delay))
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index cc8ec2652f..35dae7bc43 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -3475,7 +3475,7 @@ ispell-process-line
             ;; Error in tex mode when a potential math mode change exists.
             (if (and replace (listp replace) (= 2 (length replace)))
                 (if (and (eq ispell-parser 'tex)
-                         (string-match "[\\\\][]()[]\\|\\\\begin\\|\\$"
+                         (string-match "[\\][]()[]\\|\\\\begin\\|\\$"
                                        (regexp-quote string)))
                     (error
                      "Don't start query replace on a line with math characters"
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index 851e46ca2d..5b42b25f77 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -172,7 +172,7 @@ reftex-end-of-bib-entry
         (if item
             (progn (end-of-line)
                    (re-search-forward
-                    "\\\\bibitem\\|\\end{thebibliography}")
+                    "\\\\bibitem\\|\\\\end{thebibliography}")
                    (1- (match-beginning 0)))
           (progn (forward-list 1) (point)))
       (error (min (point-max) (+ 300 (point)))))))
@@ -447,7 +447,7 @@ reftex-get-bib-names
         (setq names (reftex-get-bib-field "editor" entry)))
     (while (string-match "\\band\\b[ \t]*" names)
       (setq names (replace-match "\n" nil t names)))
-    (while (string-match "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+" names)
+    (while (string-match "[-.a-zA-Z]+\\.[ \t]*\\|,.*\\|[{}]+" names)
       (setq names (replace-match "" nil t names)))
     (while (string-match "^[ \t]+\\|[ \t]+$" names)
       (setq names (replace-match "" nil t names)))
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 5833ab32ed..3ec96aa67d 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -308,7 +308,7 @@ reftex-replace-prefix-escapes
   ;; Replace %escapes in a label prefix
   (save-match-data
     (let (letter (num 0) replace)
-      (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
+      (while (string-match "%\\([a-zA-Z]\\)" prefix num)
         (setq letter (match-string 1 prefix))
         (setq replace
               (save-match-data
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index a15ec953f6..1f72f51d76 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -209,7 +209,7 @@ url-generic-parse-url
 	    ;; 3.3. Path
 	    (skip-chars-forward "^?#")
 	    ;; 3.4. Query
-	    (when (looking-at "?")
+	    (when (looking-at "\\?")
 	      (skip-chars-forward "^#"))
 	    (setq file (buffer-substring save-pos (point)))
 	    ;; 3.5 Fragment
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index 1d0ecb4436..cb80ec6cef 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -503,7 +503,7 @@ url-truncate-url-for-viewing
 	 (urlobj nil))
     ;; The first thing that can go are the search strings
     (if (and (>= str-width fr-width)
-	     (string-match "?" url))
+	     (string-match "\\?" url))
 	(setq url (concat (substring url 0 (match-beginning 0)) "?...")
 	      str-width (length url)))
     (if (< str-width fr-width)
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 2c790a2856..40204404e7 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1065,7 +1065,7 @@ diff-unified->context
                             " ----\n" hunk))
 		  ;;(goto-char (point-min))
 		  (forward-line 1)
-		  (if (not (save-excursion (re-search-forward "^+" nil t)))
+		  (if (not (save-excursion (re-search-forward "^\\+" nil t)))
 		      (delete-region (point) (point-max))
 		    (let ((modif nil) (delete nil))
 		      (if (save-excursion (re-search-forward "^\\+.*\n-"
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index e29013cdb4..ab5a449cd3 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -332,7 +332,7 @@ vc-bzr-file-name-relative
          (file-relative-name filename* rootdir))))
 
 (defvar vc-bzr-error-regexp-alist
-  '(("^\\( M[* ]\\|+N \\|-D \\|\\|  \\*\\|R[M ] \\) \\(.+\\)" 2 nil nil 1)
+  '(("^\\( M[* ]\\|\\+N \\|-D \\|\\|  \\*\\|R[M ] \\) \\(.+\\)" 2 nil nil 1)
     ("^C  \\(.+\\)" 2)
     ("^Text conflict in \\(.+\\)" 1 nil nil 2)
     ("^Using saved parent location: \\(.+\\)" 1 nil nil 0))
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index a4ff1cb4cd..3bbd0ed49b 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -910,7 +910,7 @@ vc-cvs-parse-status
 state."
   (let (file status missing)
     (goto-char (point-min))
-    (while (looking-at "? \\(.*\\)")
+    (while (looking-at "\\? \\(.*\\)")
       (setq file (expand-file-name (match-string 1)))
       (vc-file-setprop file 'vc-state 'unregistered)
       (forward-line 1))
diff --git a/lisp/woman.el b/lisp/woman.el
index 38e083a961..a351f788ec 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -2624,7 +2624,7 @@ woman0-el
 	(t				; Ignore -- leave in buffer
 	 ;; This does not work too well, but it's only for debugging!
 	 (skip-chars-forward "^ \t")
-	 (if (looking-at "[ \t]*\\{") (search-forward "\\}"))
+	 (if (looking-at "[ \t]*{") (search-forward "}"))
 	 (forward-line 1))))
 
 ;; request is not used dynamically by any callees.
@@ -2636,7 +2636,7 @@ woman-if-ignore
     ;; Ignore -- leave in buffer
     ;; This does not work too well, but it's only for debugging!
     (skip-chars-forward "^ \t")
-    (if (looking-at "[ \t]*\\{") (search-forward "\\}"))
+    (if (looking-at "[ \t]*{") (search-forward "}"))
     (forward-line 1)))
 
 (defun woman0-so ()
@@ -3268,7 +3268,7 @@ woman-change-fonts
     (while
 	;; Find font requests, paragraph macros and font escapes:
 	(re-search-forward
-	 "^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
+	 "^[.'][ \t]*\\(\\(ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
       (let (font beg notfont fescape)
 	;; Match font indicator and leave point at end of sequence:
 	(cond ((match-beginning 2)
diff --git a/lisp/xdg.el b/lisp/xdg.el
index 65e35b7b35..e5a3de4828 100644
--- a/lisp/xdg.el
+++ b/lisp/xdg.el
@@ -117,7 +117,7 @@ xdg-user-dirs
 (defun xdg--substitute-home-env (str)
   (if (file-name-absolute-p str) str
     (save-match-data
-      (and (string-match "^$HOME/" str)
+      (and (string-match "^\\$HOME/" str)
            (replace-match "~/" t nil str 0)))))
 
 (defun xdg--user-dirs-parse-line ()
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-05  2:04 ` Paul Eggert
@ 2019-03-05  4:30   ` Clément Pit-Claudel
  2019-03-05 15:06   ` Mattias Engdegård
  1 sibling, 0 replies; 14+ messages in thread
From: Clément Pit-Claudel @ 2019-03-05  4:30 UTC (permalink / raw)
  To: emacs-devel

On 04/03/2019 21.04, Paul Eggert wrote:
> A nicer way would be
> for "make check" to run the trawler.

An even nicer way would be to integrate things tightly enough that the byte-compile reports these, possibly when some flag is present :)
This way these errors could be shown by flymake & flycheck.

Clément.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-05  2:04 ` Paul Eggert
  2019-03-05  4:30   ` Clément Pit-Claudel
@ 2019-03-05 15:06   ` Mattias Engdegård
  2019-03-08  6:02     ` Stefan Monnier
  2019-03-08 17:13     ` Paul Eggert
  1 sibling, 2 replies; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-05 15:06 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

5 mars 2019 kl. 03.04 skrev Paul Eggert <eggert@cs.ucla.edu>:
> 
> Thanks for reporting that. I fixed the glitches as best I could by
> applying the attached patch. I didn't see any false alarms, which is good.

Good work!

> It'd be nice if we could catch such typos on a regular basis. Is there
> some easy way to do that? A simple way might be for you to run your
> trawler once a month (say) and report back here. A nicer way would be
> for "make check" to run the trawler.

I can run it periodically but would surely forget. Should I put the trawler in the Emacs source tree (if so, where?), in ELPA, or elsewhere?

As a temporary measure, it now resides at https://github.com/mattiase/trawl, and it has some improvements which uncovered a few more nits. The error locations are now more precise, too.

About that massive change of yours: most of it were obvious, of course, but perhaps you could satisfy my curiosity:

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 8de0103019..2afde7ee75 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -2016,7 +2016,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
       (call-process "lsar" nil t nil "-l" (or file copy))
       (if copy (delete-file copy))
       (goto-char (point-min))
-      (re-search-forward "^\\(\s+=+\s?+\\)+\n")
+      (re-search-forward "^\\(\s+=+\s+\\)+\n")
                                    ^^^
Are you sure this shouldn't be `\s*', which was the previous semantics, or `\s+?', in case it was a transposition mistake?
I suppose the \n at the end makes a non-greedy repetition unlikely.

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 06f7be3da7..fa3abfac58 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -7378,7 +7378,7 @@ groups."
 
 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
 (defcustom gnus-button-valid-localpart-regexp
-  "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
+  "[a-z$%(*-=?[_][^<>\")!;:,{}\n\t @]*"

You kept the rather odd range `*-=' which comprises `*+,-./0123456789:;<='. Is it supposed to be that way?

diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index afc2239fbf..512d49b9c5 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -804,7 +804,7 @@ The 2nd and 3rd arguments BEGIN and END specify the region."
 
     ;; Special Ethiopic punctuation.
     (goto-char (point-min))
-    (while (re-search-forward "\\ce[»\\.\\?]\\|«\\ce" nil t)
+    (while (re-search-forward "\\ce[»\\.?]\\|«\\ce" nil t)

Should `\' really be kept in the set of characters? It looks like it was only included as an attempt to escape `.' and `?'.

diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 43659d2820..c25d787391 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -246,7 +246,7 @@ there, then load the URL at or before point."
   "Find e-mail address around or before point.
 Then search backwards to beginning of line for the start of an e-mail
 address.  If no e-mail address found, return nil."
-  (re-search-backward "[^-_A-z0-9.@]" (line-beginning-position) 'lim)
+  (re-search-backward "[^-_A-Za-z0-9.@]" (line-beginning-position) 'lim)

This is good, but I should just point out that searching for A-z uncovers more suspect regexps, some of which aren't found by the trawler.

diff --git a/lisp/nxml/rng-uri.el b/lisp/nxml/rng-uri.el
index 0e458cfd2f..d8f2884f5e 100644
--- a/lisp/nxml/rng-uri.el
+++ b/lisp/nxml/rng-uri.el
@@ -42,7 +42,7 @@ escape them using %HH."
 
 (defun rng-uri-escape-multibyte (uri)
   "Escape multibyte characters in URI."
-  (replace-regexp-in-string "[:nonascii:]"
+  (replace-regexp-in-string "[[:nonascii:]]"

Lovely one! Here is another one in the same file (line 33), but that wasn't found by the trawler:

	 (replace-regexp-in-string "[\000-\032\177<>#%\"{}|\\^[]`%?;]"

That \032 doesn't look right (number base confusion?), and it looks like it's meant as a single character alternative but it isn't, given the misplaced `]'.

diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
index 1ff6358403..83dcc7b0d1 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -845,11 +845,11 @@ If BEG and END are given, only do this in that region."
 	    (cl-incf cnt-error)
 	    (throw 'next t))
 	  (move-marker bos-marker (point))
-	  (if (re-search-forward "^** Old value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\*\\* Old value[ \t]*$" eos t)

Shouldn't this start with "^\\**", or does it have to be exactly two asterisks?

 	      (setq old (buffer-substring
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading) (point)))))
-	  (if (re-search-forward "^** New value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\*\\* New value[ \t]*$" eos t)

Idem.

--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -10467,7 +10467,7 @@ This is still an experimental function, your mileage may vary."
    ((and (equal type "lisp") (string-match "^/" path))
     ;; Planner has a slash, we do not.
     (setq type "elisp" path (substring path 1)))
-   ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
+   ((string-match "^//\\(.*\\)/\\(<.*>\\)$" path)

Another repetition-of-repetition. Sure it shouldn't be `*?' instead? It looks likely, since there is a `/' following that would be eaten by the `.*' given half a chance.

diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index be272c0922..c1a267f4c5 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -2052,7 +2052,7 @@ If ALL is nil, only match comments that start in column > 0."
                 (when (<= (point) bos)
                   (move-to-column (1+ fill-column))
                   ;; What is this doing???
-                  (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
+                  (or (re-search-forward "[-\t\n,'+./*)=]" eol t)

Where did the . come from? Don't you think that `+-/*' were meant to include those four symbols only?

diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el
index 1ea4b33093..a759709b5c 100644
--- a/lisp/progmodes/mixal-mode.el
+++ b/lisp/progmodes/mixal-mode.el
@@ -1044,7 +1044,7 @@ EXECUTION-TIME holds info about the time it takes, number or string.")
      . mixal-font-lock-operation-code-face)
     (,(regexp-opt mixal-assembly-pseudoinstructions 'words)
      . mixal-font-lock-assembly-pseudoinstruction-face)
-    ("^[A-Z0-9a-z]*[ \t]+[A-ZO-9a-z]+[ \t]+\\(=.*=\\)"
+    ("^[A-Z0-9a-z]*[ \t]+[A-Z0-9a-z]+[ \t]+\\(=.*=\\)"

Another glorious regexp!

diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index a949a461c1..e1003378b2 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -9357,7 +9357,7 @@ Returns REGEXP and list of ( (signal_name connection_name)... )."
 	      ;; Regexp form??
 	      ((looking-at
 		;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
-		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
+		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
 	       (setq rep (match-string-no-properties 3))
 	       (goto-char (match-end 0))
 	       (setq tpl-wild-list

Are you sure that | shouldn't be there too? Or is this some kind of XEmacs idiom?




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
       [not found] <20190305112504.D97DD1EC@emma.svaha.wsnyder.org>
@ 2019-03-05 15:35 ` Wilson Snyder
  2019-03-05 16:12   ` Mattias Engdegård
  2019-03-07 17:39   ` Paul Eggert
  0 siblings, 2 replies; 14+ messages in thread
From: Wilson Snyder @ 2019-03-05 15:35 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

Paul et al, thanks for this cleanup:

> * commit 3c94c7bc02fcacb4a101188dddb0c44d53444178
>   Author:     Paul Eggert <eggert@cs.ucla.edu>
>       Fix regular-expression glitches and typos

This though failed the verilog-mode.el internal tests due to this:

> -		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
> +		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")

Which removed | from the character class.  I committed a fix for this, but
you may want to check the other files patched.

Thanks.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-05 15:35 ` Wilson Snyder
@ 2019-03-05 16:12   ` Mattias Engdegård
  2019-03-07 17:39   ` Paul Eggert
  1 sibling, 0 replies; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-05 16:12 UTC (permalink / raw)
  To: Wilson Snyder; +Cc: Paul Eggert, emacs-devel

5 mars 2019 kl. 16.35 skrev Wilson Snyder <wsnyder@wsnyder.org>:
> 
> Paul et al, thanks for this cleanup:
> 
>> * commit 3c94c7bc02fcacb4a101188dddb0c44d53444178
>>  Author:     Paul Eggert <eggert@cs.ucla.edu>
>>      Fix regular-expression glitches and typos
> 
> This though failed the verilog-mode.el internal tests due to this:
> 
>> -		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
>> +		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
> 
> Which removed | from the character class.  I committed a fix for this, but
> you may want to check the other files patched.

-(defconst verilog-coverpoint-re "\\w+\\s-*:\\s-*\\(coverpoint\\|cross\\constraint\\)"  )
+(defconst verilog-coverpoint-re "\\w+\\s*:\\s*\\(coverpoint\\|cross\\|constraint\\)")

I don't think "\\s*" matches anything, since * is not a syntax class character. The regexp engine doesn't complain, but it probably should. What do you want it to match?




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-05 15:35 ` Wilson Snyder
  2019-03-05 16:12   ` Mattias Engdegård
@ 2019-03-07 17:39   ` Paul Eggert
  1 sibling, 0 replies; 14+ messages in thread
From: Paul Eggert @ 2019-03-07 17:39 UTC (permalink / raw)
  To: Wilson Snyder; +Cc: emacs-devel

On 3/5/19 7:35 AM, Wilson Snyder wrote:
> Paul et al, thanks for this cleanup:
>
>> * commit 3c94c7bc02fcacb4a101188dddb0c44d53444178
>>   Author:     Paul Eggert <eggert@cs.ucla.edu>
>>       Fix regular-expression glitches and typos
> This though failed the verilog-mode.el internal tests due to this:
>
>> -		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
>> +		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
> Which removed | from the character class.

Actually, that patch didn't remove | from the character class, since
[|---] matches only "-", as the "|--" in the pattern does not match
anything since "|" comes after "-" in ASCII.

However, I see you adjusted the regular expression later to add | to the
character class in a different way, so I assume it's OK now. (I don't
know Verilog.)

It is a little puzzling that the patch caused the verilog-mode.el
internal tests to fail, since the failure couldn't have been due to this
part of the patch. My guess is that some other part of the patch was the
culprit, but whatever it was I guess you fixed it. Sorry about the glitch.

By the way, is it still important for verilog-mode.el to support XEmacs?
I thought that XEmacs was kind of dead. If we didn't need to cater to
XEmacs's regular-expression bugs we could simplify that regular expression.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-05 15:06   ` Mattias Engdegård
@ 2019-03-08  6:02     ` Stefan Monnier
  2019-03-08 17:13     ` Paul Eggert
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2019-03-08  6:02 UTC (permalink / raw)
  To: emacs-devel

> I can run it periodically but would surely forget. Should I put the
> trawler in the Emacs source tree (if so, where?), in ELPA,
> or elsewhere?

At the very least, you can put it somewhere in Emacs's `admin`
subdirectory (if we assume its usefulness is currently limited to
Emacs's own maintenance).

I hope someone takes up the challenge to make it work with flymake (via
byte-compile ideally, or via some other means otherwise).


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Scan of regexp mistakes
  2019-03-05 15:06   ` Mattias Engdegård
  2019-03-08  6:02     ` Stefan Monnier
@ 2019-03-08 17:13     ` Paul Eggert
  2019-03-09 12:36       ` Mattias Engdegård
  2019-03-09 13:09       ` Mattias Engdegård
  1 sibling, 2 replies; 14+ messages in thread
From: Paul Eggert @ 2019-03-08 17:13 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 5271 bytes --]

On 3/5/19 7:06 AM, Mattias Engdegård wrote:
>
> I can run it periodically but would surely forget. Should I put the trawler in the Emacs source tree (if so, where?), in ELPA, or elsewhere?

Stefan mentioned one possibility. Though even then I daresay it'd be
helpful if you ran it periodically, just as I periodically run
admin/merge-gnulib. (If you don't run it, it's likely nobody else will....)


> -      (re-search-forward "^\\(\s+=+\s?+\\)+\n")
> +      (re-search-forward "^\\(\s+=+\s+\\)+\n")
>                                     ^^^
> Are you sure this shouldn't be `\s*'

No, good point. I'll change it to that. See attached patch.


> -  "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
> +  "[a-z$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
>
> You kept the rather odd range `*-=' which comprises `*+,-./0123456789:;<='. Is it supposed to be that way?

Goodness knows what is intended here, as this is some ad hoc variant of
RFC 5322/2822/822 and I don't know which variant. Might as well spell
out the range in a more-conventional way, though. The attached patch
replaces *-= with *+./= (as ,:;< aren't allowed unquoted in RFC 5322
atoms) and puts - and 0-9 elsewhere; this should be closer to what was
wanted and should be clearer anyway. I was unable to track down whatever
suggestion was made by Felix Wiemann long ago, and so removed that
comment (since the regexp no longer matches his suggestion anyway).


> -    (while (re-search-forward "\\ce[»\\.\\?]\\|«\\ce" nil t)
> +    (while (re-search-forward "\\ce[»\\.?]\\|«\\ce" nil t)
>
> Should `\' really be kept in the set of characters? It looks like it was only included as an attempt to escape `.' and `?'.

Yes, probably. Fixed in the attached.


> searching for A-z uncovers more suspect regexps, some of which aren't found by the trawler.

I wonder where those all came from? I attempted to fix them in the attached.


> Here is another one in the same file (line 33), but that wasn't found by the trawler:
>
> 	 (replace-regexp-in-string "[\000-\032\177<>#%\"{}|\\^[]`%?;]"
>
> That \032 doesn't look right (number base confusion?), and it looks like it's meant as a single character alternative but it isn't, given the misplaced `]'.

The regexp has other troubles. It doesn't include !$'()*+,/:@&= (all of
which are reserved characters according to RFC 3986), and it has
duplicate %. The attached patch fixes the % and puts in a FIXME about
the other chars.


> diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
> index 1ff6358403..83dcc7b0d1 100644
> --- a/lisp/org/org-mobile.el
> +++ b/lisp/org/org-mobile.el
> @@ -845,11 +845,11 @@ If BEG and END are given, only do this in that region."
>  	    (cl-incf cnt-error)
>  	    (throw 'next t))
>  	  (move-marker bos-marker (point))
> -	  (if (re-search-forward "^** Old value[ \t]*$" eos t)
> +	  (if (re-search-forward "^\\*\\* Old value[ \t]*$" eos t)
>
> Shouldn't this start with "^\\**", or does it have to be exactly two asterisks?
>
>  	      (setq old (buffer-substring
>  			 (1+ (match-end 0))
>  			 (progn (outline-next-heading) (point)))))
> -	  (if (re-search-forward "^** New value[ \t]*$" eos t)
> +	  (if (re-search-forward "^\\*\\* New value[ \t]*$" eos t)
>
> Idem.

"\\**" would be safer, yes. Fixed in the attached.


> -   ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
> +   ((string-match "^//\\(.*\\)/\\(<.*>\\)$" path)
>
> Another repetition-of-repetition. Sure it shouldn't be `*?' instead? It looks likely, since there is a `/' following that would be eaten by the `.*' given half a chance.

The comment on the next line says "Planner has the id after the final
slash", which implies that the first .* should indeed be greedy.


>
> diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
> index be272c0922..c1a267f4c5 100644
> --- a/lisp/progmodes/fortran.el
> +++ b/lisp/progmodes/fortran.el
> @@ -2052,7 +2052,7 @@ If ALL is nil, only match comments that start in column > 0."
>                  (when (<= (point) bos)
>                    (move-to-column (1+ fill-column))
>                    ;; What is this doing???
> -                  (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
> +                  (or (re-search-forward "[-\t\n,'+./*)=]" eol t)
>
> Where did the . come from? Don't you think that `+-/*' were meant to include those four symbols only?

I couldn't figure out what the code was doing (note the comment...) so
decided to preserve the semantics of the old regexp. But you're right,
"." is likely not intended there. I removed it in the attached.


>  		;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
> -		"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
> +		"\\s-*\\.\\(\\([-a-zA-Z0-9`_$+@^.*?]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
>  	       (setq rep (match-string-no-properties 3))
>  	       (goto-char (match-end 0))
>  	       (setq tpl-wild-list
>
> Are you sure that | shouldn't be there too? Or is this some kind of XEmacs idiom?
>
You're right. Wilson Snyder later stepped in and fixed that string. Nice
to have a real expert in the house.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-More-regexp-corrections-and-tweaks.patch --]
[-- Type: text/x-patch; name="0001-More-regexp-corrections-and-tweaks.patch", Size: 9246 bytes --]

From 03d2da31d311def9773ede09b6ad89b094c61805 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 8 Mar 2019 09:08:46 -0800
Subject: [PATCH] More regexp corrections and tweaks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From suggestions by Mattias Engdegård in:
https://lists.gnu.org/r/emacs-devel/2019-03/msg00131.html
* lisp/arc-mode.el (archive-rar-summarize):
* lisp/gnus/gnus-art.el (gnus-button-valid-localpart-regexp):
* lisp/language/ethio-util.el (ethio-fidel-to-tex-buffer):
* lisp/nxml/rng-uri.el (rng-file-name-uri):
* lisp/org/org-mobile.el (org-mobile-apply):
* lisp/progmodes/cperl-mode.el (cperl-init-faces):
* lisp/progmodes/fortran.el (fortran-fill):
* lisp/progmodes/mantemp.el (mantemp-remove-comments)
(mantemp-remove-memfuncs, mantemp-insert-cxx-syntax):
* lisp/speedbar.el (speedbar-directory-buttons-follow):
* lisp/vc/add-log.el (change-log-font-lock-keywords):
Fix more regular expressions that seem to be typos or infelicities.
---
 lisp/arc-mode.el             | 2 +-
 lisp/gnus/gnus-art.el        | 3 +--
 lisp/language/ethio-util.el  | 2 +-
 lisp/nxml/rng-uri.el         | 7 ++++---
 lisp/org/org-mobile.el       | 4 ++--
 lisp/progmodes/cperl-mode.el | 4 ++--
 lisp/progmodes/fortran.el    | 2 +-
 lisp/progmodes/mantemp.el    | 8 ++++----
 lisp/speedbar.el             | 2 +-
 lisp/vc/add-log.el           | 2 +-
 10 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 2afde7ee75..6a58d61a54 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -2016,7 +2016,7 @@ archive-rar-summarize
       (call-process "lsar" nil t nil "-l" (or file copy))
       (if copy (delete-file copy))
       (goto-char (point-min))
-      (re-search-forward "^\\(\s+=+\s+\\)+\n")
+      (re-search-forward "^\\(\s+=+\s*\\)+\n")
       (while (looking-at (concat "^\s+[0-9.]+\s+D?-+\s+"   ; Flags
                                  "\\([0-9-]+\\)\s+"        ; Size
                                  "\\([-0-9.%]+\\|-+\\)\s+" ; Ratio
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index fa3abfac58..baf44cb483 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -7376,9 +7376,8 @@ gnus-button-valid-fqdn-regexp
   :group 'gnus-article-buttons
   :type 'regexp)
 
-;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
 (defcustom gnus-button-valid-localpart-regexp
-  "[a-z$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
+  "[-a-z0-9$%(*+./=?[_][^<>\")!;:,{}\n\t @]*"
   "Regular expression that matches a localpart of mail addresses or MIDs."
   :version "22.1"
   :group 'gnus-article-buttons
diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index 512d49b9c5..04b15ddd9a 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -804,7 +804,7 @@ ethio-fidel-to-tex-buffer
 
     ;; Special Ethiopic punctuation.
     (goto-char (point-min))
-    (while (re-search-forward "\\ce[»\\.?]\\|«\\ce" nil t)
+    (while (re-search-forward "\\ce[».?]\\|«\\ce" nil t)
       (cond
        ((= (setq ch (preceding-char)) ?\»)
 	(delete-char -1)
diff --git a/lisp/nxml/rng-uri.el b/lisp/nxml/rng-uri.el
index d8f2884f5e..798475bbc3 100644
--- a/lisp/nxml/rng-uri.el
+++ b/lisp/nxml/rng-uri.el
@@ -30,9 +30,10 @@ rng-file-name-uri
 escape them using %HH."
   (setq f (expand-file-name f))
   (let ((url
-	 (replace-regexp-in-string "[\000-\032\177<>#%\"{}|\\^[]`%?;]"
-				   'rng-percent-encode
-				   f)))
+	 ;; FIXME. Explain why the pattern doesn't also have "!$&'()*+,/:@=".
+	 ;; See Internet RFC 3986 section 2.2.
+	 (replace-regexp-in-string "[]\0-\s\"#%;<>?[\\^`{|}\177]"
+				   'rng-percent-encode f)))
     (concat "file:"
 	    (if (and (> (length url) 0)
 		     (= (aref url 0) ?/))
diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
index 83dcc7b0d1..8b4e895388 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -845,11 +845,11 @@ org-mobile-apply
 	    (cl-incf cnt-error)
 	    (throw 'next t))
 	  (move-marker bos-marker (point))
-	  (if (re-search-forward "^\\*\\* Old value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\** Old value[ \t]*$" eos t)
 	      (setq old (buffer-substring
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading) (point)))))
-	  (if (re-search-forward "^\\*\\* New value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\** New value[ \t]*$" eos t)
 	      (setq new (buffer-substring
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading)
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 0fe4b106c5..a9402e17a9 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -5736,9 +5736,9 @@ cperl-init-faces
 			 (if (eq (char-after (cperl-1- (match-end 0))) ?\{ )
 			     'font-lock-function-name-face
 			   'font-lock-variable-name-face))))
-	    '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t;]" ; require A if B;
+	    '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t;]" ; require A if B;
 	      2 font-lock-function-name-face)
-	    '("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
+	    '("^[ \t]*format[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t]*=[ \t]*$"
 	      1 font-lock-function-name-face)
 	    (cond ((featurep 'font-lock-extra)
 		   '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index c1a267f4c5..b8aa521cf6 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -2052,7 +2052,7 @@ fortran-fill
                 (when (<= (point) bos)
                   (move-to-column (1+ fill-column))
                   ;; What is this doing???
-                  (or (re-search-forward "[-\t\n,'+./*)=]" eol t)
+                  (or (re-search-forward "[-\t\n,'+/*)=]" eol t)
                       (goto-char bol)))
                 (if (bolp)
                     (re-search-forward "[ \t]" opoint t))
diff --git a/lisp/progmodes/mantemp.el b/lisp/progmodes/mantemp.el
index 9beeb4aae6..4190a84727 100644
--- a/lisp/progmodes/mantemp.el
+++ b/lisp/progmodes/mantemp.el
@@ -89,7 +89,7 @@ mantemp-remove-comments
   (save-excursion
     (goto-char (point-min))
     (message "Removing comments")
-    (while (re-search-forward "^[A-z.()+0-9: ]*`\\|'.*$" nil t)
+    (while (re-search-forward "^[a-zA-Z.()+0-9: ]*`\\|'.*$" nil t)
       (replace-match ""))))
 
 (defun mantemp-remove-memfuncs ()
@@ -99,14 +99,14 @@ mantemp-remove-memfuncs
     (goto-char (point-min))
     (message "Removing member function extensions")
     (while (re-search-forward
-	    "^[A-z :&*<>~=,0-9+]*>::operator " nil t nil)
+	    "^[a-zA-Z :&*<>~=,0-9+]*>::operator " nil t nil)
       (progn
 	(backward-char 11)
 	(delete-region (point) (line-end-position))))
     ;; Remove other member function extensions.
     (goto-char (point-min))
     (message "Removing member function extensions")
-    (while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil)
+    (while (re-search-forward "^[a-zA-Z :&*<>~=,0-9+]*>::" nil t nil)
       (progn
 	(backward-char 2)
 	(delete-region (point) (line-end-position))))))
@@ -154,7 +154,7 @@ mantemp-insert-cxx-syntax
     (goto-char (point-min))
     (message "Inserting 'template' for functions")
     (while (re-search-forward
-	    "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil)
+	    "^template class [a-zA-Z :&*<>~=,0-9+!]*(" nil t nil)
       (progn
 	(beginning-of-line)
 	(forward-word-strictly 1)
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 46b3f2ea90..a7fd564e94 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -3388,7 +3388,7 @@ speedbar-directory-buttons-follow
   "Speedbar click handler for default directory buttons.
 TEXT is the button clicked on.  TOKEN is the directory to follow.
 INDENT is the current indentation level and is unused."
-  (if (string-match "^[A-z]:$" token)
+  (if (string-match "^[A-Za-z]:$" token)
       (setq default-directory (concat token "/"))
     (setq default-directory token))
   ;; Because we leave speedbar as the current buffer,
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index 9fe06bbf52..f9efd44c5c 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -239,7 +239,7 @@ change-log-font-lock-keywords
     ;; wrongly with a non-date line existing as a random note.  In
     ;; addition, using any kind of fixed setting like this doesn't
     ;; work if a user customizes add-log-time-format.
-    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
+    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-Z][a-z][a-z] [0-9:+ ]+"
      (0 'change-log-date)
      ;; Name and e-mail; some people put e-mail in parens, not angles.
      ("\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" nil nil
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-08 17:13     ` Paul Eggert
@ 2019-03-09 12:36       ` Mattias Engdegård
  2019-03-09 17:14         ` Paul Eggert
  2019-03-09 13:09       ` Mattias Engdegård
  1 sibling, 1 reply; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-09 12:36 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

8 mars 2019 kl. 18.13 skrev Paul Eggert <eggert@cs.ucla.edu>:
> 
> On 3/5/19 7:06 AM, Mattias Engdegård wrote:
>> 
>> I can run it periodically but would surely forget. Should I put the trawler in the Emacs source tree (if so, where?), in ELPA, or elsewhere?
> 
> Stefan mentioned one possibility. Though even then I daresay it'd be
> helpful if you ran it periodically, just as I periodically run
> admin/merge-gnulib. (If you don't run it, it's likely nobody else will....)

You are both right. I shall try to run it periodically but also see if it can be integrated into `make check'.
It depends on an ELPA package (xr); does this require any special treatment? We don't want `make check' to fail if xr isn't installed.

Thanks for your updates, and I agree with your changes.

>> 	 (replace-regexp-in-string "[\000-\032\177<>#%\"{}|\\^[]`%?;]"
>> 
>> That \032 doesn't look right (number base confusion?), and it looks like it's meant as a single character alternative but it isn't, given the misplaced `]'.
> 
> The regexp has other troubles. It doesn't include !$'()*+,/:@&= (all of
> which are reserved characters according to RFC 3986), and it has
> duplicate %. The attached patch fixes the % and puts in a FIXME about
> the other chars.

Thank you. It annoyed me that I couldn't catch this regexp with any formal rule violation (maybe we should try tax evasion). An ad-hoc pattern to catch [...[...]...] did work, and caught nothing else, but I was afraid it would become a false positive in legitimate patterns.

>> --- a/lisp/progmodes/fortran.el
>> +++ b/lisp/progmodes/fortran.el
>> @@ -2052,7 +2052,7 @@ If ALL is nil, only match comments that start in column > 0."
>>                 (when (<= (point) bos)
>>                   (move-to-column (1+ fill-column))
>>                   ;; What is this doing???
>> -                  (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
>> +                  (or (re-search-forward "[-\t\n,'+./*)=]" eol t)
>> 
>> Where did the . come from? Don't you think that `+-/*' were meant to include those four symbols only?
> 
> I couldn't figure out what the code was doing (note the comment...) so
> decided to preserve the semantics of the old regexp. But you're right,
> "." is likely not intended there. I removed it in the attached.

It appears to look for the first good place to desperately break a line that is already indented beyond the margin, using a convention of breaking after binary operators. From this point of view, excluding . is probably correct, lest we split .EQ. . I can't really explain the "\t\n')" part; in particular, the search bound should make it impossible for \n to match. It still mangles some things: for instance,

  ALPHA**BETA

is line-broken as

  ALPHA*
  *BETA

Thus we might want to improve the regexp to (rx (or "**" (any "\t\n,')=*/+-"))), but we should really ask a Fortran expert.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-08 17:13     ` Paul Eggert
  2019-03-09 12:36       ` Mattias Engdegård
@ 2019-03-09 13:09       ` Mattias Engdegård
  2019-03-09 17:12         ` Paul Eggert
  1 sibling, 1 reply; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-09 13:09 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

8 mars 2019 kl. 18.13 skrev Paul Eggert <eggert@cs.ucla.edu>:
> 
>> searching for A-z uncovers more suspect regexps, some of which aren't found by the trawler.
> 
> I wonder where those all came from? I attempted to fix them in the attached.

Very good, thanks, just this last one:

--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -239,7 +239,7 @@ a case simply use the directory containing the changed file."
     ;; wrongly with a non-date line existing as a random note.  In
     ;; addition, using any kind of fixed setting like this doesn't
     ;; work if a user customizes add-log-time-format.
-    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
+    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-Z][a-z][a-z] [0-9:+ ]+"

The [A-z] should become [A-Za-z] rather than [A-Z], right?




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-09 13:09       ` Mattias Engdegård
@ 2019-03-09 17:12         ` Paul Eggert
  2019-03-09 20:16           ` Mattias Engdegård
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Eggert @ 2019-03-09 17:12 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård wrote:
> --- a/lisp/vc/add-log.el
> +++ b/lisp/vc/add-log.el
> @@ -239,7 +239,7 @@ a case simply use the directory containing the changed file."
>       ;; wrongly with a non-date line existing as a random note.  In
>       ;; addition, using any kind of fixed setting like this doesn't
>       ;; work if a user customizes add-log-time-format.
> -    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
> +    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-Z][a-z][a-z] [0-9:+ ]+"
> 
> The [A-z] should become [A-Za-z] rather than [A-Z], right?

 From context I think not. It's trying to match a particular English-language 
date format where month-name abbreviations are always capitalized. The author 
was too lazy to list the twelve abbreviations.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-09 12:36       ` Mattias Engdegård
@ 2019-03-09 17:14         ` Paul Eggert
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Eggert @ 2019-03-09 17:14 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård wrote:
> It depends on an ELPA package (xr); does this require any special treatment? We don't want `make check' to fail if xr isn't installed.

Right, so the special treatment would be to skip the test if xr is not already 
installed. We don't want Emacs to download xr if not available, as 'make check' 
shouldn't try to use the network.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Scan of regexp mistakes
  2019-03-09 17:12         ` Paul Eggert
@ 2019-03-09 20:16           ` Mattias Engdegård
  0 siblings, 0 replies; 14+ messages in thread
From: Mattias Engdegård @ 2019-03-09 20:16 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

9 mars 2019 kl. 18.12 skrev Paul Eggert <eggert@cs.ucla.edu>:
> 
> Mattias Engdegård wrote:
>> -    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] [0-9:+ ]+"
>> +    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t \\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-Z][a-z][a-z] [0-9:+ ]+"
>> The [A-z] should become [A-Za-z] rather than [A-Z], right?
> 
> From context I think not. It's trying to match a particular English-language date format where month-name abbreviations are always capitalized. The author was too lazy to list the twelve abbreviations.

You are right, and a smaller regexp (in the size of the matched language) is preferable -- especially as the preceding comment is worried about accidental matches. Thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-03-09 20:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-03 18:01 Scan of regexp mistakes Mattias Engdegård
2019-03-05  2:04 ` Paul Eggert
2019-03-05  4:30   ` Clément Pit-Claudel
2019-03-05 15:06   ` Mattias Engdegård
2019-03-08  6:02     ` Stefan Monnier
2019-03-08 17:13     ` Paul Eggert
2019-03-09 12:36       ` Mattias Engdegård
2019-03-09 17:14         ` Paul Eggert
2019-03-09 13:09       ` Mattias Engdegård
2019-03-09 17:12         ` Paul Eggert
2019-03-09 20:16           ` Mattias Engdegård
     [not found] <20190305112504.D97DD1EC@emma.svaha.wsnyder.org>
2019-03-05 15:35 ` Wilson Snyder
2019-03-05 16:12   ` Mattias Engdegård
2019-03-07 17:39   ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).