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

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

RE: [External] : Re: completing-read depricated initial-input


From: Drew Adams
Subject: RE: [External] : Re: completing-read depricated initial-input
Date: Thu, 23 Jun 2022 16:30:01 +0000

> > (let ((list '("iffalse" "iftrue" "else" "fi")))
> >   (completing-read "Macro: "
> >                    (mapcar (lambda (x) (concat "\\" x)) list)
> >                    nil nil "\\"))
> 
> A convincing example, in my opinion.

Yes, it's a typical use case for non-nil INIT
arg: inserting a prefix.

And it's also essentially the case for non-nil
`insert-default-directory' for `read-file-name'.

(Try setting `insert-default-directory' to nil,
and see if you like it.  Now imagine if Emacs
hard-coded the behavior as nil and decided to
tell users that inserting `default-directory'
is deprecated...)

This case can arise if you use `try-completion'
to obtain such a common prefix, and then you use
`completing-read' to get the completion the user
wants.

Another example:
(completing-read "Color: " (defined-colors)
                 nil nil (buffer-substring-no-properties
                             (widget-field-start widget)
                             (point)))
___

Another typical use case is when the HIST arg is a
cons, so you can insert a particular history element
and position the cursor after it.

This case is what the doc string of `completing-read'
(misguidedly) says is the _only_ use case:

  (This is the only case in which you should use
  INITIAL-INPUT instead of DEF.)

(Our docs shouldn't use "should", BTW. ;-))

And it's not even necessarily a case of "instead
of DEF".  Using INIT here doesn't exclude also
using a DEF value.



reply via email to

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