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: Tue, 26 Oct 2021 10:38:27 +0800 Message-ID: References: <874k97y28i.fsf@zoho.eu> <871r4azcgt.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="26536"; 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:39:24 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 1mfCN1-0006kW-MT for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 04:39:23 +0200 Original-Received: from localhost ([::1]:46974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfCN0-0008By-HO for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Oct 2021 22:39:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfCMN-0008Bj-3Y for help-gnu-emacs@gnu.org; Mon, 25 Oct 2021 22:38:43 -0400 Original-Received: from mail-ua1-x931.google.com ([2607:f8b0:4864:20::931]:34521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfCMK-0000zv-9I for help-gnu-emacs@gnu.org; Mon, 25 Oct 2021 22:38:42 -0400 Original-Received: by mail-ua1-x931.google.com with SMTP id h4so26267619uaw.1 for ; Mon, 25 Oct 2021 19:38:39 -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=gqV3CVnCD6V5nGouOfvRWTRBhcMTTm1ZCnNe7BQeX0U=; b=Ds2kOiKJlOl1KfAevzuiHchBU/uIwgA5nFkbm4vmfOUB5g5hV60CoFJJYkuTPg3YXS dO5jjfh3sU8l68srl/3f+NGNvGmBarQPlfMyk8g7wSztyozFW9gvxOxv1Ny5WDC4j4lG BJBVWxJ9QK6AvoHQssOSYASKjDZfobb69u69PTRd8fudWzgC9C/+jyBmc4JQ3Q2YCdqW T5Gp00n8s66vVJ6u/DcjbRDtx+3qzf5FSB0/KPNiQhy8ad5GI2Im0KJuSAwP93D+nt8/ bjVZyTMFwDrRFX3wl5WRGwvPmeyFoEA7ifIB+cdsIIn+v5N49Q3ErCFlB+Hus0yY6I4W TSuA== 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=gqV3CVnCD6V5nGouOfvRWTRBhcMTTm1ZCnNe7BQeX0U=; b=SxFGA4KzJ79LqABOOFz1PHQoLlTMzhby5/c6AsUCcPyx9GimvFucUUCW0TZ025nkqz 4bWZUXxgO6DdJ78ULwMoJBLEJX5KBHt1uWxudKWwA4IgZyxje/TDaW4QaTmIlv5eMBvm B9IKaBfRS/+DciTcPw6ogsJ2elguoovQoBgNKqhWm8QighE8zXGwEdDcLCS3lxiFN08v p8aRnguw9lQ2XuWGqdxhRtVxSVadeywWN2DA5Zwcf2lvIKB0yhFD1kWE59trhv1XySd1 R54IFzGP7vahmwWssvPjzUqRpoy7yEMhXQAELs2WlCg3jBui3QlUQ52n/JUYcN4WZ9GA RIcQ== X-Gm-Message-State: AOAM533PMtryBSB+E8tW1VhvliDlqW5bKYXW6J4QYYjb0dH5G1gfQQtA m10Z69fexmZXe7HZwmQg9v1PVMSkcRqr8OGDyZu+NdCZ7TZd30bA X-Google-Smtp-Source: ABdhPJy1Oml+Vt3vaYXyUHCQMFGMrY7hZ/3vMIsMcuwFEymPH0WkBtEKv8yjVWsCpIk0+w8UyEUpE8s3/+KzRhIhJsU= X-Received: by 2002:a9f:2aca:: with SMTP id d10mr20076035uaj.26.1635215919170; Mon, 25 Oct 2021 19:38:39 -0700 (PDT) In-Reply-To: <871r4azcgt.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x931.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:134171 Archived-At: On Sun, Oct 24, 2021 at 11:09 PM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Hongyi Zhao wrote: > > >> 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. > > Yes, interactive is a command, M-x CMD RET, or a keybinding. > > Non-interactive is from Lisp ... > > (`call-interactively' is the exception that proves the rule, > and it should only be used when ... there is a reason to :)) > > But that's not what I refered to actually, if you study the > code you see the "nil t" that you asked about in the > other thread - > > (defun atomic-position (flag) > (interactive > (list > (completing-read > "flag: " '("alat" "angstrom" "bohr" "crystal" "crystal_sg") nil t) )) > (insert (format "Atomic position: %s\n" flag)) ) > > - and if you take a look at the docstring of `completion-read' > you see that these arguments are for the > > &optional PREDICATE REQUIRE-MATCH > > so the first nil says PREDICATE should be nil, it is already > nil by default What exactly does nil mean here? The document says the following: PREDICATE limits completion to a subset of COLLECTION. > but we want to say that REQUIRE-MATCH should be > t, so we say that PREDICATE is nil just to get to > REQUIRE-MATCH if you follow, then we say it is t. > > And this is the difference from non-interactive use, because > there is no such thing in the non-interactive part of the > function. You can send any "flag" argument from Lisp and it > will be processed. > > (atomic-position "darn") (atomic-position "darn") ;; Atomic position: darn > But M-x atomic-position RET darn RET ... try it. 0 flag (match required): darn > Read (or look at) the docstrings, especially the > interface/prototype part, to all functions you use ... The lisp documentation is very obscure, and I often cannot grasp them the first time I read it. HZ