diff options
| author | Michael Heerdegen | 2018-06-13 04:37:38 +0200 |
|---|---|---|
| committer | Michael Heerdegen | 2018-06-17 15:22:30 +0200 |
| commit | 45ee24efed57093b421159ca1028097952f2d564 (patch) | |
| tree | f6172378d6be486b5ec339d3363a632877970108 | |
| parent | fa9679ca488a17b2b6b9f31299d69c190aa86642 (diff) | |
| download | emacs-45ee24efed57093b421159ca1028097952f2d564.tar.gz emacs-45ee24efed57093b421159ca1028097952f2d564.zip | |
Allow floats as 'pcase' QPATS
* lisp/emacs-lisp/pcase.el (\`): Extend semantics of QPATS to all
numbers. Add a comment explaining why we disallow some atoms as
QPATS.
* doc/lispref/control.texi (Backquote Patterns): Update the paragraph
explaining QPATS. Remove a sentence suggesting an analogy between
QPATS to self-quoting objects.
| -rw-r--r-- | doc/lispref/control.texi | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/pcase.el | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 34f5f570440..975ab3d0759 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi | |||
| @@ -1090,12 +1090,10 @@ Matches if @var{expval} is a vector of length @var{m} whose | |||
| 1090 | 1090 | ||
| 1091 | @item @var{symbol} | 1091 | @item @var{symbol} |
| 1092 | @itemx @var{keyword} | 1092 | @itemx @var{keyword} |
| 1093 | @itemx @var{integer} | 1093 | @itemx @var{number} |
| 1094 | @itemx @var{string} | 1094 | @itemx @var{string} |
| 1095 | Matches if the corresponding element of @var{expval} is | 1095 | Matches if the corresponding element of @var{expval} is |
| 1096 | @code{equal} to the specified literal object. | 1096 | @code{equal} to the specified literal object. |
| 1097 | Note that, aside from @var{symbol}, this is the same set of | ||
| 1098 | self-quoting literal objects that are acceptable as a core pattern. | ||
| 1099 | 1097 | ||
| 1100 | @item ,@var{pattern} | 1098 | @item ,@var{pattern} |
| 1101 | Matches if the corresponding element of @var{expval} | 1099 | Matches if the corresponding element of @var{expval} |
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index fa7b1de8b4d..4a69244d265 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el | |||
| @@ -919,7 +919,7 @@ QPAT can take the following forms: | |||
| 919 | ,PAT matches if the `pcase' pattern PAT matches. | 919 | ,PAT matches if the `pcase' pattern PAT matches. |
| 920 | SYMBOL matches if EXPVAL is `equal' to SYMBOL. | 920 | SYMBOL matches if EXPVAL is `equal' to SYMBOL. |
| 921 | KEYWORD likewise for KEYWORD. | 921 | KEYWORD likewise for KEYWORD. |
| 922 | INTEGER likewise for INTEGER. | 922 | NUMBER likewise for NUMBER. |
| 923 | STRING likewise for STRING. | 923 | STRING likewise for STRING. |
| 924 | 924 | ||
| 925 | The list or vector QPAT is a template. The predicate formed | 925 | The list or vector QPAT is a template. The predicate formed |
| @@ -949,7 +949,10 @@ The predicate is the logical-AND of: | |||
| 949 | `(and (pred consp) | 949 | `(and (pred consp) |
| 950 | (app car ,(list '\` (car qpat))) | 950 | (app car ,(list '\` (car qpat))) |
| 951 | (app cdr ,(list '\` (cdr qpat))))) | 951 | (app cdr ,(list '\` (cdr qpat))))) |
| 952 | ((or (stringp qpat) (integerp qpat) (symbolp qpat)) `',qpat) | 952 | ((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat) |
| 953 | ;; In all other cases just raise an error so we can't break | ||
| 954 | ;; backward compatibility when adding \` support for other | ||
| 955 | ;; compounded values that are not `consp' | ||
| 953 | (t (error "Unknown QPAT: %S" qpat)))) | 956 | (t (error "Unknown QPAT: %S" qpat)))) |
| 954 | 957 | ||
| 955 | (provide 'pcase) | 958 | (provide 'pcase) |