branch: externals/denote
commit 0d855bbf1264347a16ce54d707af3698a4ec8eb6
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Make 'denote-{title,signature}-prompt' complete from its history
    
    I am implementing this in response to feedback provided by Suhail
    Singh who asked that signatures should behave more like keywords. What
    I am doing here is not exactly that because keywords can be many
    whereas a signature is one, like a title.
    
    Completion from its own history may not be what we settle on. I am
    open to suggestions on how to make this more user friendly. I just
    don't want to introduce new user options before knowing exactly what
    the needs are.
    
    Suhail's feedback on the mailing list:
    
<https://lists.sr.ht/~protesilaos/denote/%3C652d82c0.c80a0220.e6282.dc47%40mx.google.com%3E#%3c65380146.c80a0220.4698b.d...@mx.google.com%3E>.
---
 README.org | 16 +++++++++++-----
 denote.el  | 22 ++++++++++++++++------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/README.org b/README.org
index 5aa72082a3..e3e27ee311 100644
--- a/README.org
+++ b/README.org
@@ -3844,10 +3844,13 @@ might change them without further notice.
   and apply ~denote-sluggify-signature~ to it. With optional
   =DEFAULT-SIGNATURE= use it as the default minibuffer value. With
   optional =PROMPT-TEXT= use it in the minibuffer instead of the
-  default prompt. [ The =DEFAULT-SIGNATURE= and =PROMPT-TEXT=
-  arguments are added as part of {{{development-version}}}. Same for
-  the parsing application of ~denote-sluggify-signature~ to the user
-  input (this was always the intent). ]
+  default prompt. Previous inputs at this prompt are available for
+  minibuffer completion. Consider ~savehist-mode~ to persist
+  minibuffer histories between sessions. [ The =DEFAULT-SIGNATURE= and
+  =PROMPT-TEXT= arguments, as well as previous input completion, are
+  added as part of {{{development-version}}}. Same for the parsing
+  application of ~denote-sluggify-signature~ to the user input (this
+  was always the intent). ]
 
 #+findex: denote-file-prompt
 + Function ~denote-file-prompt~ :: Prompt for file with identifier in
@@ -3871,7 +3874,10 @@ might change them without further notice.
 + Function ~denote-title-prompt~ :: Read file title for ~denote~. With
   optional =DEFAULT-TITLE= use it as the default value. With optional
   =PROMPT-TEXT= use it in the minibuffer instead of the generic
-  prompt. [ The =PROMPT-TEXT= is part of {{{development-version}}}. ]
+  prompt. Previous inputs at this prompt are available for minibuffer
+  completion. Consider ~savehist-mode~ to persist minibuffer histories
+  between sessions. [ The =PROMPT-TEXT= and completion of previous
+  inputs are part of {{{development-version}}}. ]
 
 #+vindex: denote-title-prompt-current-default
 + Variable ~denote-title-prompt-current-default~ :: Currently bound
diff --git a/denote.el b/denote.el
index a88f4b8469..284d775509 100644
--- a/denote.el
+++ b/denote.el
@@ -1762,11 +1762,16 @@ back to nil.")
   "Read file title for `denote'.
 With optional DEFAULT-TITLE use it as the default value.  With
 optional PROMPT-TEXT use it in the minibuffer instead of the
-generic prompt."
+generic prompt.
+
+Previous inputs at this prompt are available for minibuffer
+completion.  Consider `savehist-mode' to persist minibuffer
+histories between sessions."
   (let ((def (or default-title denote-title-prompt-current-default)))
-    (read-string
+    (completing-read
      (format-prompt (or prompt-text "File title") def)
-     nil 'denote--title-history def)))
+     denote--title-history
+     nil nil nil 'denote--title-history def)))
 
 (defvar denote--file-type-history nil
   "Minibuffer history of `denote-file-type-prompt'.")
@@ -1852,11 +1857,16 @@ packages such as `marginalia' and `embark')."
   "Prompt for signature string and apply `denote-sluggify-signature' to it.
 With optional DEFAULT-SIGNATURE use it as the default minibuffer
 value.  With optional PROMPT-TEXT use it in the minibuffer
-instead of the default prompt."
+instead of the default prompt.
+
+Previous inputs at this prompt are available for minibuffer
+completion.  Consider `savehist-mode' to persist minibuffer
+histories between sessions."
   (denote-sluggify-signature
-   (read-string
+   (completing-read
     (format-prompt (or prompt-text "Provide signature") nil)
-    nil 'denote--signature-history default-signature)))
+    denote--signature-history
+    nil nil nil 'denote--signature-history default-signature)))
 
 ;;;;; Convenience commands as `denote' variants
 

Reply via email to