diff options
| author | Mattias EngdegÄrd | 2019-05-20 17:38:03 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-05-20 17:38:03 +0200 |
| commit | c2cda3ff4025e8c27bdfc2a5279f3b635c8df260 (patch) | |
| tree | 20d58564a6aa5dcbd6fc1c9fd94e95738dceeeb7 | |
| parent | d3a0ddedba53b9e2c99274c8ec125d53f991da5d (diff) | |
| download | emacs-c2cda3ff4025e8c27bdfc2a5279f3b635c8df260.tar.gz emacs-c2cda3ff4025e8c27bdfc2a5279f3b635c8df260.zip | |
Revert "Allow zero-argument rx `or' and `seq' forms"
This reverts commit b552fc05c231ca6800330a318d3a74ddd0f5a13c.
It caused a bootstrapping failure which I have yet to resolve - sorry.
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/rx.el | 13 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 8 |
3 files changed, 6 insertions, 21 deletions
| @@ -1321,12 +1321,6 @@ when given in a string. Previously, '(any "\x80-\xff")' would match | |||
| 1321 | characters U+0080...U+00FF. Now the expression matches raw bytes in | 1321 | characters U+0080...U+00FF. Now the expression matches raw bytes in |
| 1322 | the 128...255 range, as expected. | 1322 | the 128...255 range, as expected. |
| 1323 | 1323 | ||
| 1324 | *** The rx 'or' and 'seq' forms no longer require any arguments. | ||
| 1325 | (or) produces a regexp that never matches anything, while (seq) | ||
| 1326 | matches the empty string, each being an identity for the operation. | ||
| 1327 | This also works for their aliases: '|' for 'or'; ':', 'and' and | ||
| 1328 | 'sequence' for 'seq'. | ||
| 1329 | |||
| 1330 | ** Frames | 1324 | ** Frames |
| 1331 | 1325 | ||
| 1332 | +++ | 1326 | +++ |
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 9478bd3bbdb..9d9028d87d5 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el | |||
| @@ -110,11 +110,11 @@ | |||
| 110 | ;; FIXME: support macros. | 110 | ;; FIXME: support macros. |
| 111 | 111 | ||
| 112 | (defvar rx-constituents ;Not `const' because some modes extend it. | 112 | (defvar rx-constituents ;Not `const' because some modes extend it. |
| 113 | '((and . (rx-and 0 nil)) | 113 | '((and . (rx-and 1 nil)) |
| 114 | (seq . and) ; SRE | 114 | (seq . and) ; SRE |
| 115 | (: . and) ; SRE | 115 | (: . and) ; SRE |
| 116 | (sequence . and) ; sregex | 116 | (sequence . and) ; sregex |
| 117 | (or . (rx-or 0 nil)) | 117 | (or . (rx-or 1 nil)) |
| 118 | (| . or) ; SRE | 118 | (| . or) ; SRE |
| 119 | (not-newline . ".") | 119 | (not-newline . ".") |
| 120 | (nonl . not-newline) ; SRE | 120 | (nonl . not-newline) ; SRE |
| @@ -390,11 +390,9 @@ FORM is of the form `(and FORM1 ...)'." | |||
| 390 | "Parse and produce code from FORM, which is `(or FORM1 ...)'." | 390 | "Parse and produce code from FORM, which is `(or FORM1 ...)'." |
| 391 | (rx-check form) | 391 | (rx-check form) |
| 392 | (rx-group-if | 392 | (rx-group-if |
| 393 | (cond | 393 | (if (memq nil (mapcar 'stringp (cdr form))) |
| 394 | ((null (cdr form)) regexp-unmatchable) | 394 | (mapconcat (lambda (x) (rx-form x '|)) (cdr form) "\\|") |
| 395 | ((cl-every #'stringp (cdr form)) | ||
| 396 | (regexp-opt (cdr form) nil t)) | 395 | (regexp-opt (cdr form) nil t)) |
| 397 | (t (mapconcat (lambda (x) (rx-form x '|)) (cdr form) "\\|"))) | ||
| 398 | (and (memq rx-parent '(: * t)) rx-parent))) | 396 | (and (memq rx-parent '(: * t)) rx-parent))) |
| 399 | 397 | ||
| 400 | 398 | ||
| @@ -1123,7 +1121,6 @@ CHAR | |||
| 1123 | `(seq SEXP1 SEXP2 ...)' | 1121 | `(seq SEXP1 SEXP2 ...)' |
| 1124 | `(sequence SEXP1 SEXP2 ...)' | 1122 | `(sequence SEXP1 SEXP2 ...)' |
| 1125 | matches what SEXP1 matches, followed by what SEXP2 matches, etc. | 1123 | matches what SEXP1 matches, followed by what SEXP2 matches, etc. |
| 1126 | Without arguments, matches the empty string. | ||
| 1127 | 1124 | ||
| 1128 | `(submatch SEXP1 SEXP2 ...)' | 1125 | `(submatch SEXP1 SEXP2 ...)' |
| 1129 | `(group SEXP1 SEXP2 ...)' | 1126 | `(group SEXP1 SEXP2 ...)' |
| @@ -1139,7 +1136,7 @@ CHAR | |||
| 1139 | `(| SEXP1 SEXP2 ...)' | 1136 | `(| SEXP1 SEXP2 ...)' |
| 1140 | matches anything that matches SEXP1 or SEXP2, etc. If all | 1137 | matches anything that matches SEXP1 or SEXP2, etc. If all |
| 1141 | args are strings, use `regexp-opt' to optimize the resulting | 1138 | args are strings, use `regexp-opt' to optimize the resulting |
| 1142 | regular expression. Without arguments, never matches anything. | 1139 | regular expression. |
| 1143 | 1140 | ||
| 1144 | `(minimal-match SEXP)' | 1141 | `(minimal-match SEXP)' |
| 1145 | produce a non-greedy regexp for SEXP. Normally, regexps matching | 1142 | produce a non-greedy regexp for SEXP. Normally, regexps matching |
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 6f392d616d1..4a5919edf02 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -107,13 +107,7 @@ | |||
| 107 | "ab")) | 107 | "ab")) |
| 108 | (should (equal (and (string-match (rx (or "a" "ab" "abc")) s) | 108 | (should (equal (and (string-match (rx (or "a" "ab" "abc")) s) |
| 109 | (match-string 0 s)) | 109 | (match-string 0 s)) |
| 110 | "a"))) | 110 | "a")))) |
| 111 | ;; Test zero-argument `or'. | ||
| 112 | (should (equal (rx (or)) regexp-unmatchable))) | ||
| 113 | |||
| 114 | (ert-deftest rx-seq () | ||
| 115 | ;; Test zero-argument `seq'. | ||
| 116 | (should (equal (rx (seq)) ""))) | ||
| 117 | 111 | ||
| 118 | (provide 'rx-tests) | 112 | (provide 'rx-tests) |
| 119 | ;; rx-tests.el ends here. | 113 | ;; rx-tests.el ends here. |