[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Embedded list selection with ido-completing-read.
From: |
Hongyi Zhao |
Subject: |
Re: Embedded list selection with ido-completing-read. |
Date: |
Tue, 26 Oct 2021 16:44:26 +0800 |
On Tue, Oct 26, 2021 at 1:20 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > But the formal parameter isn't used in the `interactive'
> > part of your code:
>
> The order if there are many. If therer are parameters
> A B C then the interactive form should read (a b c) and
> parameter A will be assigned a and so on ...
>
> > (defun atomic-position (flag)
> > (interactive
> > (list
> > (completing-read "flag: " '("alat" "angstrom" "bohr" "crystal"
> > "crystal_sg") nil t)))
> > (insert (format "Atomic position: %s\n" flag)))
> >
> > This makes it difficult for me to adapt the above code to
> > a multi-parameter situation.
> >
> >> > (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))
>
> (list (completing-read ... )
> (completing-read ... )
> ;; as many you like/have said should be there )
>
> Remove everything that isn't doing the list. Then see if and
> in what state you get a list by evaluating the
> interactive form.
I tried for some time and got the following code snippet, but it
doesn't seem to be able to complete the work discussed here by the
original code snippet:
(defun atomic-position (prog flag1 flag2)
(interactive
(list
(completing-read "prog: " '("neb" "pw" "cp") nil t)
(completing-read "flag1: " '("alat" "angstrom" "bohr" "crystal"
"crystal_sg") nil t)
(completing-read "flag2: " '("alat" "angstrom" "bohr" "crystal") nil t)
)
)
(cond ((or (equal prog "neb")
(equal prog "pw"))
(insert (format "Atomic position: %s\n" flag1)))
((equal prog "cp")
(insert (format "Atomic position: %s\n" flag2)))
))
HZ
- Re: Embedded list selection with ido-completing-read., (continued)
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/24
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/25
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26
- Re: Embedded list selection with ido-completing-read.,
Hongyi Zhao <=
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Hongyi Zhao, 2021/10/26
- Re: Embedded list selection with ido-completing-read., Emanuel Berg, 2021/10/26