[Top][All Lists]

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

Re: completing-read depricated initial-input

From: Arash Esbati
Subject: Re: completing-read depricated initial-input
Date: Thu, 23 Jun 2022 22:46:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Robert Pluim <> writes:

>>>>>> On Thu, 23 Jun 2022 16:46:53 +0200, Arash Esbati <> said:
>     Arash> I'd say it's up to the AUCTeX maintainers to bump the minimum 
> required
>     Arash> Emacs version at a faster pace ;-)
> Either that, or they can depend on the 'compat' package, and then just
> use emacs-28 features with wild abandon.

Thanks for reminding me of compat.  I think compat-28.el has currently a
bug since the return value of `format-prompt' is not the same as in

(format-prompt "Foo" "")
=> "Foo: "

This is what compat-28.el does:

(defun compat-format-prompt (prompt default &rest format-args)
  "Format PROMPT with DEFAULT.
If FORMAT-ARGS is nil, PROMPT is used as a plain string.  If
FORMAT-ARGS is non-nil, PROMPT is used as a format control
string, and FORMAT-ARGS are the arguments to be substituted into
it.  See `format' for details.

If DEFAULT is a list, the first element is used as the default.
If not, the element is used as is.

If DEFAULT is nil or an empty string, no \"default value\" string
is included in the return value."
   (if (null format-args)
     (apply #'format prompt format-args))
   (and default
        (or (not (stringp default))
            (not (null default)))
        ;;  (length> default 0) ; This is in Emacs stock version
        (format " (default %s)"
                (if (consp default)
                    (car default)
   ": "))

(compat-format-prompt "Foo" "")
=> "Foo (default ): "

compat doesn't check if DEFAULT is an empty string.  I'm CC'ing Philip,
maybe he can comment.

Best, Arash

reply via email to

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