]> git.eshelyaron.com Git - emacs.git/commitdiff
Add and remove backslashes in regexps
authorMattias Engdegård <mattiase@acm.org>
Mon, 17 Feb 2020 17:26:47 +0000 (18:26 +0100)
committerMattias Engdegård <mattiase@acm.org>
Thu, 20 Feb 2020 15:03:30 +0000 (16:03 +0100)
These irregularities were found by relint; see
https://lists.gnu.org/archive/html/emacs-devel/2020-01/msg00949.html .

* doc/lispref/modes.texi (Example Major Modes):
* etc/srecode/el.srt:
* lisp/cedet/data-debug.el (data-debug-mode):
* lisp/cedet/semantic/grammar.el (semantic-grammar-mode):
* lisp/cedet/srecode/srt-mode.el (srecode-template-mode):
* lisp/comint.el (comint--unquote&requote-argument):
* lisp/emacs-lisp/lisp-mode.el (lisp-mode):
* lisp/gnus/mm-uu.el (mm-uu-type-alist):
* lisp/progmodes/cc-awk.el (c-awk-harmless-pattern-characters*):
* lisp/progmodes/cfengine.el (cfengine-common-settings):
* lisp/progmodes/cperl-mode.el (cperl-after-sub-regexp, cperl-init-faces):
* lisp/shell.el (shell-chdrive-regexp, shell--unquote&requote-argument):
* lisp/textmodes/tex-mode.el (tex-common-initialization):
Remove duplicated backslashes in character alternatives.

* lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2):
* lisp/progmodes/opascal.el (opascal--syntax-propertize):
* lisp/progmodes/pascal.el (pascal--syntax-propertize):
Remove backslashes escaping non-special characters.

* lisp/progmodes/fortran.el (fortran-font-lock-keywords-3): Escape '*'.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Escape '^'.

17 files changed:
doc/lispref/modes.texi
etc/srecode/el.srt
lisp/cedet/data-debug.el
lisp/cedet/semantic/grammar.el
lisp/cedet/srecode/srt-mode.el
lisp/comint.el
lisp/emacs-lisp/lisp-mode.el
lisp/gnus/mm-uu.el
lisp/progmodes/cc-awk.el
lisp/progmodes/cfengine.el
lisp/progmodes/cperl-mode.el
lisp/progmodes/fortran.el
lisp/progmodes/opascal.el
lisp/progmodes/pascal.el
lisp/progmodes/perl-mode.el
lisp/shell.el
lisp/textmodes/tex-mode.el

index f380f1669e0bb2a67c578af2b7a688d7200b9d9f..f8cf4578fc2f26d1e6861ce6c3de9f458714833f 100644 (file)
@@ -1428,7 +1428,7 @@ or to switch back to an existing one."
   (lisp-mode-variables nil t)
   (setq-local find-tag-default-function 'lisp-find-tag-default)
   (setq-local comment-start-skip
-              "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
+              "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
   (setq imenu-case-fold-search t))
 @end group
 @end smallexample
index 3473fb693c172884a9df334aee6ea982a13c2929..7d5c64c86c0192856ab891a9a3df7f7213696983 100644 (file)
@@ -102,7 +102,7 @@ $<MODEFCN:declaration:function$
        comment-start ";;"
        comment-end "")
   (set (make-local-variable 'comment-start-skip)
-       "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+       "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
   (set-syntax-table $MODESYM$-mode-syntax-table)
   (use-local-map $MODESYM$-mode-map)
   (set (make-local-variable 'font-lock-defaults)
index 78a72dd889c5a23b5b71154efd14d1f0db3215ec..075e122e79dbe064d5200fbaf077b3654b762949 100644 (file)
@@ -880,7 +880,7 @@ If PARENT is non-nil, it is somehow related as a parent to thing."
        comment-end ""
        buffer-read-only t)
   (setq-local comment-start-skip
-       "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+       "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
   (buffer-disable-undo)
   (set (make-local-variable 'font-lock-global-modes) nil)
   (font-lock-mode -1)
index 62c86f9d12d6fcf820a7300794b779dce8ae26f0..2c3b24b9b16f344cd291fa2e0063621ea2280f9f 100644 (file)
@@ -1306,7 +1306,7 @@ the change bounds to encompass the whole nonterminal tag."
   ;; Look within the line for a ; following an even number of backslashes
   ;; after either a non-backslash or the line beginning.
   (set (make-local-variable 'comment-start-skip)
-       "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+       "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
   (set (make-local-variable 'indent-line-function)
        'semantic-grammar-indent)
   (set (make-local-variable 'fill-paragraph-function)
index 6b8c3034a4cf4aa7c52a495660430ef00be174bb..4c1e030fceb9df071f5fc47e3456294be23b7fab 100644 (file)
@@ -195,7 +195,7 @@ we can tell font lock about them.")
   (set (make-local-variable 'comment-end) "")
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
   (set (make-local-variable 'comment-start-skip)
-       "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+       "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
   (set (make-local-variable 'font-lock-defaults)
        '(srecode-font-lock-keywords
          nil  ;; perform string/comment fontification
index bf376a0b81c8acbdaadc0f69d1d43f03aa694a4f..5c521ff0fdf63e71f2ce3dc6fa4a2128987d8ffe 100644 (file)
@@ -3124,7 +3124,7 @@ See `comint-word'."
               "\\$\\(?:\\([[:alpha:]][[:alnum:]]*\\)"
               "\\|{\\(?1:[^{}]+\\)}\\)"
               (when (memq system-type '(ms-dos windows-nt))
-                "\\|%\\(?1:[^\\\\/]*\\)%")
+                "\\|%\\(?1:[^\\/]*\\)%")
               (when comint-file-name-quote-list
                 "\\|\\\\\\(.\\)")))
          (qupos nil)
index f66122d6d7242bde5147713d0e81f0a70dc44f1a..3b0f5493eebb220d34914f9c24b74b6904234b98 100644 (file)
@@ -456,7 +456,7 @@ This will generate compile-time constants from BINDINGS."
          (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>")
           (0 font-lock-builtin-face))
          ;; ELisp and CLisp `&' keywords as types.
-         (,(concat "\\_<\\&" lisp-mode-symbol-regexp "\\_>")
+         (,(concat "\\_<&" lisp-mode-symbol-regexp "\\_>")
           . font-lock-type-face)
          ;; ELisp regexp grouping constructs
          (,(lambda (bound)
@@ -511,7 +511,7 @@ This will generate compile-time constants from BINDINGS."
          (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>")
           (0 font-lock-builtin-face))
          ;; ELisp and CLisp `&' keywords as types.
-         (,(concat "\\_<\\&" lisp-mode-symbol-regexp "\\_>")
+         (,(concat "\\_<&" lisp-mode-symbol-regexp "\\_>")
           . font-lock-type-face)
          ;; This is too general -- rms.
          ;; A user complained that he has functions whose names start with `do'
@@ -750,7 +750,7 @@ or to switch back to an existing one."
   (setq-local lisp-indent-function 'common-lisp-indent-function)
   (setq-local find-tag-default-function 'lisp-find-tag-default)
   (setq-local comment-start-skip
-             "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
+             "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
   (setq imenu-case-fold-search t))
 
 (defun lisp-find-tag-default ()
index 61bf0a78c0e5aad3f4eb009efe97889c13e6f0aa..aedd6c948c224768bc238718c94074976145a29b 100644 (file)
@@ -192,7 +192,7 @@ This can be either \"inline\" or \"attachment\".")
      ,(lambda () (mm-uu-verbatim-marks-extract 0 0))
      nil)
     (LaTeX
-     "^\\([\\\\%][^\n]+\n\\)*\\\\documentclass.*[[{%]"
+     "^\\([\\%][^\n]+\n\\)*\\\\documentclass.*[[{%]"
      "^\\\\end{document}"
      ,#'mm-uu-latex-extract
      nil
index fd61e3e32875ec9fec21f72e0cab2990a5f7a2a1..52e6da6f4ac81cebd116ae834fd99dc3d64f8b4c 100644 (file)
@@ -1003,7 +1003,7 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
 ;; Matches an unterminated string/regexp, NOT including the eol at the end.
 
 (defconst c-awk-harmless-pattern-characters*
-  (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*"))
+  (concat "\\([^{;#/\"\\\n\r]\\|" c-awk-esc-pair-re "\\)*"))
 ;; Matches any "harmless" character in a pattern or an escaped character pair.
 
 (defun c-awk-at-statement-end-p ()
index 9ddb2ab2bbb0af506963d2aa2575252aee015a97..18df372f2c64e4bd0a4fa4bfa8563a7c3378db56 100644 (file)
@@ -1322,7 +1322,7 @@ Use it by enabling `eldoc-mode'."
   (set (make-local-variable 'parens-require-spaces) nil)
   (set (make-local-variable 'comment-start)  "# ")
   (set (make-local-variable 'comment-start-skip)
-       "\\(\\(?:^\\|[^\\\\\n]\\)\\(?:\\\\\\\\\\)*\\)#+[ \t]*")
+       "\\(\\(?:^\\|[^\\\n]\\)\\(?:\\\\\\\\\\)*\\)#+[ \t]*")
   ;; Like Lisp mode.  Without this, we lose with, say,
   ;; `backward-up-list' when there's an unbalanced quote in a
   ;; preceding comment.
index 5fee2df5863c44779bc44e0aab736486762ab01b..6f6da8e6b2ed7dd090e1b006e0aad2c35c1d85ec 100644 (file)
@@ -1306,7 +1306,7 @@ the last)."
                     cperl-maybe-white-and-comment-rex ; whitespace-comments
                     "\\(\\sw\\|_\\)+"  ; attr-name
                     ;; attr-arg (1 level of internal parens allowed!)
-                    "\\((\\(\\\\.\\|[^\\\\()]\\|([^\\\\()]*)\\)*)\\)?"
+                    "\\((\\(\\\\.\\|[^\\()]\\|([^\\()]*)\\)*)\\)?"
                     "\\("              ; optional : (XXX allows trailing???)
                        cperl-maybe-white-and-comment-rex ; whitespace-comments
                     ":\\)?"
@@ -5659,16 +5659,16 @@ indentation and initial hashes.  Behaves usually outside of comment."
            '("^[ \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]*}"
+                  '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
                     (2 font-lock-string-face t)
                     (0 '(restart 2 t)))) ; To highlight $a{bc}{ef}
                  (font-lock-anchored
-                  '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
+                  '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
                     (2 font-lock-string-face t)
                     ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
                      nil nil
                      (1 font-lock-string-face t))))
-                 (t '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
+                 (t '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
                       2 font-lock-string-face t)))
            '("[[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
              font-lock-string-face t)
index 811951eaaaf0dd4385e93b1af924d1b6c8cdd03a..abc860b9478a9619ae375236a504ad108a949769 100644 (file)
@@ -429,7 +429,7 @@ The only difference is, it returns t in a case when the default returns nil."
    fortran-font-lock-keywords-1
    ;; All type specifiers plus their declared items.
    (list
-    (list (concat fortran-type-types "[ \t(/]*\\(*\\)?")
+    (list (concat fortran-type-types "[ \t(/]*\\(\\*\\)?")
           ;; Type specifier.
           '(1 font-lock-type-face)
           ;; Declaration item (or just /.../ block name).
index fcd9294f660fd3338342c389ce79654fac056cb2..8c060991f4271fe675d71cf0b2f818c3c22898b1 100644 (file)
@@ -1688,7 +1688,7 @@ comment block.  If not in a // comment, just does a normal newline."
    ;; as comment starters.  Fix it here by removing the "2" from the syntax
    ;; of the second char of such sequences.
    ("/\\(\\*\\)" (1 ". 3b"))
-   ("(\\(\\/\\)" (1 (prog1 ". 1c" (forward-char -1) nil)))
+   ("(\\(/\\)" (1 (prog1 ". 1c" (forward-char -1) nil)))
    ;; Pascal uses '' and "" rather than \' and \" to escape quotes.
    ("''\\|\"\"" (0 (if (save-excursion
                          (nth 3 (syntax-ppss (match-beginning 0))))
index 13505d04a2d5fa62ca38ae1825a68ec9be066523..5036b793c55db6ebf1680071af8863d243e48c43 100644 (file)
    ;; as comment starters.  Fix it here by removing the "2" from the syntax
    ;; of the second char of such sequences.
    ("/\\(\\*\\)" (1 ". 3b"))
-   ("(\\(\\/\\)" (1 (prog1 ". 1c" (forward-char -1) nil)))
+   ("(\\(/\\)" (1 (prog1 ". 1c" (forward-char -1) nil)))
    ;; Pascal uses '' and "" rather than \' and \" to escape quotes.
    ("''\\|\"\"" (0 (if (save-excursion
                          (nth 3 (syntax-ppss (match-beginning 0))))
index f864f6a34cd1f89312cf54baf78175c8c9d9f91f..ff0b6a331bc6ad335b638d37f804f5d852f6b1ec 100644 (file)
                                                       (match-beginning 0))))))
                             (string-to-syntax ". p"))))
       ;; Handle funny names like $DB'stop.
-      ("\\$ ?{?^?[_[:alpha:]][_[:alnum:]]*\\('\\)[_[:alpha:]]" (1 "_"))
+      ("\\$ ?{?\\^?[_[:alpha:]][_[:alnum:]]*\\('\\)[_[:alpha:]]" (1 "_"))
       ;; format statements
       ("^[ \t]*format.*=[ \t]*\\(\n\\)"
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
index ecebf937e29188cfad74b08111831f6e4bc8f534..1e2679f72357c8446c18f1b9bc2f60a803d4c798 100644 (file)
@@ -252,7 +252,7 @@ This mirrors the optional behavior of tcsh."
 (defcustom shell-chdrive-regexp
   (if (memq system-type '(ms-dos windows-nt))
       ; NetWare allows the five chars between upper and lower alphabetics.
-      "[]a-zA-Z^_`\\[\\\\]:"
+      "[]a-zA-Z^_`[\\]:"
     nil)
   "If non-nil, is regexp used to track drive changes."
   :type '(choice regexp
@@ -377,7 +377,7 @@ Thus, this does not include the shell's current directory.")
               "\\|\\$\\(?:\\([[:alpha:]][[:alnum:]]*\\)"
               "\\|{\\(?1:[^{}]+\\)}\\)"
               (when (memq system-type '(ms-dos windows-nt))
-                "\\|%\\(?1:[^\\\\/]*\\)%")
+                "\\|%\\(?1:[^\\/]*\\)%")
               (when comint-file-name-quote-list
                 "\\|\\\\\\(.\\)")))
          (qupos nil)
index 0e28756ea75f230fb89b8ad33651f4564cbdea32..f95979e2fcbdef188da59d629e30df268d745967 100644 (file)
@@ -465,7 +465,7 @@ An alternative value is \" . \", if you use a font with a narrow period."
 ;    ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
 ;    ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
 ;    ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
-;    ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
+;    ("^[ \t\n]*\\\\def[\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
 ;  ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>.
 ;  '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
 ;     2 font-lock-function-name-face)
@@ -1252,10 +1252,10 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
                  ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "")
                  ("%" . "$"))))
   ;; A line containing just $$ is treated as a paragraph separator.
-  (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$")
+  (setq-local paragraph-start "[ \t]*$\\|[\f\\%]\\|[ \t]*\\$\\$")
   ;; A line starting with $$ starts a paragraph,
   ;; but does not separate paragraphs if it has more stuff on it.
-  (setq-local paragraph-separate "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$")
+  (setq-local paragraph-separate "[ \t]*$\\|[\f\\%]\\|[ \t]*\\$\\$[ \t]*$")
   (setq-local add-log-current-defun-function #'tex-current-defun-name)
   (setq-local comment-start "%")
   (setq-local comment-add 1)