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

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

[nongnu] elpa/helm 26313b28d1: Setup helm-pattern in helm-initial-setup


From: ELPA Syncer
Subject: [nongnu] elpa/helm 26313b28d1: Setup helm-pattern in helm-initial-setup
Date: Tue, 23 Aug 2022 14:58:41 -0400 (EDT)

branch: elpa/helm
commit 26313b28d1c57ac0b46fec4fbf9741358050da03
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Setup helm-pattern in helm-initial-setup
    
    Previously we were setting helm-pattern according to default in
    helm-initial-setup and we were overriding it later in helm-initialize
    (after calling helm-initial-setup).
    Now we are setting it in the same place which make the code more
    readable and comprehensive.
    Also pattern is set before calling init functions in case inout or
    default is used in these functions to initialize candidates.
    See (#2530) and <https://github.com/emacs-helm/helm-mu/issues/54>.
---
 helm-core.el | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index cbdb3405c9..c7d68cf326 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -3635,15 +3635,11 @@ For RESUME INPUT DEFAULT and SOURCES see `helm'."
     (helm-current-position 'save)
     (if (helm-resume-p resume)
         (helm-initialize-overlays (helm-buffer-get))
-      (helm-initial-setup default sources-list))
+      (helm-initial-setup input default sources-list))
     (setq helm-alive-p t)
     (unless (eq resume 'noresume)
       (helm--push-and-remove-dups helm-buffer 'helm-buffers)
       (setq helm-last-buffer helm-buffer))
-    (when input
-      (setq helm-input input
-            helm-pattern input)
-      (helm--fuzzy-match-maybe-set-pattern))
     ;; If a `resume' attribute is present `helm-compute-attr-in-sources'
     ;; will run its function.
     (when (helm-resume-p resume)
@@ -3664,7 +3660,7 @@ For RESUME INPUT DEFAULT and SOURCES see `helm'."
     (overlay-put helm-selection-overlay 'face 'helm-selection)
     (overlay-put helm-selection-overlay 'priority 1)))
 
-(defun helm-initial-setup (default sources)
+(defun helm-initial-setup (input default sources)
   "Initialize Helm settings and set up the Helm buffer."
   ;; Run global hook.
   (helm-log-run-hook 'helm-before-initialize-hook)
@@ -3700,15 +3696,26 @@ For RESUME INPUT DEFAULT and SOURCES see `helm'."
               'vertical 'horizontal))
     (setq helm--window-side-state
           (or helm-split-window-default-side 'below)))
+  ;; Some sources like helm-mu are using input to init their
+  ;; candidates in init function, so setup initial helm-pattern here.
+  ;; See bug#2530 and https://github.com/emacs-helm/helm-mu/issues/54.
+  (cond (input
+         (setq helm-input input
+               helm-pattern input))
+        (default
+         (setq helm-pattern (or (and helm-maybe-use-default-as-input
+                                     (or (if (listp default)
+                                             (car default) default)
+                                         (with-helm-current-buffer
+                                           (thing-at-point 'symbol))))
+                                "")
+               ;; Even if there is default in helm-pattern we want the
+               ;; prompt to be empty when using default as input, why
+               ;; helm-input is initialized to "".
+               helm-input "")))
+  (helm--fuzzy-match-maybe-set-pattern)
   ;; Call the init function for sources where appropriate
   (helm-compute-attr-in-sources 'init sources)
-  (setq helm-pattern (or (and helm-maybe-use-default-as-input
-                              (or (if (listp default)
-                                      (car default) default)
-                                  (with-helm-current-buffer
-                                    (thing-at-point 'symbol))))
-                         ""))
-  (setq helm-input "")
   (clrhash helm-candidate-cache)
   (helm-create-helm-buffer)
   (helm-clear-visible-mark)



reply via email to

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