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 16:44:26 +0800 Message-ID: References: <87r1cbwnda.fsf@zoho.eu> <87a6iz1at1.fsf@zoho.eu> <87sfwqxuhi.fsf@zoho.eu> <878rygmkhn.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="15336"; 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 10:46:40 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 1mfI6R-0003mV-B0 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 10:46:39 +0200 Original-Received: from localhost ([::1]:49320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfI6Q-0001HS-3i for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 04:46:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfI4W-0001F1-NP for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 04:44:40 -0400 Original-Received: from mail-ua1-x934.google.com ([2607:f8b0:4864:20::934]:47089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfI4U-0001Rv-L1 for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 04:44:40 -0400 Original-Received: by mail-ua1-x934.google.com with SMTP id x3so8383158uar.13 for ; Tue, 26 Oct 2021 01:44:38 -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=+IVLG5vM3auFb1YYYr4hHuFamV+DKDm6ITfa4Qm/2Vk=; b=PJFsd9QcqVWendgzf8JyDSeaZEDxNVQ9zeLkzSBkQZiri6SfelkwlYTQ7XG4f+AmNE +tdSCDQitz3l/n4rz6QU0INsm/TMl96pNV1IlRB2M97692n9R+RlXmaxR/8JfirsBqhs QJW5N5dkf7MMj+4Pi+f9mglf9oe6Q9XME8hcAfs7xY8vMkXj5J5RY43yR8eTxkDhAX/K pb5XiO6f3fhCCL63XvIidYSP/sjRnrTpnSmmUNlvwGGLuQm7ZNf0r91hhQ+klv63PCkJ wmxWA5sa16DoA6zjbLQLOa74enwUSpJjmjXTAzBRF0EEreRd46rXzPi+5N/U2pz2wBAL h9UQ== 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=+IVLG5vM3auFb1YYYr4hHuFamV+DKDm6ITfa4Qm/2Vk=; b=s5Lxo/6OY1N7z4n+uIzFXxcnBXHC3j+1zRspK2TSPPWBQtirKbG5gVWG0TMtJPMs4i 9hesC/hVb+n071DKL4Kd5sRsSh8wj01HAoTK2EBioMe1RtB4efo8Q33gKXmaWX5uMt5s sURsra2A16GoU+EYMQJUBuxl5Go8h0Uc6M86QPHwvaunt4trfOt4QdX9Qw58vN4V5UUA 4vzTIHzUYzTVFoPlGK0jI48gagn2K+IEqGfOssK61gdQqHODlK9BiRtZauIGqW5bnERs pNJcs8jFfp7ms1iSE9olsHRRGIsUwVeyejlITSdcknBDDVP6JHjf+0O4oKVO8xtAAOV6 mXUQ== X-Gm-Message-State: AOAM530xXkdzqnkT9hgMF3ZovHda0ZCjXDU2IaXltWulhZjab0T3oIZ0 5ryOhD8oKtBcC7PNSMLnhSAbyimkAnad8KoYuyDWFaug0aUB6bw4 X-Google-Smtp-Source: ABdhPJwMENsmAbF5xfAcl2tad5fLUhNtJGYuqud5PU0N/1WRK22PweOl72CpTT8KN92ZOWdZpcwruRA7nOgDNxhgkd8= X-Received: by 2002:a05:6102:3a4c:: with SMTP id c12mr6710198vsu.10.1635237877385; Tue, 26 Oct 2021 01:44:37 -0700 (PDT) In-Reply-To: <878rygmkhn.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::934; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x934.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:134196 Archived-At: On Tue, Oct 26, 2021 at 1:20 PM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Hongyi Zhao wrote: > > > But the formal parameter isn't used in the `interactive' > > part of your code: > > The order if there are many. If therer are parameters > A B C then the interactive form should read (a b c) and > parameter A will be assigned a and so on ... > > > (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)) > > (list (completing-read ... ) > (completing-read ... ) > ;; as many you like/have said should be there ) > > Remove everything that isn't doing the list. Then see if and > in what state you get a list by evaluating the > interactive form. I tried for some time and got the following code snippet, but it doesn't seem to be able to complete the work discussed here by the original code snippet: (defun atomic-position (prog flag1 flag2) (interactive (list (completing-read "prog: " '("neb" "pw" "cp") nil t) (completing-read "flag1: " '("alat" "angstrom" "bohr" "crystal" "crystal_sg") nil t) (completing-read "flag2: " '("alat" "angstrom" "bohr" "crystal") nil t) ) ) (cond ((or (equal prog "neb") (equal prog "pw")) (insert (format "Atomic position: %s\n" flag1))) ((equal prog "cp") (insert (format "Atomic position: %s\n" flag2))) )) HZ