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: Insert one of the flags automatically with tab completion. Date: Sun, 24 Oct 2021 22:53:44 +0800 Message-ID: References: <874k97y28i.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="1911"; 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 16:55:34 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 1meeuL-0000Iz-Bz for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 16:55:33 +0200 Original-Received: from localhost ([::1]:52880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meeuK-0000ae-5i for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 10:55:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meess-0000Yt-4J for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 10:54:02 -0400 Original-Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]:35565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meesp-0005jD-7Y for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 10:54:01 -0400 Original-Received: by mail-ua1-x92d.google.com with SMTP id q13so17125467uaq.2 for ; Sun, 24 Oct 2021 07:53:55 -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=+Db9Fz9E5+P1DtzTVO3XjbZA6mtkHLvsBkdyZvZCMDQ=; b=O07Sq0xocJVN/PuTGtD0hXKcSp7Zlu1tGeYkI0CJSusy0o1BGNkjAlkbfSpc+8nTBR /kLlTBgkY5TdheefmW2imNBN+56qMn8LIo39ARkLADLNo/k6zhQPRL1nb8GLnAIZeHTc pCIzixYgoZd7a9Q3aS8Tv3e7EpzYaG2PDRy5idXlcJbvC+HGbvafoZBLrjc6RCdPPsVd OWOkcMXWDUAt5Sd5uF7wTCqzOP0sdgBs1762TbUVSvT8k1Y/xHWjGZQfgxZv4ySmJlB0 Au96Tj55fMmtnZJQTjbJThZc9c8VtKj07AKbh4cbT6O7pPRiR/XOFeCnwjO5WMtspb+B sK/A== 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=+Db9Fz9E5+P1DtzTVO3XjbZA6mtkHLvsBkdyZvZCMDQ=; b=rviGeTEFvkRKqNiGGpjFBZWgv+6lmhXwoGryduhE9fBbvSqiWB1mBR7RG0KvvCm3It 65nGjr2BbKq0wvCAxD9IYIYA4YUBv9tKSmRvphwqiNUwLmnLAlnWB2XBaYlwLLVVgLQA 1q3Vz/ADk7ksgYOtl7JNxTatV4eGIHQ1uXIRDzD8wICQBEybV3Th5gMNxs/KZbgTgFve d6OHYrhkkIf5W7ack+MEGPK0W4VYDPAu5QGNKc6mQU1x0+Ui840A2BC7K/p+m2WkYOMs r3LGHk8k5MJkavuX4fZuYwJtv0I92WlnNe89rU4aJjj1xlx6BYpYgy43TWum/AK/l9mI mC3w== X-Gm-Message-State: AOAM530owH/xMBbSWd/qRliF716GFNhuU6iSfNN1VtFaETA7RzNAv6BM rS/EAER2CLjKUc7ETgd9lt6xU+uUNDHZHpMF7z9b0WajqCtIZ/SQ X-Google-Smtp-Source: ABdhPJy8JUMNA9rdvyS9Gvgaf6MyNsGleAgGXhHzXfpw41qXFfXWHSvuGtzQEWHbtFHqprL64yBxOgLPCQMU2343lu4= X-Received: by 2002:a67:edd7:: with SMTP id e23mr10764563vsp.14.1635087234831; Sun, 24 Oct 2021 07:53:54 -0700 (PDT) In-Reply-To: <874k97y28i.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::92d; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92d.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:134106 Archived-At: On Sun, Oct 24, 2021 at 3:23 AM Emanuel Berg via Users list for the GNU Emacs text editor 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) )) I can't find the real effect of `nil t` here, so I omitted it: (defun atomic-position (flag) (interactive (list (completing-read "flag: " '("alat" "angstrom" "bohr" "crystal" "crystal_sg")))) (insert (format "Atomic position: %s\n" flag))) > (insert (format "Atomic position: %s\n" flag)) ) > > Note that interactive and non-interactive use are not > identical in one aspect ... > > -- > underground experts united > https://dataswamp.org/~incal