aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2019-03-26 19:06:36 -0700
committerPaul Eggert2019-03-26 19:07:21 -0700
commit5d6a314475704f3fbdb29f68c6929516230e8a98 (patch)
treead00278e70192b7bfb072b436a0aa607ed20a9a9
parentc8ec3108a3d0bd1955d21f40b3c0c3b36d55b20d (diff)
downloademacs-5d6a314475704f3fbdb29f68c6929516230e8a98.tar.gz
emacs-5d6a314475704f3fbdb29f68c6929516230e8a98.zip
2019-03-26 regex cleanup
Problems reported by Mattias Engdegård in: https://lists.gnu.org/r/emacs-devel/2019-03/msg01028.html * lisp/align.el (align-rules-list): * lisp/speedbar.el (speedbar-check-read-only, speedbar-check-vc): * lisp/vc/diff-mode.el (diff-add-change-log-entries-other-window): * lisp/woman.el (woman-parse-numeric-arg): Put "-" at end of character alternatives, since a range was not intended. * lisp/erc/erc.el (font-lock): * lisp/mail/footnote.el (cl-seq): Avoid duplicate character alternatives by using cl-seq API. * lisp/mail/footnote.el (footnote--current-regexp): * lisp/textmodes/css-mode.el (css--font-lock-keywords): Avoid repetition of repetition. * lisp/net/webjump.el (webjump-url-encode): Add ~ to character alternatives, and rewrite confusing range. * lisp/progmodes/verilog-mode.el (verilog-compiler-directives) (verilog-assignment-operator-re): Remove duplicate. * lisp/progmodes/verilog-mode.el (verilog-preprocessor-re): * lisp/textmodes/css-mode.el (css--font-lock-keywords): Don’t escape a char that doesn’t need it. * lisp/textmodes/picture.el (picture-tab-chars): In docstring, do not say regexp characters will be quoted; merely say in another way that the syntax is that of character alternatives. (picture-set-tab-stops, picture-tab-search): Don’t attempt to regexp-quote picture-tab-chars. (picture-tab-search): Quote \ in picture-tab-chars for skip-chars-backwards, which treats \ differently than regexp character alternatives do.
-rw-r--r--lisp/align.el2
-rw-r--r--lisp/erc/erc.el7
-rw-r--r--lisp/mail/footnote.el16
-rw-r--r--lisp/net/webjump.el2
-rw-r--r--lisp/progmodes/verilog-mode.el8
-rw-r--r--lisp/speedbar.el4
-rw-r--r--lisp/textmodes/css-mode.el4
-rw-r--r--lisp/textmodes/picture.el14
-rw-r--r--lisp/vc/diff-mode.el2
-rw-r--r--lisp/woman.el2
10 files changed, 34 insertions, 27 deletions
diff --git a/lisp/align.el b/lisp/align.el
index a81498be5d0..fd88d0eda42 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -438,7 +438,7 @@ The possible settings for `align-region-separate' are:
438 (tab-stop . nil)) 438 (tab-stop . nil))
439 439
440 (perl-assignment 440 (perl-assignment
441 (regexp . ,(concat "[^=!^&*-+<>/| \t\n]\\(\\s-*\\)=[~>]?" 441 (regexp . ,(concat "[^=!^&*+<>/| \t\n-]\\(\\s-*\\)=[~>]?"
442 "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)")) 442 "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)"))
443 (group . (1 2)) 443 (group . (1 2))
444 (modes . align-perl-modes) 444 (modes . align-perl-modes)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index bcaa3e45258..e34487de273 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -67,6 +67,7 @@
67(load "erc-loaddefs" nil t) 67(load "erc-loaddefs" nil t)
68 68
69(eval-when-compile (require 'cl-lib)) 69(eval-when-compile (require 'cl-lib))
70(require 'cl-seq)
70(require 'font-lock) 71(require 'font-lock)
71(require 'pp) 72(require 'pp)
72(require 'thingatpt) 73(require 'thingatpt)
@@ -2522,10 +2523,8 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is
2522non-nil." 2523non-nil."
2523 (if erc-lurker-trim-nicks 2524 (if erc-lurker-trim-nicks
2524 (replace-regexp-in-string 2525 (replace-regexp-in-string
2525 (format "[%s]" 2526 (regexp-opt (cl-delete-duplicates
2526 (mapconcat (lambda (char) 2527 (mapcar #'char-to-string erc-lurker-ignore-chars)))
2527 (regexp-quote (char-to-string char)))
2528 erc-lurker-ignore-chars ""))
2529 "" nick) 2528 "" nick)
2530 nick)) 2529 nick))
2531 2530
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el
index a7802929dca..7f88e30120d 100644
--- a/lisp/mail/footnote.el
+++ b/lisp/mail/footnote.el
@@ -64,6 +64,7 @@
64;;; Code: 64;;; Code:
65 65
66(eval-when-compile (require 'cl-lib)) 66(eval-when-compile (require 'cl-lib))
67(require 'cl-seq)
67(defvar filladapt-token-table) 68(defvar filladapt-token-table)
68 69
69(defgroup footnote nil 70(defgroup footnote nil
@@ -363,7 +364,9 @@ Use Unicode characters for footnoting."
363 ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק"))) 364 ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק")))
364 365
365(defconst footnote-hebrew-numeric-regex 366(defconst footnote-hebrew-numeric-regex
366 (concat "[" (apply #'concat (apply #'append footnote-hebrew-numeric)) "']+")) 367 (concat "[" (cl-delete-duplicates
368 (apply #'concat (apply #'append footnote-hebrew-numeric)))
369 "']+"))
367;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?") 370;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?")
368 371
369(defun footnote--hebrew-numeric (n) 372(defun footnote--hebrew-numeric (n)
@@ -457,9 +460,14 @@ Conversion is done based upon the current selected style."
457 460
458(defun footnote--current-regexp () 461(defun footnote--current-regexp ()
459 "Return the regexp of the index of the current style." 462 "Return the regexp of the index of the current style."
460 (concat (nth 2 (or (assq footnote-style footnote-style-alist) 463 (let ((regexp (nth 2 (or (assq footnote-style footnote-style-alist)
461 (nth 0 footnote-style-alist))) 464 (nth 0 footnote-style-alist)))))
462 "*")) 465 (concat
466 ;; Hack to avoid repetition of repetition.
467 (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp)
468 (substring regexp 0 -1)
469 regexp)
470 "*")))
463 471
464(defun footnote--refresh-footnotes (&optional index-regexp) 472(defun footnote--refresh-footnotes (&optional index-regexp)
465 "Redraw all footnotes. 473 "Redraw all footnotes.
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index 40df23e174a..e297b9d6108 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -342,7 +342,7 @@ Please submit bug reports and other feedback to the author, Neil W. Van Dyke
342 (mapconcat (lambda (c) 342 (mapconcat (lambda (c)
343 (let ((s (char-to-string c))) 343 (let ((s (char-to-string c)))
344 (cond ((string= s " ") "+") 344 (cond ((string= s " ") "+")
345 ((string-match "[a-zA-Z_.-/]" s) s) 345 ((string-match "[a-zA-Z_./~-]" s) s)
346 (t (upcase (format "%%%02x" c)))))) 346 (t (upcase (format "%%%02x" c))))))
347 (encode-coding-string str 'utf-8) 347 (encode-coding-string str 'utf-8)
348 "")) 348 ""))
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 9e241c70e76..f55cf0002d0 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -2053,7 +2053,7 @@ find the errors."
2053 "`resetall" "`timescale" "`unconnected_drive" "`undef" "`undefineall" 2053 "`resetall" "`timescale" "`unconnected_drive" "`undef" "`undefineall"
2054 ;; compiler directives not covered by IEEE 1800 2054 ;; compiler directives not covered by IEEE 1800
2055 "`case" "`default" "`endfor" "`endprotect" "`endswitch" "`endwhile" "`for" 2055 "`case" "`default" "`endfor" "`endprotect" "`endswitch" "`endwhile" "`for"
2056 "`format" "`if" "`let" "`protect" "`switch" "`timescale" "`time_scale" 2056 "`format" "`if" "`let" "`protect" "`switch" "`time_scale"
2057 "`while" 2057 "`while"
2058 )) 2058 ))
2059 "List of Verilog compiler directives.") 2059 "List of Verilog compiler directives.")
@@ -2414,9 +2414,7 @@ find the errors."
2414 '( 2414 '(
2415 ;; blocking assignment_operator 2415 ;; blocking assignment_operator
2416 "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>=" 2416 "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>="
2417 ;; non blocking assignment operator 2417 ;; comparison (also nonblocking assignment "<=")
2418 "<="
2419 ;; comparison
2420 "==" "!=" "===" "!==" "<=" ">=" "==?" "!=?" "<->" 2418 "==" "!=" "===" "!==" "<=" ">=" "==?" "!=?" "<->"
2421 ;; event_trigger 2419 ;; event_trigger
2422 "->" "->>" 2420 "->" "->>"
@@ -2973,7 +2971,7 @@ find the errors."
2973 "\\<\\(`pragma\\)\\>\\s-+.+$" 2971 "\\<\\(`pragma\\)\\>\\s-+.+$"
2974 "\\)\\|\\(?:" 2972 "\\)\\|\\(?:"
2975 ;; `timescale time_unit / time_precision 2973 ;; `timescale time_unit / time_precision
2976 "\\<\\(`timescale\\)\\>\\s-+10\\{0,2\\}\\s-*[munpf]?s\\s-*\\/\\s-*10\\{0,2\\}\\s-*[munpf]?s" 2974 "\\<\\(`timescale\\)\\>\\s-+10\\{0,2\\}\\s-*[munpf]?s\\s-*/\\s-*10\\{0,2\\}\\s-*[munpf]?s"
2977 "\\)\\|\\(?:" 2975 "\\)\\|\\(?:"
2978 ;; `define and `if can span multiple lines if line ends in '\'. NOTE: `if is not IEEE 1800-2012 2976 ;; `define and `if can span multiple lines if line ends in '\'. NOTE: `if is not IEEE 1800-2012
2979 ;; from http://www.emacswiki.org/emacs/MultilineRegexp 2977 ;; from http://www.emacswiki.org/emacs/MultilineRegexp
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 399ef4557b8..4823e4ba565 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -2849,7 +2849,7 @@ indicator, then do not add a space."
2849 (progn 2849 (progn
2850 (goto-char speedbar-ro-to-do-point) 2850 (goto-char speedbar-ro-to-do-point)
2851 (while (and (not (input-pending-p)) 2851 (while (and (not (input-pending-p))
2852 (re-search-forward "^\\([0-9]+\\):\\s-*[[<][+-?][]>] " 2852 (re-search-forward "^\\([0-9]+\\):\\s-*[[<][+?-][]>] "
2853 nil t)) 2853 nil t))
2854 (setq speedbar-ro-to-do-point (point)) 2854 (setq speedbar-ro-to-do-point (point))
2855 (let ((f (speedbar-line-file))) 2855 (let ((f (speedbar-line-file)))
@@ -2900,7 +2900,7 @@ to add more types of version control systems."
2900 (progn 2900 (progn
2901 (goto-char speedbar-vc-to-do-point) 2901 (goto-char speedbar-vc-to-do-point)
2902 (while (and (not (input-pending-p)) 2902 (while (and (not (input-pending-p))
2903 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-?]\\] " 2903 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+?-]\\] "
2904 nil t)) 2904 nil t))
2905 (setq speedbar-vc-to-do-point (point)) 2905 (setq speedbar-vc-to-do-point (point))
2906 (if (speedbar-check-vc-this-line (match-string 1)) 2906 (if (speedbar-check-vc-this-line (match-string 1))
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index cddcdc0947b..57ecc9788eb 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -892,7 +892,7 @@ cannot be completed sensibly: `custom-ident',
892 (,(concat "@" css-ident-re) (0 font-lock-builtin-face)) 892 (,(concat "@" css-ident-re) (0 font-lock-builtin-face))
893 ;; Selectors. 893 ;; Selectors.
894 ;; Allow plain ":root" as a selector. 894 ;; Allow plain ":root" as a selector.
895 ("^[ \t]*\\(:root\\)\\(?:[\n \t]*\\)*{" (1 'css-selector keep)) 895 ("^[ \t]*\\(:root\\)\\(?:[\n \t]*\\){" (1 'css-selector keep))
896 ;; FIXME: attribute selectors don't work well because they may contain 896 ;; FIXME: attribute selectors don't work well because they may contain
897 ;; strings which have already been highlighted as f-l-string-face and 897 ;; strings which have already been highlighted as f-l-string-face and
898 ;; thus prevent this highlighting from being applied (actually now that 898 ;; thus prevent this highlighting from being applied (actually now that
@@ -915,7 +915,7 @@ cannot be completed sensibly: `custom-ident',
915 "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids 915 "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
916 css-pseudo-element-ids) 916 css-pseudo-element-ids)
917 t) 917 t)
918 "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)" 918 "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)"
919 "\\(?:([^)]+)\\)?" 919 "\\(?:([^)]+)\\)?"
920 (if (not sassy) 920 (if (not sassy)
921 "[^:{}()\n]*" 921 "[^:{}()\n]*"
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index f0e30135f16..b5208494674 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -387,7 +387,8 @@ Interactively, ARG is the numeric argument, and defaults to 1."
387\\[picture-set-tab-stops] and \\[picture-tab-search]. 387\\[picture-set-tab-stops] and \\[picture-tab-search].
388The syntax for this variable is like the syntax used inside of `[...]' 388The syntax for this variable is like the syntax used inside of `[...]'
389in a regular expression--but without the `[' and the `]'. 389in a regular expression--but without the `[' and the `]'.
390It is NOT a regular expression, any regexp special characters will be quoted. 390It is NOT a regular expression, and should follow the usual
391rules for the contents of a character alternative.
391It defines a set of \"interesting characters\" to look for when setting 392It defines a set of \"interesting characters\" to look for when setting
392\(or searching for) tab stops, initially \"!-~\" (all printing characters). 393\(or searching for) tab stops, initially \"!-~\" (all printing characters).
393For example, suppose that you are editing a table which is formatted thus: 394For example, suppose that you are editing a table which is formatted thus:
@@ -425,7 +426,7 @@ stops computed are displayed in the minibuffer with `:' at each stop."
425 (if arg 426 (if arg
426 (setq tabs (or (default-value 'tab-stop-list) 427 (setq tabs (or (default-value 'tab-stop-list)
427 (indent-accumulate-tab-stops (window-width)))) 428 (indent-accumulate-tab-stops (window-width))))
428 (let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]"))) 429 (let ((regexp (concat "[ \t]+[" picture-tab-chars "]")))
429 (beginning-of-line) 430 (beginning-of-line)
430 (let ((bol (point))) 431 (let ((bol (point)))
431 (end-of-line) 432 (end-of-line)
@@ -433,8 +434,8 @@ stops computed are displayed in the minibuffer with `:' at each stop."
433 (skip-chars-forward " \t") 434 (skip-chars-forward " \t")
434 (setq tabs (cons (current-column) tabs))) 435 (setq tabs (cons (current-column) tabs)))
435 (if (null tabs) 436 (if (null tabs)
436 (error "No characters in set %s on this line" 437 (error "No characters in set [%s] on this line"
437 (regexp-quote picture-tab-chars)))))) 438 picture-tab-chars)))))
438 (setq tab-stop-list tabs) 439 (setq tab-stop-list tabs)
439 (let ((blurb (make-string (1+ (nth (1- (length tabs)) tabs)) ?\ ))) 440 (let ((blurb (make-string (1+ (nth (1- (length tabs)) tabs)) ?\ )))
440 (while tabs 441 (while tabs
@@ -455,12 +456,13 @@ If no such character is found, move to beginning of line."
455 (progn 456 (progn
456 (beginning-of-line) 457 (beginning-of-line)
457 (skip-chars-backward 458 (skip-chars-backward
458 (concat "^" (regexp-quote picture-tab-chars)) 459 (concat "^" (replace-regexp-in-string
460 "\\\\" "\\\\" picture-tab-chars nil t))
459 (point-min)) 461 (point-min))
460 (not (bobp)))) 462 (not (bobp))))
461 (move-to-column target)) 463 (move-to-column target))
462 (if (re-search-forward 464 (if (re-search-forward
463 (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]") 465 (concat "[ \t]+[" picture-tab-chars "]")
464 (line-end-position) 466 (line-end-position)
465 'move) 467 'move)
466 (setq target (1- (current-column))) 468 (setq target (1- (current-column)))
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index b67caab7f50..dbde284da84 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2213,7 +2213,7 @@ I.e. like `add-change-log-entry-other-window' but applied to all hunks."
2213 ;; `add-change-log-entry-other-window' works better in 2213 ;; `add-change-log-entry-other-window' works better in
2214 ;; that case. 2214 ;; that case.
2215 (re-search-forward 2215 (re-search-forward
2216 (concat "\n[!+-<>]" 2216 (concat "\n[!+<>-]"
2217 ;; If the hunk is a context hunk with an empty first 2217 ;; If the hunk is a context hunk with an empty first
2218 ;; half, recognize the "--- NNN,MMM ----" line 2218 ;; half, recognize the "--- NNN,MMM ----" line
2219 "\\(-- [0-9]+\\(,[0-9]+\\)? ----\n" 2219 "\\(-- [0-9]+\\(,[0-9]+\\)? ----\n"
diff --git a/lisp/woman.el b/lisp/woman.el
index a351f788ece..39d9b806d27 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -3511,7 +3511,7 @@ The expression may be an argument in quotes."
3511 (let ((value (if (looking-at "[+-]") 0 (woman-parse-numeric-value))) 3511 (let ((value (if (looking-at "[+-]") 0 (woman-parse-numeric-value)))
3512 op) 3512 op)
3513 (while (cond 3513 (while (cond
3514 ((looking-at "[+-/*%]") ; arithmetic operators 3514 ((looking-at "[+/*%-]") ; arithmetic operators
3515 (forward-char) 3515 (forward-char)
3516 (setq op (intern-soft (match-string 0))) 3516 (setq op (intern-soft (match-string 0)))
3517 (setq value (funcall op value (woman-parse-numeric-value)))) 3517 (setq value (funcall op value (woman-parse-numeric-value))))