summaryrefslogtreecommitdiff
path: root/helm-lib.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-10-16 08:17:01 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-10-16 08:17:01 +0200
commit17ae400436b3cbf2ff36dd527be35eea946c2cc2 (patch)
tree6634ed225ab241ba2c2cd10841be694ba1a0a0ab /helm-lib.el
parentf93867cc38ca6a35906c024443da63febffe55c3 (diff)
Fix default TEST in helm-position
* helm-lib.el (helm-position): Do it.
Diffstat (limited to 'helm-lib.el')
-rw-r--r--helm-lib.el15
1 files changed, 8 insertions, 7 deletions
diff --git a/helm-lib.el b/helm-lib.el
index 2bcb2134..3556ec60 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -525,19 +525,20 @@ Otherwise make a list with one element."
obj
(list obj)))
-(cl-defmacro helm-position (item seq &key (test 'eq) all)
+(cl-defmacro helm-position (item seq &key test all)
"A simple and faster replacement of CL `position'.
Return position of first occurence of ITEM found in SEQ.
Argument SEQ can be a string, in this case ITEM have to be a char.
Argument ALL, if non--nil specify to return a list of positions of
all ITEM found in SEQ."
(let ((key (if (stringp seq) 'across 'in)))
- `(cl-loop for c ,key ,seq
- for index from 0
- when (funcall ,test c ,item)
- if ,all collect index into ls
- else return index
- finally return ls)))
+ `(cl-loop with deftest = 'eq
+ for c ,key ,seq
+ for index from 0
+ when (funcall (or ,test deftest) c ,item)
+ if ,all collect index into ls
+ else return index
+ finally return ls)))
(cl-defun helm-fast-remove-dups (seq &key (test 'eq))
"Remove duplicates elements in list SEQ.