help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: completing-read depricated initial-input


From: Emanuel Berg
Subject: Re: completing-read depricated initial-input
Date: Fri, 24 Jun 2022 04:17:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Tassilo Horn wrote:

>> (let ((name "Danger"))
>>   (read-string (format-prompt "Name" name) nil nil name))
>
> Nice!

Actually no, try to replace existing code with that ... It's
the two occurrences of name (above) that makes it clumsy
and ugly.

Also this is not needed functionally, it's logical that it
isn't but as an example see for example `read-number' which
already does this for you. Eval this:

  (read-number "pills/day: "  4)

S0 why not `read-string' as well?

However - one can do one's own function for that ...

(defun read-string-1 (ps &optional def hist)
  (setq ps (format-prompt ps def))
  (read-string ps nil hist def))
  
(read-string-1 "name" "Danger")

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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