[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Insert one of the flags automatically with tab completion.
From: |
Emanuel Berg |
Subject: |
Re: Insert one of the flags automatically with tab completion. |
Date: |
Sun, 24 Oct 2021 17:09:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
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
&optional PREDICATE REQUIRE-MATCH
so the first nil says PREDICATE should be nil, it is already
nil by default 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")
But M-x atomic-position RET darn RET ... try it.
Read (or look at) the docstrings, especially the
interface/prototype part, to all functions you use ...
--
underground experts united
https://dataswamp.org/~incal