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.d8c0@mx.google.com%3E>.
This commit is contained in:
Protesilaos Stavrou 2023-10-25 09:41:35 +03:00
parent 85d34f0fba
commit 0d855bbf12
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
2 changed files with 27 additions and 11 deletions

View file

@ -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

View file

@ -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