emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/el-search e29370e 281/332: [el-search] Fix more "redund


From: Stefan Monnier
Subject: [elpa] externals/el-search e29370e 281/332: [el-search] Fix more "redundant _ pattern" warnings
Date: Tue, 1 Dec 2020 15:49:04 -0500 (EST)

branch: externals/el-search
commit e29370ee66628dda1e5b0b20e9439235a2235c1f
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>

    [el-search] Fix more "redundant _ pattern" warnings
    
    Also bump version to 1.8.7.
    
    * packages/el-search/el-search.el (el-search-make-matcher): Handle
    symbols directly as catchall patterns.  Remove redundant second pcase
    branch.
    * packages/el-search/el-search-x.el (append): Handle one more corner
    case specially.
---
 el-search-x.el |  8 +++++---
 el-search.el   | 17 ++++++++++-------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/el-search-x.el b/el-search-x.el
index 0af955c..58b5251 100644
--- a/el-search-x.el
+++ b/el-search-x.el
@@ -95,8 +95,10 @@ Example: the pattern
    (append '(1 2 3) x (app car-safe 7))
 
 matches the list (1 2 3 4 5 6 7 8 9), binding `x' to (4 5 6)."
-  (if (null patterns)
-      '(pred null)
+  (cond
+   ((null patterns)       '(pred null))
+   ((equal patterns '(_)) '(pred listp))
+   (t
     (pcase-let ((`(,pattern . ,more-patterns) patterns))
       (cond
        ((null more-patterns) pattern)
@@ -106,7 +108,7 @@ matches the list (1 2 3 4 5 6 7 8 9), binding `x' to (4 5 
6)."
                                      (el-search-make-matcher pattern)
                                      (el-search-make-matcher (car 
more-patterns)))
                    `(,,pattern ,,(car more-patterns)))))
-       (t `(append ,pattern (append ,@more-patterns)))))))
+       (t `(append ,pattern (append ,@more-patterns))))))))
 
 (defcustom el-search-lazy-l t
   "Whether to interpret symbols and strings specially in `l'.
diff --git a/el-search.el b/el-search.el
index 1edb198..65e2dfd 100644
--- a/el-search.el
+++ b/el-search.el
@@ -7,7 +7,7 @@
 ;; Created: 29 Jul 2015
 ;; Keywords: lisp
 ;; Compatibility: GNU Emacs 25
-;; Version: 1.8.6
+;; Version: 1.8.7
 ;; Package-Requires: ((emacs "25") (stream "2.2.4") (cl-print "1.0"))
 
 
@@ -1073,14 +1073,17 @@ N times."
      (defvar warning-suppress-log-types)
      (let ((byte-compile-debug t) ;make undefined pattern types raise an error
            (warning-suppress-log-types '((bytecomp)))
-           (pattern-is-catchall (eq pattern '_)))
+           (pattern-is-catchall (memq pattern '(_ t)))
+           (pattern-is-symbol   (and (symbolp pattern)
+                                     (not (or (keywordp pattern)
+                                              (null pattern))))))
        (byte-compile
         `(lambda (,(if pattern-is-catchall '_ expression))
-           ,(if pattern-is-catchall
-                (if result-specified result-expr t)
-              `(pcase ,expression
-                 (,pattern ,(if result-specified result-expr t))
-                 (_        nil)))))))))
+           ,(cond
+             (pattern-is-catchall (if result-specified result-expr t))
+             ((and pattern-is-symbol (not result-specified)) t)
+             (t `(pcase ,expression
+                   (,pattern ,(if result-specified result-expr t)))))))))))
 
 (defun el-search--match-p (matcher expression)
   (funcall matcher expression))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]