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: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap. Date: Sat, 23 Oct 2021 19:58:46 +0800 Message-ID: References: <87y26lporl.fsf@zoho.eu> <874k98m9wj.fsf@web.de> <87ilxoyu5m.fsf@web.de> 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="22891"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 23 13:59:30 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 1meFgP-0005jq-JO for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 13:59:29 +0200 Original-Received: from localhost ([::1]:49246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meFgN-0006VK-RH for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 07:59:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meFfx-0006V8-GX for help-gnu-emacs@gnu.org; Sat, 23 Oct 2021 07:59:01 -0400 Original-Received: from mail-vk1-xa30.google.com ([2607:f8b0:4864:20::a30]:42742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meFfv-0003ft-IB for help-gnu-emacs@gnu.org; Sat, 23 Oct 2021 07:59:01 -0400 Original-Received: by mail-vk1-xa30.google.com with SMTP id o42so2762827vkf.9 for ; Sat, 23 Oct 2021 04:58:58 -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 :cc; bh=YZ5cari52vGrJWe4VQf6HglcyGSiQn35qFRydvBMR/g=; b=VQNOWe2caPzadaNlfpiqOzH/4TJ1Lhr7o9F2jCzoXYboN13ynbONDiOo7Qt3IuOaLQ L6Lrn/InVUR3oRb1Eq5hs0DPFYk5Q71Ku+iu7hZ0VmzFBX5U8qW86NswG2Rin8VRB8XE q/3SGVIIPfkXp8N2pdErTDx3vvmj+26pVT9+EjB8doh4Atl41xPJ8aBCpZOSsR/4LgeW b7JQag5dvSeg/EMZpoIdhfaCauig7eDLjuWziD+H52FFl8BCR+A3Uzvciz8+myDrCehf g+T+TmgDqBjLzdxDTQ2k3SAyqoqVf9eMp0T9K0SydfrKlakOGiE5T4SuUwtzZ4AobL77 S07Q== 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:cc; bh=YZ5cari52vGrJWe4VQf6HglcyGSiQn35qFRydvBMR/g=; b=44e0Rz3v4hC7xgW1E7HvG9YBs3/UfSQmLWl9IrjQWZuuKWu1/9qscvuUJeAbi6tXCH 7mG4H/CC4OZVLoxsKwsFBZIj1m/rl7RUgjaeSBZrHODcSXdiOyRjQyvr3SawMbQSphK3 uVBM7UgKiW3zDPFvidCkxaxSL+3l0ZdCPvRmPnWd7f9hBFfDkCmNLLW4hDLGGaUjmCG/ UU33hKi+dI76SxS/F6adWxpzSRrOMs6O21X18mxfsjdR26G7KN5UvA1P1/Cdy4t147VY 0SyLivMERjPnPgfsS+HmrhXaoYVCP81M2GdjMaOxdzVoAVSPqrWeCLLow15WNSKkxUSR lGwA== X-Gm-Message-State: AOAM532pHQhMfw9rqic+Fu+7UCiq1L1+3RZ7ijBqSbNKqIvEcAyrNJRK tGpM/cshi8ZkndA7h7efWS3P/AbOVCie9TdGUJeYj+7+sVc767m6 X-Google-Smtp-Source: ABdhPJyKI1MBlzSr2m2ThqP7VYgxz5Sps8gN3EdhG1BkdYbwA8ijBQutd4gZTs7Fm0/r0TmwVd4Km+g5fSepaj4d/p4= X-Received: by 2002:a05:6122:1812:: with SMTP id ay18mr5563656vkb.14.1634990337951; Sat, 23 Oct 2021 04:58:57 -0700 (PDT) In-Reply-To: <87ilxoyu5m.fsf@web.de> Received-SPF: pass client-ip=2607:f8b0:4864:20::a30; envelope-from=hongyi.zhao@gmail.com; helo=mail-vk1-xa30.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:134047 Archived-At: On Sat, Oct 23, 2021 at 5:20 PM Michael Heerdegen wrote: > > Hongyi Zhao writes: > > > > Hongyi Zhao writes: > > > > > > > ("" . (lambda () > > > > (interactive) > > > > (if (company--active-p) #'company-search-abort > > > > #'company-search-candidates))) > > > > > > Your lambda only returns a command name, but it doesn't call any > > > command. It will just do "nothing". > > > > I'm in a confusion for this problem. The fix? > > If it's not obvious to you why this does nothing, you need to learn more > basics. Let's name the command: > > (defun my-command () > (interactive) > (if (company--active-p) #'company-search-abort > #'company-search-candidates)) > > When you eval that definition and do M-x my-command, what would you > expect to happen? I changed to the following form, but it still does nothing: (defun my-command () (interactive) (if (company--active-p) (company-search-abort) (company-search-candidates))) HZ