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 03:16:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao wrote:

> I still can't figure out how to use your suggestions above
> to further simplify my implementation below:
>
> (defun my-pw-ATOMIC_POSITIONS2 ()
>   (interactive
>    (list
>     (insert "ATOMIC_POSITIONS "
>             (completing-read
>              "flag: "
>              '(("alat")
>                ("bohr")
>                ("angstrom")
>                ("crystal")
>                ("crystal_sg")
>                )
>              )))))

Same as I said before ...

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) ))

;; test:
;;   (call-interactively #'atomic-position)
;;   (atomic-position "bohr")

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




reply via email to

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