branch: master
commit dda90f7d7585e4e03cc7ef3a5b649995f0b91649
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-unquote-regex-parens): Handle cons arg
Fixes #1322
---
counsel.el | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/counsel.el b/counsel.el
index a4bb0b0..ab2c1db 100644
--- a/counsel.el
+++ b/counsel.el
@@ -54,25 +54,30 @@
(defun counsel-unquote-regex-parens (str)
"Unquote regex parenthesis in STR."
- (let ((start 0)
- ms)
- (while (setq start (string-match "\\\\)\\|\\\\(\\|[()]" str start))
- (setq ms (match-string-no-properties 0 str))
- (cond ((equal ms "\\(")
- (setq str (replace-match "(" nil t str))
- (setq start (+ start 1)))
- ((equal ms "\\)")
- (setq str (replace-match ")" nil t str))
- (setq start (+ start 1)))
- ((equal ms "(")
- (setq str (replace-match "\\(" nil t str))
- (setq start (+ start 2)))
- ((equal ms ")")
- (setq str (replace-match "\\)" nil t str))
- (setq start (+ start 2)))
- (t
- (error "Unexpected"))))
- str))
+ (if (consp str)
+ (mapconcat
+ #'car
+ (cl-remove-if-not #'cdr str)
+ ".*")
+ (let ((start 0)
+ ms)
+ (while (setq start (string-match "\\\\)\\|\\\\(\\|[()]" str start))
+ (setq ms (match-string-no-properties 0 str))
+ (cond ((equal ms "\\(")
+ (setq str (replace-match "(" nil t str))
+ (setq start (+ start 1)))
+ ((equal ms "\\)")
+ (setq str (replace-match ")" nil t str))
+ (setq start (+ start 1)))
+ ((equal ms "(")
+ (setq str (replace-match "\\(" nil t str))
+ (setq start (+ start 2)))
+ ((equal ms ")")
+ (setq str (replace-match "\\)" nil t str))
+ (setq start (+ start 2)))
+ (t
+ (error "Unexpected"))))
+ str)))
(defun counsel-directory-parent (dir)
"Return the directory parent of directory DIR."