From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74404: [PATCH] Give Completion Preview bindings higher precedence Date: Sun, 17 Nov 2024 17:30:47 +0100 Message-ID: Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16732"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 74404@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 17 17:31:26 2024 Return-path: Envelope-to: geb-bug-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 1tCiBK-0004DY-AM for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Nov 2024 17:31:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCiAz-0003vu-A0; Sun, 17 Nov 2024 11:31:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCiAw-0003vF-Lb for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 11:31:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tCiAw-0005a0-Cs for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 11:31:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=Rm0MTOCCnurrSpRvXEGoqLYB9yMB/9HUGIh7rKAA2lE=; b=me9l3O5PMtNlxkUvlaSzqxzgpICDrBfXTGLk38VrV6bJytzZwCEDQZ5VF57LS46/I5jvBsn3M/u9t+ApVWMBLeLziTLv1xSSK+xTFfici7R+J7SHGQP6EThOot8bJf48u+bqdJSND35M+/jLX1Nbux/7ybvmo+C7gMpy2iwVrItPRx62/b+Gk2Qype2R4FIRvNk2k/TTzhFH0fOa+f4+l/wI6/or9GhvfuK2r9yfk/hsaiFtBZPNWs8NQdCWLiLlQdZoK9ZhlPVTD1Q6IKZVrnJlWhya9gxZD0SZ21yDxR4QQqfBKLs4rK2TNGR5Pi4APLTdtuy3jbgQyVI2ps723Q==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tCiAw-0002R2-7w for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 11:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Nov 2024 16:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17318610569345 (code B ref -1); Sun, 17 Nov 2024 16:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Nov 2024 16:30:56 +0000 Original-Received: from localhost ([127.0.0.1]:58255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCiAp-0002Qf-Tv for submit@debbugs.gnu.org; Sun, 17 Nov 2024 11:30:56 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:32780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCiAn-0002QW-OC for submit@debbugs.gnu.org; Sun, 17 Nov 2024 11:30:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCiAn-0003uo-0q for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 11:30:53 -0500 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCiAl-0005Yd-JQ for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 11:30:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1731861049; bh=7PDLbA2C0TT6G/s/VJbInWFoC+5IWwIe2M+qJWKvQuE=; h=From:To:Subject:Date:From; b=fZr5YRmnyg1NfMC4eMKDylKNYJER8ypnHt685CLyqYwkbtIT+CrEZp9xrxsMdh98t obJM4qe5dY3TeCFYy5zRlZCnWJX8igpV6moCdWW9RD6HatqyDat2nKx4/h3ozrQBzi U3agy4bQdZEJYAqODxNVmpr8GN1uX3VJiBm7/Yxro4m2Szwxn9e7tYTqe2Y1i+BoPd vKQtOP6LTk44bJ0G2ixH0+LXEvvhe/oGs5gt+jqNKMQmLpel9XSqZxzQjBQv7tFDtl OZ64Tjcejf1SOEKOU3TJjgGsNXTSW2ovmFDau3lrMykaL1Gyyzx6jn5Tcg5ANKgR4T k+3u3aGa7FA8w== X-Hashcash: 1:20:241117:bug-gnu-emacs@gnu.org::wFlDTZpzQKKrTonm:Btou Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295541 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Whenever Completion Preview mode shows a completion preview, it also activates keybindings for commands that interact with that preview, most notably TAB is bound to completion-preview-insert, which inserts the suggested completion. This is implemented via a minor mode completion-preview-active-mode whose keymap provides these bindings, and which is enabled when the preview is displayed. This all works well, except for when another minor mode, foo-mode, is enabled, whose keybindings conflict with these active preview bindings. If foo-mode is defined after completion-preview-active-mode, i.e. if foo.el is loaded after completion-preview.el, then foo-mode comes first in minor-mode-map-alist and takes precedence over the bindings in completion-preview-active-mode-map. This happens, for example, with eshell-cmpl-mode, a minor mode that is enabled by default in Eshell, which binds TAB to completion-at-point. So currently Completion Preview mode doesn't work as expected in Eshell: when you try to accept the suggested completion (with TAB), you get completion-at-point instead of completion-preview-insert. To fix this issue, we need to give the active completion preview bindings higher precedence than keymaps of minor modes that where defined after loading completion-preview.el. The patch below does that by using minor-mode-overriding-map-alist. Any thoughts? --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Give-Completion-Preview-bindings-higher-precedence.patch >From 951df80d3749b2e82072f397dd7c7b5ce256f36d Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 17 Nov 2024 16:55:30 +0100 Subject: [PATCH] Give Completion Preview bindings higher precedence * lisp/completion-preview.el (completion-preview-active-mode): add keymap to 'minor-mode-overriding-map-alist' so it takes precedence over other minor mode maps that bind TAB, such as 'eshell-cmpl-mode' in Eshell. --- lisp/completion-preview.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 4564812e8a9..e5be3197032 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -322,8 +322,13 @@ completion-preview-active-mode "Mode for when the completion preview is shown." :interactive nil (if completion-preview-active-mode - (add-hook 'window-selection-change-functions - #'completion-preview--window-selection-change nil t) + (progn + (add-hook 'window-selection-change-functions + #'completion-preview--window-selection-change nil t) + ;; Give keymap precedence over other minor mode maps. + (setf (alist-get 'completion-preview-active-mode + minor-mode-overriding-map-alist) + completion-preview-active-mode-map)) (remove-hook 'window-selection-change-functions #'completion-preview--window-selection-change t) (completion-preview-hide))) -- 2.46.2 --=-=-=--