[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsi
From: |
Drew Adams |
Subject: |
bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) |
Date: |
Tue, 25 Aug 2020 08:34:58 -0700 (PDT) |
This is what I do in Icicles.
` icicle-handle-default-for-prompt' is called from
`(icicle-)completing-read' and `(icicle-)read-string'.
;; In `(icicle-)completing-read':
(setq prompt
(icicle-handle-default-for-prompt
prompt
;; If `insert-default-directory' then make DEF
;; in prompt relative to `default-directory'.
(if (and def1 (eq icicle-default-value t)
insert-default-directory)
(file-relative-name def1)
def1)
(and (eq icicle-default-value t)
;; Include in prompt only if
;; `insert-default-directory' does not
;; insert it as input.
(or (not insert-default-directory)
(not (icicle-file-name-input-p))
(not (equal def1 default-directory))))))
;; In `(icicle-)read-string':
(when default-value
(setq prompt (icicle-handle-default-for-prompt
prompt
default-value
(eq icicle-default-value t))))
(defun icicle-handle-default-for-prompt (prompt default include)
"Return PROMPT, possibly changed to format or remove the DEFAULT value.
Argument INCLUDE:
* nil means do not include DEFAULT in prompt. Remove it if there.
* non-nil means include DEFAULT, formatted according to
`icicle-default-in-prompt-format-function'.
In the existing PROMPT before modification, recognizes inclusion of
a default value according to these possible patterns:
`minibuffer-default-in-prompt-regexps'
\"(default ___):\"
\"(default is ___):\"
\" [___] \""
(when (consp default) (setq default (car default)))
(dolist ; Remove the default, if already there.
(rgx (if (boundp 'minibuffer-default-in-prompt-regexps)
minibuffer-default-in-prompt-regexps
'(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'" 1)
("\\( \\[.*\\]\\):? *\\'" 1))))
(setq prompt (replace-regexp-in-string
(car rgx) "" prompt nil nil (cadr rgx))))
(if (and default include) ; Add non-nil DEFAULT, if INCLUDE.
(replace-regexp-in-string
".*\\(\\): *\\'"
(funcall icicle-default-in-prompt-format-function default)
prompt nil t 1)
prompt))
(defcustom icicle-default-in-prompt-format-function
(lambda (default) (format " (%s)" default))
"Function that formats the default value to include in the prompt.
The function must accept the default value (a string) as its (first)
argument and return a string, which is prepended to the first
occurrence of `: ' in the prompt. This option has no effect unless
`icicle-default-value' is t."
:group 'Icicles-Miscellaneous :type 'function)
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Stefan Kangas, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Stefan Monnier, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy),
Drew Adams <=
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Stefan Kangas, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Juri Linkov, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Stefan Monnier, 2020/08/25
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/26
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Juri Linkov, 2020/08/27
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/28
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Stefan Monnier, 2020/08/28
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/30
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/08/28