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

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

Re: Embedded list selection with ido-completing-read.


From: Emanuel Berg
Subject: Re: Embedded list selection with ido-completing-read.
Date: Sun, 24 Oct 2021 18:23:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao wrote:

>> 1) Use a formal parameter.
>>
>> 2) Don't do anything in the `interactive' form except
>>    get/assign the argument(s).
>>
>> 3) Test interactively and non-interactively (i.e., from Lisp).
>>
>> (defun atomic-position (flag)
>>   (interactive
>>    (list (completing-read
>>           "flag: "
>>           '("alat" "angstrom" "bohr" "crystal" "crystal_sg") )))
>>   (insert (format "Atomic Kitten: %s" flag) ))
>
> I've tried to rewrite the following more complex function
> written by me by your above rules/guidelines, but still
> failed to do the trick

... ? Is this for real?

Do 1-2, then 3.

> (defun ATOMIC_POSITIONS ()
>   (interactive
>    (let* ((prog '("neb" "pw" "cp"))
>       (prog-read (completing-read "prog: " prog))
>       )
>
>      (cond ((or (equal prog-read "neb")
>         (equal prog-read "pw"))
>         (insert "ATOMIC_POSITIONS "
>             (completing-read "flag: "
>                      '("alat" "bohr" "angstrom" "crystal" "crystal_sg"))))
>        ((equal prog-read "cp")
>         (insert "ATOMIC_POSITIONS "
>             (completing-read "flag: "
>                      '("alat" "bohr" "angstrom" "crystal")))))
>      ))
>   (newline 1))

...

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




reply via email to

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