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

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

[nongnu] elpa/helm 80233cbea6 2/2: Try to compute completing-read's DEFA


From: ELPA Syncer
Subject: [nongnu] elpa/helm 80233cbea6 2/2: Try to compute completing-read's DEFAULT arg from prompt
Date: Sun, 21 Jan 2024 03:59:56 -0500 (EST)

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

    Try to compute completing-read's DEFAULT arg from prompt
    
    when it is not provided.
    
    Some completing-read's are providing DEFAULT in prompt but the DEFAULT
    argument of completing-read is not provided, try here to extract DEFAULT
    from PROMPT which is typically a prompt builded with format-prompt.
    See `describe-language-environment' as example.
---
 helm-mode.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/helm-mode.el b/helm-mode.el
index b9a383646b..d88bcafdac 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -1610,15 +1610,24 @@ Use either `helm-completing-read-default-1' or 
`helm-completing-read-default-2'
 according to `helm-completion-style'."
   (let* (;; Standard will be used as CANDS-IN-BUFFER arg.
          (standard (and (memq helm-completion-style '(helm helm-fuzzy)) t))
+         (def (or default (helm-mode--find-default-in-prompt prompt)))
          (fn (if standard
                  #'helm-completing-read-default-1
                #'helm-completing-read-default-2)))
     (funcall fn
              prompt collection test require-match
-             init hist default inherit-input-method name buffer
+             init hist def inherit-input-method name buffer
              ;; CANDS-IN-BUFFER
              standard)))
 
+(defun helm-mode--find-default-in-prompt (prompt)
+  ;; Some completing-read's are providing DEFAULT in prompt but the DEFAULT
+  ;; argument of completing-read is not provided, try here to extract DEFAULT
+  ;; from PROMPT which is typically a prompt builded with format-prompt.
+  ;; See `describe-language-environment' as example.
+  (when (string-match "\\`.*\\([(]default \\(.*\\)[)]\\):" prompt)
+    (match-string 2 prompt)))
+
 (defun helm-mode--read-buffer-to-switch (prompt)
   "[INTERNAL] This is used to advice `read-buffer-to-switch'.
 Don't use it directly."



reply via email to

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