summaryrefslogtreecommitdiff
path: root/helm-lib.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2018-10-27 10:49:07 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2018-10-27 14:22:18 +0200
commit5a34aef77d8cd899cc142175bd953b5dd43ed478 (patch)
tree706e9cddedc087afdef7fabfdd1e794c6b7f065a /helm-lib.el
parent4a99e9003b581f4e0229c23a44f92c6185064816 (diff)
New macro helm-case
* helm-files.el (helm-list-dir-external): Use it. (helm-delete-file): Use it. * helm-lib.el (helm-case): New.
Diffstat (limited to 'helm-lib.el')
-rw-r--r--helm-lib.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/helm-lib.el b/helm-lib.el
index 4bb71cf7..88ae6f24 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -454,6 +454,21 @@ The usage is the same as `cond'."
(t `(helm-aif ,(car conditions)
(helm-aand ,@(cdr conditions))))))
+;;; Improved existing functions or macros
+;;
+(defmacro helm-case (expr &rest clauses)
+ "A simpler `cl-case' implementation handling strings.
+NOTE: Duplicate keys in CLAUSES are deliberately not handled."
+ (declare (indent 1) (debug t))
+ (unless (null clauses)
+ (let ((clause1 (car clauses)))
+ `(let ((key ',(car clause1)))
+ (if (or (equal ,expr key)
+ (eq key t)
+ (and (listp key) (member ,expr key)))
+ (progn ,@(cdr clause1))
+ (helm-case ,expr ,@(cdr clauses)))))))
+
;;; Fuzzy matching routines
;;
(defsubst helm--mapconcat-pattern (pattern)