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: Tue, 26 Oct 2021 10:52:58 +0800 Message-ID: References: <87r1cbwnda.fsf@zoho.eu> <87a6iz1at1.fsf@zoho.eu> <87sfwqxuhi.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="10993"; 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 Tue Oct 26 04:53:46 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 1mfCav-0002gt-Sm for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 04:53:45 +0200 Original-Received: from localhost ([::1]:48478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfCau-0001Ss-AZ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Oct 2021 22:53:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfCaP-0001Sk-1F for help-gnu-emacs@gnu.org; Mon, 25 Oct 2021 22:53:13 -0400 Original-Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:43977) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfCaN-0001ES-7B for help-gnu-emacs@gnu.org; Mon, 25 Oct 2021 22:53:12 -0400 Original-Received: by mail-ua1-x935.google.com with SMTP id k28so22018572uaa.10 for ; Mon, 25 Oct 2021 19:53:10 -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=v768KTv5J69bVCn3mbhlLtPEP4fdGZsWkWMtaiDhNqs=; b=G6MxAlKcrwGUEbQUef4oZbRgmjWyOQ97MVfIK+Z3wGa6gfQuGPKQHFM+LgMp+ncP3D DPHObZob/g7QUwwq16eBesRdi6UId1OmEnNqSvTmJuZ0/IAs0nLr+P01PPAi9dovWgw/ A6Q1ph9l7bwdbbpKuNiqZhoTY+AQUb7hu2odESGIZyC9Ow30PZWoPZM4G6xskvDrw6gb MPsbmR2zBI7K9LhvaG3hUH89YqT/eLbseLA//uGkAmvcL7YinUpx/sV1c7z9mze1Z1wp sq/PDFLb85GLrvkjufDX4h7q5vEU8Y359JR0g35oSgT37xcu/N3DpBxlSfH7B1QMJgUS FICQ== 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=v768KTv5J69bVCn3mbhlLtPEP4fdGZsWkWMtaiDhNqs=; b=36SiA3EMr8Wz1EoAcadWZZiRK9RureOqovsKaKRQ9Min5u8JFRO31HLVmJnIN6gVLt n0YRsCxiFPh5dtOkrLlU33wWfxckIyhMrkD4X++Ti9p8xaEuoe0mCnjv+iO7+/laZOdT VTK/LZJSuDXLP8R30LcSjSwSfuP5Qmf5/TiS0WPU8pj8wtogk/rlwgEQrFLYAmP/VyYr +pExaeLOfO980k+q2YMqeq0oh1pltBkWRiKvi6L89IvHDtpTLz01Tqchm8Ax3+y9+60j qijJ/NQx5MmV5G9kLAArJYVThoDrSO8eG851aTSgGxbga3WKMxvAhuq6KPJKswPClMnn Y98A== X-Gm-Message-State: AOAM530UddODLCGn/GjcGSkc0Nu/juY+iiKNHoa4+QZelq+xM4TIkM0b i4BtDrCcopXAeJerEAfIw8CNbv/SV7Fg4x2ueiU= X-Google-Smtp-Source: ABdhPJzqhNL47xAmSCwABpzbrqx07sIk77WmL0dlUwYo8e12nLc3O4mTicJ3ele+hBpm/M/w/xK+N/YMNdTJBA31GYc= X-Received: by 2002:a67:edd7:: with SMTP id e23mr19842864vsp.14.1635216789997; Mon, 25 Oct 2021 19:53:09 -0700 (PDT) In-Reply-To: <87sfwqxuhi.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::935; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x935.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:134172 Archived-At: On Mon, Oct 25, 2021 at 12:23 AM Emanuel Berg via Users list for the GNU Emacs text editor 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