[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: completing-read depricated initial-input
From: |
Philip Kaludercic |
Subject: |
Re: completing-read depricated initial-input |
Date: |
Fri, 24 Jun 2022 08:40:08 +0000 |
Arash Esbati <arash@gnu.org> writes:
> Robert Pluim <rpluim@gmail.com> writes:
>
>>>>>>> On Thu, 23 Jun 2022 16:46:53 +0200, Arash Esbati <arash@gnu.org> 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
> Emacs>=28:
>
> (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."
> (concat
> (if (null format-args)
> prompt
> (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)
> 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.
You are right, this is a bug. When "reimplementing" format-prompt with
backwards compatibility in mind, I replaced the (length> default 0) with
(not (null default)). This would work on lists, but not on arrays. I
have replaced it and updated the tests.
> Best, Arash
- Re: completing-read depricated initial-input, (continued)
- Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/23
- Re: completing-read depricated initial-input, Arash Esbati, 2022/06/23
- Re: completing-read depricated initial-input, Lars Ingebrigtsen, 2022/06/23
- Re: completing-read depricated initial-input, Tassilo Horn, 2022/06/23
- Re: completing-read depricated initial-input, Arash Esbati, 2022/06/23
- Re: completing-read depricated initial-input, Robert Pluim, 2022/06/23
- Re: completing-read depricated initial-input, Arash Esbati, 2022/06/23
- Re: completing-read depricated initial-input,
Philip Kaludercic <=
- Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/23
- Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/23
- Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/23
- Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/23
- RE: [External] : Re: completing-read depricated initial-input, Drew Adams, 2022/06/23
- Re: [External] : Re: completing-read depricated initial-input, Tassilo Horn, 2022/06/23
- Re: [External] : Re: completing-read depricated initial-input, carlmarcos, 2022/06/24
- Re: [External] : Re: completing-read depricated initial-input, Jean Louis, 2022/06/24
- Re: [External] : Re: completing-read depricated initial-input, Emanuel Berg, 2022/06/25
- RE: [External] : Re: completing-read depricated initial-input, Drew Adams, 2022/06/25