[Top][All Lists]

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

Re: Insert one of the flags automatically with tab completion.

From: Hongyi Zhao
Subject: Re: Insert one of the flags automatically with tab completion.
Date: Tue, 26 Oct 2021 10:38:27 +0800

On Sun, Oct 24, 2021 at 11:09 PM Emanuel Berg via Users list for the
GNU Emacs text editor <> wrote:
> Hongyi Zhao wrote:
> >> Note that interactive and non-interactive use are not
> >> identical in one aspect ...
> >
> > Interactive is interacting with user as a command.
> > Non-interactive is called from within lisp code.
> Yes, interactive is a command, M-x CMD RET, or a keybinding.
> Non-interactive is from Lisp ...
> (`call-interactively' is the exception that proves the rule,
> and it should only be used when ... there is a reason to :))
> But that's not what I refered to actually, if you study the
> code you see the "nil t" that you asked about in the
> other thread -
> (defun atomic-position (flag)
>   (interactive
>    (list
>     (completing-read
>      "flag: " '("alat" "angstrom" "bohr" "crystal" "crystal_sg") nil t) ))
>   (insert (format "Atomic position: %s\n" flag)) )
> - and if you take a look at the docstring of `completion-read'
> you see that these arguments are for the
> so the first nil says PREDICATE should be nil, it is already
> nil by default

What exactly does nil mean here?

The document says the following:

PREDICATE limits completion to a subset of COLLECTION.

> but we want to say that REQUIRE-MATCH should be
> t, so we say that PREDICATE is nil just to get to
> REQUIRE-MATCH if you follow, then we say it is t.
> And this is the difference from non-interactive use, because
> there is no such thing in the non-interactive part of the
> function. You can send any "flag" argument from Lisp and it
> will be processed.
> (atomic-position "darn")

(atomic-position "darn") ;; Atomic position: darn

> But M-x atomic-position RET darn RET ... try it.

0 flag (match required): darn

> Read (or look at) the docstrings, especially the
> interface/prototype part, to all functions you use ...

The lisp documentation is very obscure, and I often cannot grasp them
the first time I read it.


reply via email to

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