]> code.delx.au - gnu-emacs-elpa/commitdiff
el-search--read-pattern: fix default(s)
authorMichael Heerdegen <michael_heerdegen@web.de>
Sat, 24 Oct 2015 22:06:22 +0000 (00:06 +0200)
committerMichael Heerdegen <michael_heerdegen@web.de>
Sat, 31 Oct 2015 18:16:58 +0000 (19:16 +0100)
packages/el-search/el-search.el

index e2f1b5abb9b45f5ffaf337028ac08ec41ae5900d..13bfdfa5a2670b9bb4664b125f3a3a32ee91092e 100644 (file)
@@ -236,11 +236,17 @@ prompt to refer to the value of the currently tested expression."
                           (or hist 'read-expression-history) default)))
 
 (defun el-search--read-pattern (prompt &optional default read)
-  (el-search-read-expression
-   prompt el-search--initial-mb-contents 'el-search-history
-   (or default (when-let ((this-sexp (sexp-at-point)))
-                 (concat "'" (el-search--print this-sexp))))
-   read))
+  (let ((this-sexp (sexp-at-point)))
+    (minibuffer-with-setup-hook
+        (lambda ()
+          (when this-sexp
+            (let ((more-defaults (list (concat "'" (el-search--print this-sexp)))))
+              (setq-local minibuffer-default-add-function
+                          (lambda () (if (listp minibuffer-default)
+                                    (append minibuffer-default more-defaults)
+                                  (cons minibuffer-default more-defaults)))))))
+      (el-search-read-expression 
+       prompt el-search--initial-mb-contents 'el-search-history default read))))
 
 (defun el-search--end-of-sexp ()
   ;;Point must be at sexp beginning