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:50:18 +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="22512"; 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:51: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 1meeqT-0005ey-Qd for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 16:51:33 +0200 Original-Received: from localhost ([::1]:51504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meeqS-0007wu-7s for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 10:51:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meepU-0007uf-U4 for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 10:50:32 -0400 Original-Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]:37470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meepS-0003Wx-8j for help-gnu-emacs@gnu.org; Sun, 24 Oct 2021 10:50:32 -0400 Original-Received: by mail-vk1-xa2a.google.com with SMTP id j12so3924465vka.4 for ; Sun, 24 Oct 2021 07:50:29 -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=oz9cIYIJPJhKzj1H+usBeTbs9/TToAuO0sxDgnIX8qU=; b=KX6YF7fAxdxF0u5Am4z7ZIWFJ1pGSqVlKJe4gP6kVP/FSVISHwKwg/TLYvak5BBsE/ dmWGCdVBmOIuBJVtbM/zBIxHpE0PVbOXmcGnXjQqfpGmukHt6Wgzo5KusW0IuZ+UKD7X ffsgFpY935c92WEz2XuP1uXpRmqRwTzqAf/5iT+oZdCQ7QupTDQ0JD3fIJCbs2TSjIUK dnCRMLwgV8OUPiKdFg7DjFfiyp0XEBet6jRVEbcarYkeIeL5gCqQliVL0FoEkA1VdR9m KTjndKuCMvPh+A77CCe7xKg75jaxiF+2JDAu2IF6atwO14Ru5ecbwDmN3TqfbkPFADtz x/IQ== 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=oz9cIYIJPJhKzj1H+usBeTbs9/TToAuO0sxDgnIX8qU=; b=3ryysEA6XVH4Q7sGIxo7Ux6LqT0WyMlwVERNkliioAU0iw7SVrWr0kPxzLllWLiMVe 2bbi2Qy3le3/neN/W4G8Rh3lZ2Hw0FixljtEp6yQkeEoc7q35P6kqf4/q0wDO6cPkqXE mn1bfVz3CgUmc2kVj5ii7fnaGTEpOH7ba5YWPbKmtgvTpjrtSq7e30FVvHO//GpXHfwa cb4m+/2zDu4oIACwt6PqbNxoX5g5GFssbXclBt0AZByIt1ySvW2CI0sZYgeuIG+0KVBb I3gl8QAZGjK5Agwz67V1FMr7jM327QtCEY1nE28nResKm/IBdE7G4HNlw5JjiOz0coE6 Ff/g== X-Gm-Message-State: AOAM530h/7xCn4sXgyLZ+Hmg7QZqX5mkOydIWhr7wQxvX40ZhF1FR7i4 uGBKGe506IZfeCM+CgmVBw3fbvxWkcftHcfbTz0= X-Google-Smtp-Source: ABdhPJypUa6BwFTge2PzSSbbPCeZ4uqcAcfHuC1CXzrgHbUFHxGyKelNVuOlNRr5v+2OAEpkz87ucqsDjyTVZSorEJI= X-Received: by 2002:a05:6122:a10:: with SMTP id 16mr10894021vkn.1.1635087029253; Sun, 24 Oct 2021 07:50:29 -0700 (PDT) In-Reply-To: <874k97y28i.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=hongyi.zhao@gmail.com; helo=mail-vk1-xa2a.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:134104 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) )) > (insert (format "Atomic position: %s\n" flag)) ) Thank you for your idiomatic coding style correction and logic enhancement. > Note that interactive and non-interactive use are not > identical in one aspect ... Interactive is interacting with user as a command. Non-interactive is called from within lisp code.