From unknown Mon Jun 16 23:45:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#47620 <47620@debbugs.gnu.org> To: bug#47620 <47620@debbugs.gnu.org> Subject: Status: [PATCH] Allow complex key bindings in project-switch-project Reply-To: bug#47620 <47620@debbugs.gnu.org> Date: Tue, 17 Jun 2025 06:45:41 +0000 retitle 47620 [PATCH] Allow complex key bindings in project-switch-project reassign 47620 emacs submitter 47620 Dario Gjorgjevski severity 47620 normal tag 47620 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 06 10:57:47 2021 Received: (at submit) by debbugs.gnu.org; 6 Apr 2021 14:57:47 +0000 Received: from localhost ([127.0.0.1]:41441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTn9H-0001il-4x for submit@debbugs.gnu.org; Tue, 06 Apr 2021 10:57:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:55578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTn99-0001iY-AP for submit@debbugs.gnu.org; Tue, 06 Apr 2021 10:57:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTn99-0005Hb-19 for bug-gnu-emacs@gnu.org; Tue, 06 Apr 2021 10:57:39 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:35747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTn95-0003FW-RG for bug-gnu-emacs@gnu.org; Tue, 06 Apr 2021 10:57:38 -0400 Received: by mail-ed1-x535.google.com with SMTP id p4so6684838edr.2 for ; Tue, 06 Apr 2021 07:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=koBkEva34Ipie4IkL/p83ieHsPkM37lDEmRNOWAM5CE=; b=DwD2uFDAmOgadLVN0Q0Oc4dZbenew40ObxOYh/xfQ6N7yPuJA1i1ew3tF2mvctNXjC 4aB2L44DpLYLG9yuL/q/HnGopMXwHFs3ikPnJJFLjJHgi8An8L7il8fjfIzbO9eJ64GH o3L07kCEL78vDWRUh+h79fnWUfqMgHii+4hJxbWALkmArFNBwIKhA+lVLAhoj2RWvYqy 8taVZfz/PokMQe07DKeMvvm6GK8tptwMpZxGnblb36UKefQ/DyYicmBweUTTM4p+xkOf tEF7ePN1RneCTPwfyCGn6om5oXZI9K+ZYuSJzGPSWkhuy0IwyV6rfQsMEnf/u7ZV3thL dk/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=koBkEva34Ipie4IkL/p83ieHsPkM37lDEmRNOWAM5CE=; b=UP4ftrkrwFgfxAREwGytV6lNd0gCKm4n6VTM/AMunB9ntFQRcsDdr3q5NXAkNFianR Hh3lNCemPYoQre/E+ebX7O/1aSdHskAv0KJF1DOnSf4SO13tpCCSNV4RLKxmimYD8b6V ESoiaxamGQU3ID/keBjZAmcTjWIrX1V3zSMl1juKL5apy5cb76teL40/Hu0fdFFhcTv4 skQzoO1BXOCFPAP5/KZ3KcSCQTdnFSanOw9AVpLQIaLLiJ1RWdEDvNt0ACOKehc0ppq1 2m9pk7kt8kghZQmA5+/06LdcpohwvEd09jBxeghT7PcS5bjIZ4S8YioKJHSmHjUI93x8 dRtw== X-Gm-Message-State: AOAM533c9QkgAAmvQTQkRSIYFkY5/rAsITdRasQz2rdcbGZZUuZ4Aejx 6oUm0qifb28KOV3hy2RGhS6clJww49+W9w== X-Google-Smtp-Source: ABdhPJyPCdNfj/i8YAmBBa2vMFGMmZL/rbMax5m9nGXPQsQtmFScu6nW64tO7e/qOxLhKvHUMh8hVA== X-Received: by 2002:a05:6402:2786:: with SMTP id b6mr24971715ede.310.1617721052996; Tue, 06 Apr 2021 07:57:32 -0700 (PDT) Received: from ZALANDO-31298 ([212.86.35.48]) by smtp.gmail.com with ESMTPSA id v8sm13956286edc.30.2021.04.06.07.57.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Apr 2021 07:57:32 -0700 (PDT) From: Dario Gjorgjevski To: bug-gnu-emacs@gnu.org Subject: [PATCH] Allow complex key bindings in project-switch-project Date: Tue, 06 Apr 2021 16:57:31 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=dario.gjorgjevski@gmail.com; helo=mail-ed1-x535.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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Hi, project-switch-project currently only allows for single-char bindings to be used for its commands. Starting with emacs -Q, evaluate (require 'project) (define-key project-prefix-map (kbd "M-s g") 'rgrep) (add-to-list 'project-switch-commands '(rgrep "grep")) and then run project-switch-project (by default bound to C-x p p) and choose a project (hopefully you already have one available). You will see "[M-s g] grep" shown in the prompt, but you will not be able to choose it by typing M-s g. The patch attached bellow allows for any kind of key binding to be used. Admittedly, there may be a better way to do it since I did not spend much time looking into it. Please, share your thoughts. Best regards, Dario --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Allow-complex-key-bindings-in-project-switch-project.patch Content-Description: Allow complex key bindings in project-switch-project >From dbd256fced765e55bbe8a589874490a121546ae1 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Tue, 6 Apr 2021 16:51:28 +0200 Subject: [PATCH] Allow complex key bindings in project-switch-project * lisp/progmodes/project.el (project-switch-project): Replace read-event with an overriding local map and read-key-sequence to allow for complex key bindings to be read. --- lisp/progmodes/project.el | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 910f70db03..84d02e25d9 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1338,23 +1338,27 @@ made from `project-switch-commands'. When called in a program, it will use the project corresponding to directory DIR." (interactive (list (project-prompt-project-dir))) - (let ((commands-menu - (mapcar - (lambda (row) - (if (characterp (car row)) - ;; Deprecated format. - ;; XXX: Add a warning about it? - (reverse row) - row)) - project-switch-commands)) - command) + (let* ((commands-menu + (mapcar + (lambda (row) + (if (characterp (car row)) + ;; Deprecated format. + ;; XXX: Add a warning about it? + (reverse row) + row)) + project-switch-commands)) + (commands-map + (let ((temp-map (make-sparse-keymap))) + (set-keymap-parent temp-map project-prefix-map) + (dolist (row commands-menu temp-map) + (when-let ((cmd (nth 0 row)) + (keychar (nth 2 row))) + (define-key temp-map (vector keychar) cmd))))) + command) (while (not command) - (let ((choice (read-event (project--keymap-prompt)))) - (when (setq command - (or (car - (seq-find (lambda (row) (equal choice (nth 2 row))) - commands-menu)) - (lookup-key project-prefix-map (vector choice)))) + (let ((overriding-local-map commands-map) + (choice (read-key-sequence (project--keymap-prompt)))) + (when (setq command (lookup-key commands-map choice)) (unless (or project-switch-use-entire-map (assq command commands-menu)) ;; TODO: Add some hint to the prompt, like "key not -- 2.31.GIT --=-=-= Content-Type: text/plain -- $ keyserver=hkps://hkps.pool.sks-keyservers.net $ keyid=744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 06 20:28:37 2021 Received: (at 47620-done) by debbugs.gnu.org; 7 Apr 2021 00:28:37 +0000 Received: from localhost ([127.0.0.1]:42516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTw3h-0005ox-70 for submit@debbugs.gnu.org; Tue, 06 Apr 2021 20:28:37 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:40453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTw3f-0005oh-8e for 47620-done@debbugs.gnu.org; Tue, 06 Apr 2021 20:28:35 -0400 Received: by mail-wr1-f43.google.com with SMTP id 12so1506385wrz.7 for <47620-done@debbugs.gnu.org>; Tue, 06 Apr 2021 17:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=i+VhHVBJi2EBFDFUyYkz+9EV+rYltFjMQocPXSwee1E=; b=j7NwCk+S0YCcZlGmOZSvsuMSN2uB4rTchZCTXOYR+zuCepe7LQmbWcpv0+vUQkz/mF a31QGGjUsakHhkXxi2A2U4vzbbReZkNGzaKYT7FN/yrlTuUf9lIhUFqE9P8uPaiC0xBS EQRkqqHiXwmtfjW3ZmiyM1ap6+xx504Vr2q7dSV6cqi3phvFeitVvYduuKf7a9UH4N0D G+OyNejkuxo3ysI96HQ0jw+0rQiyp2X5cBME6QnnIVjznmYkRuoefeqYDwGvBZuUVnPp 8dd3tbQ0GtY6aRjYE2CSdJaq8ccbJJKx8B0HiZMg0XgcoIAP32iwiTCHitb+Jn1CGh60 gg8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=i+VhHVBJi2EBFDFUyYkz+9EV+rYltFjMQocPXSwee1E=; b=BEUEIC4qSsSeO+d1ayWair4z04gvWknVjAFfGzcuby2kr0rEnEFrwzQf8fLoIyR0r4 ZBh7W0eRK1XqoMaQYoYTns5rPP7PCJSx3dmTFmTeln5l/ray13m9Nd2rvlURrs88Zzmv m6e2ONt4agUgSBMvqssEh0oXl4cpiUBjnzaAvyQO/EQYfpZVhShh7mBlRNpjqRFA2jS8 oOxue5H5BLPKt7ydSZJd+NXuVTVAprHgvKB0d6gVVshCGzJDcG/5iuyT+msy0OWE4/rX NjBopQvYRo5LwspiEVB22yEmY/zhExAuDq04ElUBnkqIhIGsPp43nGsnG1wObtoVDOR3 Yoyg== X-Gm-Message-State: AOAM531X4l4cb76L0LvfyLeO/olZ4McGiK2Hv2QmtSrwdCaUeg5oiRIC dWjs6MM4c1Zfzjwh/83eUSs9tEk86MQ= X-Google-Smtp-Source: ABdhPJxVJ4gRps5bg3C/pWW/Uag083t6msY81DoVH12NlOgi9TfQHO1Bk0bne6NAiyg2+Jcw1OmWNA== X-Received: by 2002:adf:fb05:: with SMTP id c5mr956972wrr.302.1617755309463; Tue, 06 Apr 2021 17:28:29 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n2sm3055835wrq.59.2021.04.06.17.28.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Apr 2021 17:28:28 -0700 (PDT) Subject: Re: bug#47620: [PATCH] Allow complex key bindings in project-switch-project To: Dario Gjorgjevski , 47620-done@debbugs.gnu.org References: From: Dmitry Gutov Message-ID: <34e7eb22-597a-985c-5172-130f8bebde86@yandex.ru> Date: Wed, 7 Apr 2021 03:28:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 47620-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Hi Dario, On 06.04.2021 17:57, Dario Gjorgjevski wrote: > project-switch-project currently only allows for single-char bindings to > be used for its commands. Starting with emacs -Q, evaluate > > (require 'project) > (define-key project-prefix-map (kbd "M-s g") 'rgrep) > (add-to-list 'project-switch-commands '(rgrep "grep")) > > and then run project-switch-project (by default bound to C-x p p) and > choose a project (hopefully you already have one available). You will > see "[M-s g] grep" shown in the prompt, but you will not be able to > choose it by typing M-s g. > > The patch attached bellow allows for any kind of key binding to be used. > Admittedly, there may be a better way to do it since I did not spend > much time looking into it. > > Please, share your thoughts. Thanks for the patch, it's a nice addition. Note that it broke the ability to 'C-g' out of the second prompt, see the follow-up commit 1ff7cde102. Likewise, any proposals with a better way to do this are welcome. (Meantime, closing.) From unknown Mon Jun 16 23:45:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 05 May 2021 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator