[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: |
Sun, 24 Oct 2021 22:50:18 +0800 |
On Sun, Oct 24, 2021 at 3:23 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > (defun my-pw-ATOMIC_POSITIONS2 ()
> > (interactive
> > (list
> > (insert "ATOMIC_POSITIONS "
> > (completing-read
> > "Select the flag: "
> > '(("alat" 1)
> > ("bohr" 2)
> > ("angstrom" 3)
> > ("crystal" 4)
> > ("crystal_sg" 5)
> > )
> > nil t ""))))
> > (newline 1))
>
> (defun atomic-position (flag)
> (interactive
> (list
> (completing-read
> "flag: " '("alat" "angstrom" "bohr" "crystal" "crystal_sg") nil t) ))
> (insert (format "Atomic position: %s\n" flag)) )
Thank you for your idiomatic coding style correction and logic enhancement.
> 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.