[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 10:52:58 +0800 |
On Mon, Oct 25, 2021 at 12:23 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> 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.
But the formal parameter isn't used in the `interactive' part of your code:
(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))
>
> ...
>
> --
> underground experts united
> https://dataswamp.org/~incal
- 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., 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 <=
- 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., 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