From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74404: [PATCH] Give Completion Preview bindings higher precedence Date: Sun, 17 Nov 2024 19:04:33 +0200 Message-ID: <86ttc5vljy.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18659"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74404@debbugs.gnu.org To: Eshel Yaron , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 17 18:05:10 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 1tCihy-0004ia-8x for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Nov 2024 18:05:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCihv-00036s-0r; Sun, 17 Nov 2024 12:05:07 -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 1tCihr-00034F-2S for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 12:05:03 -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 1tCihq-0003Bq-OU for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 12:05:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=ReiN9FsgCGLHAOG1LNt9pMDqZRTgY4iGkxwNN4dLcsM=; b=RA4lMlbm6ML7bIwtsDrutPEnZohV/4M2iLqTrBOhM7MoUav6tUP9I5NDx3X5b3K3kbgsnEMZk/nR8LdrRaPeWVB+IJUDMuJqIYpxlLPvfbK1kTo5uzDFfwiaH7BQXSfDaBw7gOXQhwbGDfEi/HQ+oZebOb0NG8PH6FSNDA0pae6DLJZ6NbcNnCkZZ6B1zbp/g19jmzZbjjU61WxUsOUdKuHSQ5o8ItlleKdHctujT5ZFoRJp8xscsFmtF450FNf1nkm3zwIF+itc4vvD36RPfvKMucTJmqJ3ozxRoVm7mx4D47a+aiie7oTai1OsZ6YM5HbLcnuQTHevJZUeCM86rA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tCihq-0003zX-Ch for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2024 12:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Nov 2024 17:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74404-submit@debbugs.gnu.org id=B74404.173186308715306 (code B ref 74404); Sun, 17 Nov 2024 17:05:02 +0000 Original-Received: (at 74404) by debbugs.gnu.org; 17 Nov 2024 17:04:47 +0000 Original-Received: from localhost ([127.0.0.1]:58373 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCiha-0003yo-KR for submit@debbugs.gnu.org; Sun, 17 Nov 2024 12:04:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51342) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tCihY-0003yY-Kv for 74404@debbugs.gnu.org; Sun, 17 Nov 2024 12:04:45 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tCihR-00035I-Ne; Sun, 17 Nov 2024 12:04:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ReiN9FsgCGLHAOG1LNt9pMDqZRTgY4iGkxwNN4dLcsM=; b=luak+wpA9b9R KdyRjVOGaB7asObmGmkKuBGA00/YGBZqF2Lp65RXZRPgUe3+1rPmab8cKrg1XxVt9ujxarqWEtDhO RnvYRt3prxZaNJ6+NbfqqdkZ1G01+2YDYDSoxn453utX7FoBJTlRU/o1Cq1GZNivLpfo6aFf9CbAH /6ud13HZkFqcb3vN8Ysf3Q6UGb35YOhobuqUXy0JyaZ7xNiA8sGsikbTBksPFQTV3/4QQL6U4JLOR +LyL7a7JzED9ibIy5qBuggCyPniqmsYzCnV0MCgnRCT2hSpj8HYaoLSDTvyKcwoOcSUfSR+/xWpEV ikxOqjZ0wbWwN+rhItiXgQ==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:295548 Archived-At: > Date: Sun, 17 Nov 2024 17:30:47 +0100 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > 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? Can't you instead use the 'keymap' text or overlay property? That would avoid the "arms race" of precedences. Adding Stefan, in case he has comments or suggestions.