From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/notmuch-indicator f563869b6a 2/4: Tweak how the keymap is implemented Date: Wed, 28 Sep 2022 14:30:01 -0400 Message-ID: References: <166438787034.3914.5858408463434087870@vcs2.savannah.gnu.org> <20220928175750.D5B2CC00615@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17476"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Protesilaos Stavrou To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 28 20:43:15 2022 Return-path: Envelope-to: ged-emacs-devel@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 1odc1a-0004ND-KT for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Sep 2022 20:43:14 +0200 Original-Received: from localhost ([::1]:51786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odc1Z-0005fe-97 for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Sep 2022 14:43:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odbox-0005hm-QD for emacs-devel@gnu.org; Wed, 28 Sep 2022 14:30:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odbou-00030a-1E for emacs-devel@gnu.org; Wed, 28 Sep 2022 14:30:10 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6FC45441A7F; Wed, 28 Sep 2022 14:30:03 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CE33B441A79; Wed, 28 Sep 2022 14:30:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1664389801; bh=4gfrS1IoUo2UDDM+n+fGXV3amNZVSu2n798y4ar4tn8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ojrv3qsVCq33z8b6Iu3AdrI0iALUGdGvOlPrxaMS6dHPqT5Rwj0/FkEvAc4zuEZRD ZFtQIqzqXwI6McUFmbompz6MchFoAKYSwhVFAq5IuSrywZ9m1H9Y2hoA64EXxmbtzh O1wzyKOPPydO7PgBo4LoEz70YrCX1YMnHKgfNSis5y4uYiEnxYoP5/cXt2e/0VGPPY d7lvNSirZW1r6DXRb20e/0R59BE+lS3eVDhVq1o94wuFzj6UGLyy0W25A6CGGG5mdL MlSDvcv99YwICGhoCn/qy4Gps5rhP02CzUnGI7m2mDx/qx9EgUeYlVoe4TyWPCPlKx gyOx8syFI470w== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A62A0120EA3; Wed, 28 Sep 2022 14:30:01 -0400 (EDT) In-Reply-To: <20220928175750.D5B2CC00615@vcs2.savannah.gnu.org> (ELPA Syncer's message of "Wed, 28 Sep 2022 13:57:50 -0400 (EDT)") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296414 Archived-At: > branch: externals/notmuch-indicator > commit f563869b6a5e5e12fd791bc109232ed45064f7a7 > Author: Protesilaos Stavrou > Commit: Protesilaos Stavrou > > Tweak how the keymap is implemented >=20=20=20=20=20 > This continues the work done by Henrik Kjerringv=E5g in commit f5c9b2= e. > Henrik does not require to assign copyright to the Free Software > Foundation for that commit, as it is within the ~15 line threshold. > --- > notmuch-indicator.el | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/notmuch-indicator.el b/notmuch-indicator.el > index 89e93054ee..9b598910e2 100644 > --- a/notmuch-indicator.el > +++ b/notmuch-indicator.el > @@ -166,17 +166,21 @@ option `notmuch-indicator-refresh-count'." > (shell-command-to-string > (format "notmuch count %s" terms)))) >=20=20 > +(defvar notmuch-indicator-mode-map > + (let ((map (make-sparse-keymap))) > + map) > + "Keymap for the Notmuch indicator.") > + > (defun notmuch-indicator--format-label (label count face terms) > "Format LABEL, COUNT, FACE and TERMS of `notmuch-indicator-args'." > - (let ((map (make-sparse-keymap))) > - (define-key map [mode-line mouse-1] > - (lambda () (interactive) (notmuch-search terms))) > - (propertize > - (if (and face label) > - (format "%s%s " (propertize label 'face face) count) > - (format "%s%s " (or label "") count)) > - 'help-echo "mouse-1: Open notmuch search" > - 'local-map map))) > + (define-key notmuch-indicator-mode-map [mode-line mouse-1] > + (lambda () (interactive) (notmuch-search terms))) > + (propertize > + (if (and face label) > + (format "%s%s " (propertize label 'face face) count) > + (format "%s%s " (or label "") count)) > + 'help-echo (format "mouse-1: Open notmuch search for `%s'" terms) > + 'local-map notmuch-indicator-mode-map)) Hmm... really? The new `define-key` will overwrite the binding added in the previous call to `notmuch-indicator--format-label`, so if you have several elements in `notmuch-indicator-args`, they'll all use the last element's `terms` when you click `mouse-1` on them. While I'm here: > + (if (and face label) > + (format "%s%s " (propertize label 'face face) count) > + (format "%s%s " (or label "") count)) can be rewritten to =20=20=20=20 (format "%s%s " (if (and face label) (propertize label 'face face) (or label "") count) Oh, and I see elsewhere that you call `mapconcat` with only 2 args, which is a new feature in Emacs-29 whereas the package claims to want to support Emacs-27. Stefan