GNU bug report logs - #12443
24.2.50; Default values in the minibuffer prompt (fix

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Fri, 14 Sep 2012 14:08:01 UTC

Severity: minor

Found in version 24.2.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #49 received at 12443 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefankangas <at> gmail.com>
Cc: 12443 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Dani Moncayo <dmoncayo <at> gmail.com>
Subject: RE: 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)




This bug report was last modified 4 years and 124 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.