diff options
| author | Mattias EngdegÄrd | 2019-05-14 11:43:49 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-05-15 18:55:27 +0200 |
| commit | 26f735ff198e52370aafe09ed5ed669e78f196ab (patch) | |
| tree | b54c83556db3e13b5852642c84097ee0c4531778 | |
| parent | d0ebc389ebba0ca5b99e019c47c4a616941378ac (diff) | |
| download | emacs-26f735ff198e52370aafe09ed5ed669e78f196ab.tar.gz emacs-26f735ff198e52370aafe09ed5ed669e78f196ab.zip | |
Add standard unmatchable regexp
Add `regexp-unmatchable' as a standard unmatchable regexp, defined as
"\\`a\\`". Use it where such a regexp is needed, replacing slower
expressions in several places.
From a suggestion by Philippe Schnoebelen.
* lisp/subr.el (regexp-unmatchable): New defconst.
* etc/NEWS (Lisp Changes): Mention `regexp-unmatchable'.
* doc/lispref/searching.texi (Regexp Functions): Document it.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt)
* lisp/progmodes/cc-defs.el (cc-conditional-require-after-load)
(c-make-keywords-re)
* lisp/progmodes/cc-engine.el (c-beginning-of-statement-1)
(c-forward-<>-arglist-recur, c-forward-decl-or-cast-1)
(c-looking-at-decl-block)
* lisp/progmodes/cc-fonts.el (c-doc-line-join-re)
(c-doc-bright-comment-start-re)
* lisp/progmodes/cc-langs.el (c-populate-syntax-table)
(c-assignment-op-regexp)
(c-block-comment-ender-regexp, c-font-lock-comment-end-skip)
(c-block-comment-start-regexp, c-line-comment-start-regexp)
(c-doc-comment-start-regexp, c-decl-start-colon-kwd-re)
(c-type-decl-prefix-key, c-type-decl-operator-prefix-key)
(c-pre-id-bracelist-key, c-enum-clause-introduction-re)
(c-nonlabel-token-2-key)
* lisp/progmodes/cc-mode.el (c-doc-fl-decl-start, c-doc-fl-decl-end)
* lisp/progmodes/cc-vars.el (c-noise-macro-with-parens-name-re)
(c-noise-macro-name-re, c-make-noise-macro-regexps)
* lisp/progmodes/octave.el (octave-help-mode)
* lisp/vc/vc-bzr.el (vc-bzr-log-view-mode, vc-bzr-revision-completion-table)
* lisp/vc/vc-git.el (vc-git-log-view-mode)
* lisp/vc/vc-hg.el (vc-hg-log-view-mode)
* lisp/vc/vc-mtn.el (vc-mtn-log-view-mode):
Use `regexp-unmatchable'.
* lisp/textmodes/ispell.el (ispell-non-empty-string):
Use `regexp-unmatchable', fixing a broken never-match regexp.
| -rw-r--r-- | doc/lispref/searching.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/regexp-opt.el | 4 | ||||
| -rw-r--r-- | lisp/net/ange-ftp.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 10 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 26 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-vars.el | 8 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/octave.el | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 4 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-bzr.el | 5 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-mtn.el | 2 |
18 files changed, 58 insertions, 39 deletions
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 8775254dd07..24f30b4dac6 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi | |||
| @@ -1070,6 +1070,13 @@ list of characters @var{chars}. | |||
| 1070 | 1070 | ||
| 1071 | @c Internal functions: regexp-opt-group | 1071 | @c Internal functions: regexp-opt-group |
| 1072 | 1072 | ||
| 1073 | @defvar regexp-unmatchable | ||
| 1074 | This variable contains a regexp that is guaranteed not to match any | ||
| 1075 | string at all. It is particularly useful as default value for | ||
| 1076 | variables that may be set to a pattern that actually matches | ||
| 1077 | something. | ||
| 1078 | @end defvar | ||
| 1079 | |||
| 1073 | @node Regexp Search | 1080 | @node Regexp Search |
| 1074 | @section Regular Expression Searching | 1081 | @section Regular Expression Searching |
| 1075 | @cindex regular expression searching | 1082 | @cindex regular expression searching |
| @@ -1990,6 +1990,10 @@ returns a regexp that never matches anything, which is an identity for | |||
| 1990 | this operation. Previously, the empty string was returned in this | 1990 | this operation. Previously, the empty string was returned in this |
| 1991 | case. | 1991 | case. |
| 1992 | 1992 | ||
| 1993 | ** New constant 'regexp-unmatchable' contains a never-matching regexp. | ||
| 1994 | It is a convenient and readable way to specify a regexp that should | ||
| 1995 | not match anything, and is as fast as any such regexp can be. | ||
| 1996 | |||
| 1993 | 1997 | ||
| 1994 | * Changes in Emacs 27.1 on Non-Free Operating Systems | 1998 | * Changes in Emacs 27.1 on Non-Free Operating Systems |
| 1995 | 1999 | ||
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el index d883752d712..00f72e284ad 100644 --- a/lisp/emacs-lisp/regexp-opt.el +++ b/lisp/emacs-lisp/regexp-opt.el | |||
| @@ -144,9 +144,9 @@ usually more efficient than that of a simplified version: | |||
| 144 | (sort (copy-sequence strings) 'string-lessp))) | 144 | (sort (copy-sequence strings) 'string-lessp))) |
| 145 | (re | 145 | (re |
| 146 | (cond | 146 | (cond |
| 147 | ;; No strings: return a\` which cannot match anything. | 147 | ;; No strings: return an unmatchable regexp. |
| 148 | ((null strings) | 148 | ((null strings) |
| 149 | (concat (or open "\\(?:") "a\\`\\)")) | 149 | (concat (or open "\\(?:") regexp-unmatchable "\\)")) |
| 150 | ;; If we cannot reorder, give up all attempts at | 150 | ;; If we cannot reorder, give up all attempts at |
| 151 | ;; optimisation. There is room for improvement (Bug#34641). | 151 | ;; optimisation. There is room for improvement (Bug#34641). |
| 152 | ((and keep-order (regexp-opt--contains-prefix sorted-strings)) | 152 | ((and keep-order (regexp-opt--contains-prefix sorted-strings)) |
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 5af9ea75ed1..b0a1e1799f5 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el | |||
| @@ -1989,7 +1989,7 @@ on the gateway machine to do the FTP instead." | |||
| 1989 | (make-local-variable 'comint-password-prompt-regexp) | 1989 | (make-local-variable 'comint-password-prompt-regexp) |
| 1990 | ;; This is a regexp that can't match anything. | 1990 | ;; This is a regexp that can't match anything. |
| 1991 | ;; ange-ftp has its own ways of handling passwords. | 1991 | ;; ange-ftp has its own ways of handling passwords. |
| 1992 | (setq comint-password-prompt-regexp "\\`a\\`") | 1992 | (setq comint-password-prompt-regexp regexp-unmatchable) |
| 1993 | (make-local-variable 'paragraph-start) | 1993 | (make-local-variable 'paragraph-start) |
| 1994 | (setq paragraph-start comint-prompt-regexp)) | 1994 | (setq paragraph-start comint-prompt-regexp)) |
| 1995 | 1995 | ||
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index cd4ed6b352e..d20e3ef32d9 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -81,7 +81,7 @@ | |||
| 81 | (progn | 81 | (progn |
| 82 | (require 'font-lock) | 82 | (require 'font-lock) |
| 83 | (let (font-lock-keywords) | 83 | (let (font-lock-keywords) |
| 84 | (font-lock-compile-keywords '("a\\`")) ; doesn't match anything. | 84 | (font-lock-compile-keywords (list regexp-unmatchable)) |
| 85 | font-lock-keywords)))) | 85 | font-lock-keywords)))) |
| 86 | 86 | ||
| 87 | 87 | ||
| @@ -1890,8 +1890,8 @@ when it's needed. The default is the current language taken from | |||
| 1890 | 1890 | ||
| 1891 | ;; Produce a regexp that doesn't match anything. | 1891 | ;; Produce a regexp that doesn't match anything. |
| 1892 | (if adorn | 1892 | (if adorn |
| 1893 | "\\(a\\`\\)" | 1893 | (concat "\\(" regexp-unmatchable "\\)") |
| 1894 | "a\\`"))) | 1894 | regexp-unmatchable))) |
| 1895 | 1895 | ||
| 1896 | (put 'c-make-keywords-re 'lisp-indent-function 1) | 1896 | (put 'c-make-keywords-re 'lisp-indent-function 1) |
| 1897 | 1897 | ||
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index ed8310d0e67..41bab270daa 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -907,7 +907,7 @@ comment at the start of cc-engine.el for more info." | |||
| 907 | stack | 907 | stack |
| 908 | ;; Regexp which matches "for", "if", etc. | 908 | ;; Regexp which matches "for", "if", etc. |
| 909 | (cond-key (or c-opt-block-stmt-key | 909 | (cond-key (or c-opt-block-stmt-key |
| 910 | "a\\`")) ; Doesn't match anything. | 910 | regexp-unmatchable)) |
| 911 | ;; Return value. | 911 | ;; Return value. |
| 912 | (ret 'same) | 912 | (ret 'same) |
| 913 | ;; Positions of the last three sexps or bounds we've stopped at. | 913 | ;; Positions of the last three sexps or bounds we've stopped at. |
| @@ -7646,7 +7646,9 @@ comment at the start of cc-engine.el for more info." | |||
| 7646 | (progn | 7646 | (progn |
| 7647 | (c-forward-syntactic-ws) | 7647 | (c-forward-syntactic-ws) |
| 7648 | (when (or (and c-record-type-identifiers all-types) | 7648 | (when (or (and c-record-type-identifiers all-types) |
| 7649 | (not (equal c-inside-<>-type-key "\\(a\\`\\)"))) | 7649 | (not (equal c-inside-<>-type-key |
| 7650 | (concat | ||
| 7651 | "\\(" regexp-unmatchable "\\)")))) | ||
| 7650 | (c-forward-syntactic-ws) | 7652 | (c-forward-syntactic-ws) |
| 7651 | (cond | 7653 | (cond |
| 7652 | ((eq (char-after) ??) | 7654 | ((eq (char-after) ??) |
| @@ -9253,7 +9255,7 @@ This function might do hidden buffer changes." | |||
| 9253 | ;; Skip over type decl prefix operators. (Note similar code in | 9255 | ;; Skip over type decl prefix operators. (Note similar code in |
| 9254 | ;; `c-forward-declarator'.) | 9256 | ;; `c-forward-declarator'.) |
| 9255 | (if (and c-recognize-typeless-decls | 9257 | (if (and c-recognize-typeless-decls |
| 9256 | (equal c-type-decl-prefix-key "a\\`")) ; Regexp which doesn't match | 9258 | (equal c-type-decl-prefix-key regexp-unmatchable)) |
| 9257 | (when (eq (char-after) ?\() | 9259 | (when (eq (char-after) ?\() |
| 9258 | (progn | 9260 | (progn |
| 9259 | (setq paren-depth (1+ paren-depth)) | 9261 | (setq paren-depth (1+ paren-depth)) |
| @@ -10886,7 +10888,7 @@ comment at the start of cc-engine.el for more info." | |||
| 10886 | ;; legal because it's part of a "compound keyword" like | 10888 | ;; legal because it's part of a "compound keyword" like |
| 10887 | ;; "enum class". Of course, if c-after-brace-list-key | 10889 | ;; "enum class". Of course, if c-after-brace-list-key |
| 10888 | ;; is nil, we can skip the test. | 10890 | ;; is nil, we can skip the test. |
| 10889 | (or (equal c-after-brace-list-key "a\\`") ; Regexp which doesn't match | 10891 | (or (equal c-after-brace-list-key regexp-unmatchable) |
| 10890 | (save-match-data | 10892 | (save-match-data |
| 10891 | (save-excursion | 10893 | (save-excursion |
| 10892 | (not | 10894 | (not |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 5f09be60a67..b3a9dd480b8 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -2580,14 +2580,14 @@ need for `pike-font-lock-extra-types'.") | |||
| 2580 | 2580 | ||
| 2581 | ;;; Doc comments. | 2581 | ;;; Doc comments. |
| 2582 | 2582 | ||
| 2583 | (defvar c-doc-line-join-re "a\\`") | 2583 | (defvar c-doc-line-join-re regexp-unmatchable) |
| 2584 | ;; Matches a join of two lines in a doc comment. | 2584 | ;; Matches a join of two lines in a doc comment. |
| 2585 | ;; This should not be changed directly, but instead set by | 2585 | ;; This should not be changed directly, but instead set by |
| 2586 | ;; `c-setup-doc-comment-style'. This variable is used in `c-find-decl-spots' | 2586 | ;; `c-setup-doc-comment-style'. This variable is used in `c-find-decl-spots' |
| 2587 | ;; in (e.g.) autodoc style comments to bridge the gap between a "@\n" at an | 2587 | ;; in (e.g.) autodoc style comments to bridge the gap between a "@\n" at an |
| 2588 | ;; EOL and the token following "//!" on the next line. | 2588 | ;; EOL and the token following "//!" on the next line. |
| 2589 | 2589 | ||
| 2590 | (defvar c-doc-bright-comment-start-re "a\\`") | 2590 | (defvar c-doc-bright-comment-start-re regexp-unmatchable) |
| 2591 | ;; Matches the start of a "bright" comment, one whose contents may be | 2591 | ;; Matches the start of a "bright" comment, one whose contents may be |
| 2592 | ;; fontified by, e.g., `c-font-lock-declarations'. | 2592 | ;; fontified by, e.g., `c-font-lock-declarations'. |
| 2593 | 2593 | ||
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 30da10a6c03..9d2f689e584 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -945,7 +945,7 @@ file name in angle brackets or quotes." | |||
| 945 | (c-make-keywords-re 'appendable | 945 | (c-make-keywords-re 'appendable |
| 946 | (c-lang-const c-cpp-include-directives)) | 946 | (c-lang-const c-cpp-include-directives)) |
| 947 | "[ \t]*") | 947 | "[ \t]*") |
| 948 | "a\\`")) ; Doesn't match anything | 948 | regexp-unmatchable)) |
| 949 | (c-lang-defvar c-cpp-include-key (c-lang-const c-cpp-include-key)) | 949 | (c-lang-defvar c-cpp-include-key (c-lang-const c-cpp-include-key)) |
| 950 | 950 | ||
| 951 | (c-lang-defconst c-opt-cpp-macro-define | 951 | (c-lang-defconst c-opt-cpp-macro-define |
| @@ -1331,7 +1331,7 @@ operators." | |||
| 1331 | (c--set-difference (c-lang-const c-assignment-operators) | 1331 | (c--set-difference (c-lang-const c-assignment-operators) |
| 1332 | '("=") | 1332 | '("=") |
| 1333 | :test 'string-equal))) | 1333 | :test 'string-equal))) |
| 1334 | "a\\`")) ; Doesn't match anything. | 1334 | regexp-unmatchable)) |
| 1335 | (c-lang-defvar c-assignment-op-regexp | 1335 | (c-lang-defvar c-assignment-op-regexp |
| 1336 | (c-lang-const c-assignment-op-regexp)) | 1336 | (c-lang-const c-assignment-op-regexp)) |
| 1337 | 1337 | ||
| @@ -1554,7 +1554,7 @@ properly." | |||
| 1554 | ;; language) | 1554 | ;; language) |
| 1555 | t (if (c-lang-const c-block-comment-ender) | 1555 | t (if (c-lang-const c-block-comment-ender) |
| 1556 | (regexp-quote (c-lang-const c-block-comment-ender)) | 1556 | (regexp-quote (c-lang-const c-block-comment-ender)) |
| 1557 | "a\\`")) ; Doesn't match anything. | 1557 | regexp-unmatchable)) |
| 1558 | (c-lang-defvar c-block-comment-ender-regexp | 1558 | (c-lang-defvar c-block-comment-ender-regexp |
| 1559 | (c-lang-const c-block-comment-ender-regexp)) | 1559 | (c-lang-const c-block-comment-ender-regexp)) |
| 1560 | 1560 | ||
| @@ -1565,7 +1565,7 @@ properly." | |||
| 1565 | ;; `font-lock-comment-delimiter-face'. | 1565 | ;; `font-lock-comment-delimiter-face'. |
| 1566 | t (if (c-lang-const c-block-comment-ender) | 1566 | t (if (c-lang-const c-block-comment-ender) |
| 1567 | (concat "[ \t]*" (c-lang-const c-block-comment-ender-regexp)) | 1567 | (concat "[ \t]*" (c-lang-const c-block-comment-ender-regexp)) |
| 1568 | "a\\`")) ; Doesn't match anything. | 1568 | regexp-unmatchable)) |
| 1569 | (c-lang-setvar font-lock-comment-end-skip | 1569 | (c-lang-setvar font-lock-comment-end-skip |
| 1570 | (c-lang-const c-font-lock-comment-end-skip)) | 1570 | (c-lang-const c-font-lock-comment-end-skip)) |
| 1571 | 1571 | ||
| @@ -1584,7 +1584,7 @@ properly." | |||
| 1584 | ;; language) | 1584 | ;; language) |
| 1585 | t (if (c-lang-const c-block-comment-starter) | 1585 | t (if (c-lang-const c-block-comment-starter) |
| 1586 | (regexp-quote (c-lang-const c-block-comment-starter)) | 1586 | (regexp-quote (c-lang-const c-block-comment-starter)) |
| 1587 | "a\\`")) ; Doesn't match anything. | 1587 | regexp-unmatchable)) |
| 1588 | (c-lang-defvar c-block-comment-start-regexp | 1588 | (c-lang-defvar c-block-comment-start-regexp |
| 1589 | (c-lang-const c-block-comment-start-regexp)) | 1589 | (c-lang-const c-block-comment-start-regexp)) |
| 1590 | 1590 | ||
| @@ -1593,7 +1593,7 @@ properly." | |||
| 1593 | ;; language; it does in all 7 CC Mode languages). | 1593 | ;; language; it does in all 7 CC Mode languages). |
| 1594 | t (if (c-lang-const c-line-comment-starter) | 1594 | t (if (c-lang-const c-line-comment-starter) |
| 1595 | (regexp-quote (c-lang-const c-line-comment-starter)) | 1595 | (regexp-quote (c-lang-const c-line-comment-starter)) |
| 1596 | "a\\`")) ; Doesn't match anything. | 1596 | regexp-unmatchable)) |
| 1597 | (c-lang-defvar c-line-comment-start-regexp | 1597 | (c-lang-defvar c-line-comment-start-regexp |
| 1598 | (c-lang-const c-line-comment-start-regexp)) | 1598 | (c-lang-const c-line-comment-start-regexp)) |
| 1599 | 1599 | ||
| @@ -1628,7 +1628,7 @@ starter." | |||
| 1628 | 1628 | ||
| 1629 | (c-lang-defconst c-doc-comment-start-regexp | 1629 | (c-lang-defconst c-doc-comment-start-regexp |
| 1630 | "Regexp to match the start of documentation comments." | 1630 | "Regexp to match the start of documentation comments." |
| 1631 | t "a\\`" ; Doesn't match anything. | 1631 | t regexp-unmatchable |
| 1632 | ;; From font-lock.el: `doxygen' uses /*! while others use /**. | 1632 | ;; From font-lock.el: `doxygen' uses /*! while others use /**. |
| 1633 | (c c++ objc) "/\\*[*!]" | 1633 | (c c++ objc) "/\\*[*!]" |
| 1634 | java "/\\*\\*" | 1634 | java "/\\*\\*" |
| @@ -3112,7 +3112,7 @@ Note that Java specific rules are currently applied to tell this from | |||
| 3112 | "Regexp matching a keyword that is followed by a colon, where | 3112 | "Regexp matching a keyword that is followed by a colon, where |
| 3113 | the whole construct can precede a declaration. | 3113 | the whole construct can precede a declaration. |
| 3114 | E.g. \"public:\" in C++." | 3114 | E.g. \"public:\" in C++." |
| 3115 | t "a\\`" ; Doesn't match anything. | 3115 | t regexp-unmatchable |
| 3116 | c++ (c-make-keywords-re t (c-lang-const c-protection-kwds))) | 3116 | c++ (c-make-keywords-re t (c-lang-const c-protection-kwds))) |
| 3117 | (c-lang-defvar c-decl-start-colon-kwd-re | 3117 | (c-lang-defvar c-decl-start-colon-kwd-re |
| 3118 | (c-lang-const c-decl-start-colon-kwd-re)) | 3118 | (c-lang-const c-decl-start-colon-kwd-re)) |
| @@ -3309,7 +3309,7 @@ Identifier syntax is in effect when this is matched \(see | |||
| 3309 | t (if (c-lang-const c-type-modifier-kwds) | 3309 | t (if (c-lang-const c-type-modifier-kwds) |
| 3310 | (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>") | 3310 | (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>") |
| 3311 | ;; Default to a regexp that never matches. | 3311 | ;; Default to a regexp that never matches. |
| 3312 | "a\\`") | 3312 | regexp-unmatchable) |
| 3313 | ;; Check that there's no "=" afterwards to avoid matching tokens | 3313 | ;; Check that there's no "=" afterwards to avoid matching tokens |
| 3314 | ;; like "*=". | 3314 | ;; like "*=". |
| 3315 | (c objc) (concat "\\(" | 3315 | (c objc) (concat "\\(" |
| @@ -3347,7 +3347,7 @@ that might precede the identifier in a declaration, e.g. the | |||
| 3347 | as the end of the operator. Identifier syntax is in effect when | 3347 | as the end of the operator. Identifier syntax is in effect when |
| 3348 | this is matched \(see `c-identifier-syntax-table')." | 3348 | this is matched \(see `c-identifier-syntax-table')." |
| 3349 | t ;; Default to a regexp that never matches. | 3349 | t ;; Default to a regexp that never matches. |
| 3350 | "a\\`" | 3350 | regexp-unmatchable |
| 3351 | ;; Check that there's no "=" afterwards to avoid matching tokens | 3351 | ;; Check that there's no "=" afterwards to avoid matching tokens |
| 3352 | ;; like "*=". | 3352 | ;; like "*=". |
| 3353 | (c objc) (concat "\\(\\*\\)" | 3353 | (c objc) (concat "\\(\\*\\)" |
| @@ -3506,7 +3506,7 @@ list." | |||
| 3506 | (c-lang-defconst c-pre-id-bracelist-key | 3506 | (c-lang-defconst c-pre-id-bracelist-key |
| 3507 | "A regexp matching tokens which, preceding an identifier, signify a bracelist. | 3507 | "A regexp matching tokens which, preceding an identifier, signify a bracelist. |
| 3508 | " | 3508 | " |
| 3509 | t "a\\`" ; Doesn't match anything. | 3509 | t regexp-unmatchable |
| 3510 | c++ "new\\([^[:alnum:]_$]\\|$\\)\\|&&?\\(\\S.\\|$\\)") | 3510 | c++ "new\\([^[:alnum:]_$]\\|$\\)\\|&&?\\(\\S.\\|$\\)") |
| 3511 | (c-lang-defvar c-pre-id-bracelist-key (c-lang-const c-pre-id-bracelist-key)) | 3511 | (c-lang-defvar c-pre-id-bracelist-key (c-lang-const c-pre-id-bracelist-key)) |
| 3512 | 3512 | ||
| @@ -3562,7 +3562,7 @@ the invalidity of the putative template construct." | |||
| 3562 | ;; before the '{' of the enum list, to avoid searching too far. | 3562 | ;; before the '{' of the enum list, to avoid searching too far. |
| 3563 | "[^][{};/#=]*" | 3563 | "[^][{};/#=]*" |
| 3564 | "{") | 3564 | "{") |
| 3565 | "a\\`")) ; Doesn't match anything. | 3565 | regexp-unmatchable)) |
| 3566 | (c-lang-defvar c-enum-clause-introduction-re | 3566 | (c-lang-defvar c-enum-clause-introduction-re |
| 3567 | (c-lang-const c-enum-clause-introduction-re)) | 3567 | (c-lang-const c-enum-clause-introduction-re)) |
| 3568 | 3568 | ||
| @@ -3703,7 +3703,7 @@ Only used if `c-recognize-colon-labels' is set." | |||
| 3703 | "Regexp matching things that can't occur two symbols before a colon in | 3703 | "Regexp matching things that can't occur two symbols before a colon in |
| 3704 | a label construct. This catches C++'s inheritance construct \"class foo | 3704 | a label construct. This catches C++'s inheritance construct \"class foo |
| 3705 | : bar\". Only used if `c-recognize-colon-labels' is set." | 3705 | : bar\". Only used if `c-recognize-colon-labels' is set." |
| 3706 | t "a\\`" ; Doesn't match anything. | 3706 | t regexp-unmatchable |
| 3707 | c++ (c-make-keywords-re t '("class"))) | 3707 | c++ (c-make-keywords-re t '("class"))) |
| 3708 | (c-lang-defvar c-nonlabel-token-2-key (c-lang-const c-nonlabel-token-2-key)) | 3708 | (c-lang-defvar c-nonlabel-token-2-key (c-lang-const c-nonlabel-token-2-key)) |
| 3709 | 3709 | ||
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index bd62fc754ab..e4ff9f019d3 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -1825,7 +1825,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1825 | ;; by `c-doc-line-join-re'), return the position of the first line of the | 1825 | ;; by `c-doc-line-join-re'), return the position of the first line of the |
| 1826 | ;; sequence. Otherwise, return nil. Point has no significance at entry to | 1826 | ;; sequence. Otherwise, return nil. Point has no significance at entry to |
| 1827 | ;; and exit from this function. | 1827 | ;; and exit from this function. |
| 1828 | (when (not (equal c-doc-line-join-re "a\\`")) | 1828 | (when (not (equal c-doc-line-join-re regexp-unmatchable)) |
| 1829 | (goto-char pos) | 1829 | (goto-char pos) |
| 1830 | (back-to-indentation) | 1830 | (back-to-indentation) |
| 1831 | (and (or (looking-at c-comment-start-regexp) | 1831 | (and (or (looking-at c-comment-start-regexp) |
| @@ -1842,7 +1842,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1842 | ;; marker (as defined by `c-doc-line-join-re), return the position of | 1842 | ;; marker (as defined by `c-doc-line-join-re), return the position of |
| 1843 | ;; the BOL at the end of the sequence. Otherwise, return nil. Point has no | 1843 | ;; the BOL at the end of the sequence. Otherwise, return nil. Point has no |
| 1844 | ;; significance at entry to and exit from this function. | 1844 | ;; significance at entry to and exit from this function. |
| 1845 | (when (not (equal c-doc-line-join-re "a\\`")) | 1845 | (when (not (equal c-doc-line-join-re regexp-unmatchable)) |
| 1846 | (goto-char pos) | 1846 | (goto-char pos) |
| 1847 | (back-to-indentation) | 1847 | (back-to-indentation) |
| 1848 | (let ((here (point))) | 1848 | (let ((here (point))) |
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 6e8acd4c0dd..b818bced730 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el | |||
| @@ -1648,9 +1648,9 @@ white space either before or after the operator, but not both." | |||
| 1648 | :group 'c) | 1648 | :group 'c) |
| 1649 | 1649 | ||
| 1650 | ;; Initialize the next two to a regexp which never matches. | 1650 | ;; Initialize the next two to a regexp which never matches. |
| 1651 | (defvar c-noise-macro-with-parens-name-re "a\\`") | 1651 | (defvar c-noise-macro-with-parens-name-re regexp-unmatchable) |
| 1652 | (make-variable-buffer-local 'c-noise-macro-with-parens-name-re) | 1652 | (make-variable-buffer-local 'c-noise-macro-with-parens-name-re) |
| 1653 | (defvar c-noise-macro-name-re "a\\`") | 1653 | (defvar c-noise-macro-name-re regexp-unmatchable) |
| 1654 | (make-variable-buffer-local 'c-noise-macro-name-re) | 1654 | (make-variable-buffer-local 'c-noise-macro-name-re) |
| 1655 | 1655 | ||
| 1656 | (defcustom c-noise-macro-names nil | 1656 | (defcustom c-noise-macro-names nil |
| @@ -1682,7 +1682,7 @@ These are recognized by CC Mode only in declarations." | |||
| 1682 | ;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into | 1682 | ;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into |
| 1683 | ;; `c-noise-macro-name-re' and `c-noise-macro-with-parens-name-re'. | 1683 | ;; `c-noise-macro-name-re' and `c-noise-macro-with-parens-name-re'. |
| 1684 | (setq c-noise-macro-with-parens-name-re | 1684 | (setq c-noise-macro-with-parens-name-re |
| 1685 | (cond ((null c-noise-macro-with-parens-names) "a\\`") ; Never matches. | 1685 | (cond ((null c-noise-macro-with-parens-names) regexp-unmatchable) |
| 1686 | ((consp c-noise-macro-with-parens-names) | 1686 | ((consp c-noise-macro-with-parens-names) |
| 1687 | (concat (regexp-opt c-noise-macro-with-parens-names t) | 1687 | (concat (regexp-opt c-noise-macro-with-parens-names t) |
| 1688 | "\\([^[:alnum:]_$]\\|$\\)")) | 1688 | "\\([^[:alnum:]_$]\\|$\\)")) |
| @@ -1691,7 +1691,7 @@ These are recognized by CC Mode only in declarations." | |||
| 1691 | (t (error "c-make-noise-macro-regexps: \ | 1691 | (t (error "c-make-noise-macro-regexps: \ |
| 1692 | c-noise-macro-with-parens-names is invalid: %s" c-noise-macro-with-parens-names)))) | 1692 | c-noise-macro-with-parens-names is invalid: %s" c-noise-macro-with-parens-names)))) |
| 1693 | (setq c-noise-macro-name-re | 1693 | (setq c-noise-macro-name-re |
| 1694 | (cond ((null c-noise-macro-names) "a\\`") ; Never matches anything. | 1694 | (cond ((null c-noise-macro-names) regexp-unmatchable) |
| 1695 | ((consp c-noise-macro-names) | 1695 | ((consp c-noise-macro-names) |
| 1696 | (concat (regexp-opt c-noise-macro-names t) | 1696 | (concat (regexp-opt c-noise-macro-names t) |
| 1697 | "\\([^[:alnum:]_$]\\|$\\)")) | 1697 | "\\([^[:alnum:]_$]\\|$\\)")) |
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 85f9078d46d..79178c4346e 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -837,7 +837,8 @@ This function is called from `compilation-filter-hook'." | |||
| 837 | grep-mode-line-matches) | 837 | grep-mode-line-matches) |
| 838 | ;; compilation-directory-matcher can't be nil, so we set it to a regexp that | 838 | ;; compilation-directory-matcher can't be nil, so we set it to a regexp that |
| 839 | ;; can never match. | 839 | ;; can never match. |
| 840 | (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) | 840 | (set (make-local-variable 'compilation-directory-matcher) |
| 841 | (list regexp-unmatchable)) | ||
| 841 | (set (make-local-variable 'compilation-process-setup-function) | 842 | (set (make-local-variable 'compilation-process-setup-function) |
| 842 | 'grep-process-setup) | 843 | 'grep-process-setup) |
| 843 | (set (make-local-variable 'compilation-disable-input) t) | 844 | (set (make-local-variable 'compilation-disable-input) t) |
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 52e5fd477f4..8a7e24e5ada 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -1691,7 +1691,7 @@ code line." | |||
| 1691 | (eval-and-compile (require 'help-mode)) | 1691 | (eval-and-compile (require 'help-mode)) |
| 1692 | ;; Don't highlight `EXAMPLE' as elisp symbols by using a regexp that | 1692 | ;; Don't highlight `EXAMPLE' as elisp symbols by using a regexp that |
| 1693 | ;; can never match. | 1693 | ;; can never match. |
| 1694 | (setq-local help-xref-symbol-regexp "x\\`")) | 1694 | (setq-local help-xref-symbol-regexp regexp-unmatchable)) |
| 1695 | 1695 | ||
| 1696 | (defun octave-help (fn) | 1696 | (defun octave-help (fn) |
| 1697 | "Display the documentation of FN." | 1697 | "Display the documentation of FN." |
diff --git a/lisp/subr.el b/lisp/subr.el index be21dc67a0d..05fb9fea68f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -5544,4 +5544,8 @@ returned list are in the same order as in TREE. | |||
| 5544 | ;; for discoverability: | 5544 | ;; for discoverability: |
| 5545 | (defalias 'flatten-list 'flatten-tree) | 5545 | (defalias 'flatten-list 'flatten-tree) |
| 5546 | 5546 | ||
| 5547 | ;; The initial anchoring is for better performance in searching matches. | ||
| 5548 | (defconst regexp-unmatchable "\\`a\\`" | ||
| 5549 | "Standard regexp guaranteed not to match any string at all.") | ||
| 5550 | |||
| 5547 | ;;; subr.el ends here | 5551 | ;;; subr.el ends here |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 6553a2799bb..0c5e6a183b5 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -4016,7 +4016,7 @@ You can bind this to the key C-c i in GNUS or mail by adding to | |||
| 4016 | 4016 | ||
| 4017 | (defun ispell-non-empty-string (string) | 4017 | (defun ispell-non-empty-string (string) |
| 4018 | (if (or (not string) (string-equal string "")) | 4018 | (if (or (not string) (string-equal string "")) |
| 4019 | "\\'\\`" ; An unmatchable string if string is null. | 4019 | regexp-unmatchable |
| 4020 | (regexp-quote string))) | 4020 | (regexp-quote string))) |
| 4021 | 4021 | ||
| 4022 | 4022 | ||
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index ab5a449cd3d..ee1646cae5a 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -702,7 +702,7 @@ or a superior directory.") | |||
| 702 | (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack. | 702 | (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack. |
| 703 | (require 'add-log) | 703 | (require 'add-log) |
| 704 | (set (make-local-variable 'log-view-per-file-logs) nil) | 704 | (set (make-local-variable 'log-view-per-file-logs) nil) |
| 705 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") | 705 | (set (make-local-variable 'log-view-file-re) regexp-unmatchable) |
| 706 | (set (make-local-variable 'log-view-message-re) | 706 | (set (make-local-variable 'log-view-message-re) |
| 707 | (if (eq vc-log-view-type 'short) | 707 | (if (eq vc-log-view-type 'short) |
| 708 | "^ *\\([0-9.]+\\): \\(.*?\\)[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)\\( \\[merge\\]\\)?" | 708 | "^ *\\([0-9.]+\\): \\(.*?\\)[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)\\( \\[merge\\]\\)?" |
| @@ -1319,7 +1319,8 @@ stream. Standard error output is discarded." | |||
| 1319 | ((string-match "\\`annotate:" string) | 1319 | ((string-match "\\`annotate:" string) |
| 1320 | (completion-table-with-context | 1320 | (completion-table-with-context |
| 1321 | (substring string 0 (match-end 0)) | 1321 | (substring string 0 (match-end 0)) |
| 1322 | (apply-partially #'completion-table-with-terminator '(":" . "\\`a\\`") | 1322 | (apply-partially #'completion-table-with-terminator |
| 1323 | (cons ":" regexp-unmatchable) | ||
| 1323 | #'completion-file-name-table) | 1324 | #'completion-file-name-table) |
| 1324 | (substring string (match-end 0)) pred action)) | 1325 | (substring string (match-end 0)) pred action)) |
| 1325 | 1326 | ||
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 192e6cf68f6..61c13026cc5 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -1087,7 +1087,7 @@ If LIMIT is a revision string, use it as an end-revision." | |||
| 1087 | (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" | 1087 | (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" |
| 1088 | (require 'add-log) ;; We need the faces add-log. | 1088 | (require 'add-log) ;; We need the faces add-log. |
| 1089 | ;; Don't have file markers, so use impossible regexp. | 1089 | ;; Don't have file markers, so use impossible regexp. |
| 1090 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") | 1090 | (set (make-local-variable 'log-view-file-re) regexp-unmatchable) |
| 1091 | (set (make-local-variable 'log-view-per-file-logs) nil) | 1091 | (set (make-local-variable 'log-view-per-file-logs) nil) |
| 1092 | (set (make-local-variable 'log-view-message-re) | 1092 | (set (make-local-variable 'log-view-message-re) |
| 1093 | (if (not (eq vc-log-view-type 'long)) | 1093 | (if (not (eq vc-log-view-type 'long)) |
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index d3f132dae70..876d824ceac 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -444,7 +444,7 @@ If LIMIT is non-nil, show no more than this many entries." | |||
| 444 | 444 | ||
| 445 | (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View" | 445 | (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View" |
| 446 | (require 'add-log) ;; we need the add-log faces | 446 | (require 'add-log) ;; we need the add-log faces |
| 447 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") | 447 | (set (make-local-variable 'log-view-file-re) regexp-unmatchable) |
| 448 | (set (make-local-variable 'log-view-per-file-logs) nil) | 448 | (set (make-local-variable 'log-view-per-file-logs) nil) |
| 449 | (set (make-local-variable 'log-view-message-re) | 449 | (set (make-local-variable 'log-view-message-re) |
| 450 | (if (eq vc-log-view-type 'short) | 450 | (if (eq vc-log-view-type 'short) |
diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el index f0b12489c1b..91cc28021cf 100644 --- a/lisp/vc/vc-mtn.el +++ b/lisp/vc/vc-mtn.el | |||
| @@ -240,7 +240,7 @@ If LIMIT is non-nil, show no more than this many entries." | |||
| 240 | 240 | ||
| 241 | (define-derived-mode vc-mtn-log-view-mode log-view-mode "Mtn-Log-View" | 241 | (define-derived-mode vc-mtn-log-view-mode log-view-mode "Mtn-Log-View" |
| 242 | ;; Don't match anything. | 242 | ;; Don't match anything. |
| 243 | (set (make-local-variable 'log-view-file-re) "\\`a\\`") | 243 | (set (make-local-variable 'log-view-file-re) regexp-unmatchable) |
| 244 | (set (make-local-variable 'log-view-per-file-logs) nil) | 244 | (set (make-local-variable 'log-view-per-file-logs) nil) |
| 245 | ;; TODO: Use a more precise regexp than "[ |/]+" to avoid false positives | 245 | ;; TODO: Use a more precise regexp than "[ |/]+" to avoid false positives |
| 246 | ;; in the ChangeLog text. | 246 | ;; in the ChangeLog text. |