From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Embedded list selection with ido-completing-read. Date: Sun, 24 Oct 2021 23:21:34 +0800 Message-ID: References: <87r1cbwnda.fsf@zoho.eu> <87a6iz1at1.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16482"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 24 17:23:56 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mefLn-00041U-Gf for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 17:23:55 +0200 Original-Received: from localhost ([::1]:46340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mefLm-0008Bu-2N for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 11:23:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mefJk-0006m7-BO for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 11:21:49 -0400 Original-Received: from mail-ua1-x933.google.com ([2607:f8b0:4864:20::933]:45901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mefJi-0007c7-Co for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 11:21:48 -0400 Original-Received: by mail-ua1-x933.google.com with SMTP id a17so17104690uax.12 for ; Sun, 24 Oct 2021 08:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=WBOrbIwFK4uuqr3FgnEQanJuCPRqGUyBGOfthXc6oXc=; b=eKR3vyn7CP9l7VmG8KnPGesVAKT6egfQqnRfUw4MHmrclXkQPIQpEBVNK7pgITrZMm hvM5o6svyTsoPiMRVPH5mQ1HxWOQGXZXwmN1W3DpRa5jdRaQV2V/FCGwKLPjwzBspeoj T/Thz6cFZEClPSfCHKBQdp7+o5CJu7BzVQWGGTboM6Z6q9xBLAZWYIUx4H0DjZA1V16P xJjsd0Mp0yZUh/s2JSKb+uY3x0duWJOQm1Emuw4zN6vUvMAkp0K9vC7P3Y6VH0oZzU6w zuMa8MQ/OgSO6RR44LqebcT+jfXi1ynvYWnQAdPI1NO5LWUDOW0rc8jspzHPFSCBh4vc dsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=WBOrbIwFK4uuqr3FgnEQanJuCPRqGUyBGOfthXc6oXc=; b=wL152cB0sqfxuL0JkMp+Lgl8pYG6mtznGvlDZpM23l476Sz9eTuXz3G11xsK3g6qsm fr8vl5CaL/tmWYM5nU8ILZ40E3EJg7KRKCISB4CwHH2IxgDILSb6bmwm4rr6r35gorh6 sX05PZtuKvXpFy9Kw6Dc1kYAELUnFOeS5vN+hzGnsItJDbychslzxw4FN4soSYF8vcRY VWAftqVAoTFbJ15O838JHZ4N3CoflL/QdbI78OfDZ4Xi12G2i2HmacD78UIOPofYyz0o 5MdkfyIC25Ce7GQTAU7LYKPvHU1FQmbZLjVvWPKB8bGxFksMzP9JsfoUTK47HjgQ13KZ iCSA== X-Gm-Message-State: AOAM530ut4jAkYLhBD8kpbbCVvFaCBFCJ62/z0YKd29wE9uHopNCWL1k VmGWvR//lSnFO5iczIwhbXq8CTgBEGyR7rQNVsi1oi5fSvjgTj96 X-Google-Smtp-Source: ABdhPJz0FMdhGpjs87Be73BaBHpv9Q8Ononar8vmPbI33jqTrQ9BjKmYNhqxEO4OBNhUpGBmmJSna+4lv3gNNeooH5Y= X-Received: by 2002:a67:a60c:: with SMTP id p12mr11030300vse.25.1635088905405; Sun, 24 Oct 2021 08:21:45 -0700 (PDT) In-Reply-To: <87a6iz1at1.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::933; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x933.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:134112 Archived-At: On Sun, Oct 24, 2021 at 9:17 AM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > 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) )) 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: (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)) > ;; test: > ;; (call-interactively #'atomic-position) > ;; (atomic-position "bohr") > > -- > underground experts united > https://dataswamp.org/~incal