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: Bind two commands to one key to toggle between them for the same local keymap. Date: Fri, 22 Oct 2021 18:02:21 +0800 Message-ID: References: <87y26lporl.fsf@zoho.eu> <87pmrxpky4.fsf@zoho.eu> <87lf2lpig4.fsf@zoho.eu> <87h7d9pg14.fsf@zoho.eu> <871r4dpesl.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="39862"; 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 Fri Oct 22 12:04:48 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 1mdrPs-000A9q-Gu for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 22 Oct 2021 12:04:48 +0200 Original-Received: from localhost ([::1]:49272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdrPr-0005EJ-3r for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 22 Oct 2021 06:04:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdrNj-00036V-Pt for help-gnu-emacs@gnu.org; Fri, 22 Oct 2021 06:02:35 -0400 Original-Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:36459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdrNh-0001ot-Jz for help-gnu-emacs@gnu.org; Fri, 22 Oct 2021 06:02:35 -0400 Original-Received: by mail-ua1-x92a.google.com with SMTP id e10so6611767uab.3 for ; Fri, 22 Oct 2021 03:02:33 -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=3T/xhcApQtJY685BYj8WZx8RK50lDCBhGtCAWE+BONQ=; b=dsoOYSzNwdZb0jLdLCA/EmHFoOkBLcoTzqxzBJUh+f5tYGnYlCxFEyyEvNlyEwvnnf aFufB7TzzjJU0wl0go/EUfeocmFPPzhq1MErq4wfXNV4e+o529co4M/R7No3he+2YTYr /Ej8lGwpQQX4ayrG4/8w1+8ZxaDFcEvWTMY6qFnMHMM35KqBpKx3khrmVTPq0Fedpczd Uv9WjgiXyEpXXg8eMpiKDKAkXEdyk7mr7QQ6SDNeBAWCQmYxpBo60UnFcjo6TQvHccz+ i6c0nkVKuKaQG5xAKXWrfIwx516mka3JaazqaRBzEBDEi0lh65mtF5eILUYyoWwjkJtF FHwA== 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=3T/xhcApQtJY685BYj8WZx8RK50lDCBhGtCAWE+BONQ=; b=sQabCHUpA8VvWLiuqhqVcSBSLLQIR98Y7uUmmZOFK2NINuAnMAxyXy8nMCGAblxTC+ /r0lk3Pv1XdZNeu3yLRYspGmjYepBOCFvaQzT7xN+sVsOyq/qoEvkdvNCmPaJrinNGtG 2BIrZWXdUHA2Jh7u6q69EAYHaKxTVkW3c4B7iJnjo4HIIrfLNwFnkaaYBB9C6Ks99cQ0 eos29UJsxzPkZGYRPb3qUC2BVsrYYvlkTELOiiATvJb0HHeysU3Agy+nSu8lWt1Ct4oO jMcNWgw231MOatoY6iEGoF8Piu9rcGYCjVWb0ZFU9E/0Jk27j+FWRTxSQhen138r2SNF hKHA== X-Gm-Message-State: AOAM531a4eHzi9JxFPoDn0CsAbLjAK1juZ/aucyqLgvrgqKsf60yIh7e x1cZGJS/60hTDyclSjNCzGzDXj+PGcGFuKmjEogfOctF9A5tImVD X-Google-Smtp-Source: ABdhPJzeT76cYrA3PcJhYFfEV92MwmEzKhhWbsNkEfEo9ZiObqxqwf9y1Jtuhf5yQFjpcev0VGiKQJX2kdZyTPr5U+o= X-Received: by 2002:ab0:3cac:: with SMTP id a44mr13477963uax.129.1634896952598; Fri, 22 Oct 2021 03:02:32 -0700 (PDT) In-Reply-To: <871r4dpesl.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92a.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:134009 Archived-At: On Fri, Oct 22, 2021 at 5:55 PM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Hongyi Zhao wrote: > > > I changed to the following code snippet, but got the same > > result: > > > > (defun hz-company-search () > > (interactive) > > (if company-search-mode > > (company-search-abort) > > (company-search-candidates))) > > > > (define-key company-active-map "\t" #'hz-company-search) > > (define-key company-search-map "\t" #'hz-company-search) > > Hm ... shouldn't it be `company-search-abort' in > `company-search-map'? The following version was tried but got the same behavior: (defun hz-company-search () (interactive) (if company-search-abort (company-search-abort) (company-search-candidates))) (define-key company-active-map "\t" #'hz-company-search) (define-key company-search-map "\t" #'hz-company-search) > But if the function is correct it should work if/where these > maps are active ... I'm puzzled by it.