diff options
| author | Paul Eggert | 2019-03-26 19:06:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-03-26 19:07:21 -0700 |
| commit | 5d6a314475704f3fbdb29f68c6929516230e8a98 (patch) | |
| tree | ad00278e70192b7bfb072b436a0aa607ed20a9a9 /lisp/textmodes | |
| parent | c8ec3108a3d0bd1955d21f40b3c0c3b36d55b20d (diff) | |
| download | emacs-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.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/css-mode.el | 4 | ||||
| -rw-r--r-- | lisp/textmodes/picture.el | 14 |
2 files changed, 10 insertions, 8 deletions
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]. |
| 388 | The syntax for this variable is like the syntax used inside of `[...]' | 388 | The syntax for this variable is like the syntax used inside of `[...]' |
| 389 | in a regular expression--but without the `[' and the `]'. | 389 | in a regular expression--but without the `[' and the `]'. |
| 390 | It is NOT a regular expression, any regexp special characters will be quoted. | 390 | It is NOT a regular expression, and should follow the usual |
| 391 | rules for the contents of a character alternative. | ||
| 391 | It defines a set of \"interesting characters\" to look for when setting | 392 | It 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). |
| 393 | For example, suppose that you are editing a table which is formatted thus: | 394 | For 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))) |