GNU bug report logs - #74404
[PATCH] Give Completion Preview bindings higher precedence

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Eshel Yaron <me@HIDDEN>; Keywords: patch; dated Sun, 17 Nov 2024 16:31:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 74404 <at> debbugs.gnu.org:


Received: (at 74404) by debbugs.gnu.org; 23 Nov 2024 14:03:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 23 09:03:03 2024
Received: from localhost ([127.0.0.1]:57216 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tEqj0-0000D1-MA
	for submit <at> debbugs.gnu.org; Sat, 23 Nov 2024 09:03:02 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:59804 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>)
 id 1tEqiy-0000CT-7d; Sat, 23 Nov 2024 09:03:00 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1732370579;
 bh=AHF61jvcCDwEmYO0CpnP047aRB1BAo07fzWm3T8I+/8=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=qS7pNAefzz/w0d0Ua/l1S6DPx+kr5qrzAzCsnExFnaYGgEbRGGaxlU7gUENsRk0ht
 rrewOVvPzx5FBqfZsjRiBnhq38Ia8d10QZ31DoSn1tc3rNDOjx5WS16sUk8Z0keeXl
 XJiXz0YEQIy8ij38lTE49ONiRCSaxigoKxyX76bjqBpcgAo93ldTt7NVorc6txNGbS
 4yd7jRJRncU1eIC5+DdSFdSXiJTh3Wg7FBb3GYAfl6XL7sYKs514h4Hnfq5U9rn+VR
 Eu8fVAKAIG57DL5Xi9LkMk9ORb9zcdw7EsjJX/Ddl8xvPR5Zm5EfwxIjzMWKk2PIGE
 p5vgzT8YKItuw==
From: Eshel Yaron <me@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
Subject: Re: bug#74404: [PATCH] Give Completion Preview bindings higher
 precedence
In-Reply-To: <87mshry40g.fsf@HIDDEN> (Sean Whitton's message
 of "Fri, 22 Nov 2024 18:08:47 +0800")
References: <m1jzd1j008.fsf@HIDDEN> <86ttc5vljy.fsf@HIDDEN>
 <jwvserpyefx.fsf-monnier+emacs@HIDDEN>
 <87mshry40g.fsf@HIDDEN>
Date: Sat, 23 Nov 2024 15:02:56 +0100
Message-ID: <m1y11a9hf3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74404
Cc: Eli Zaretskii <eliz@HIDDEN>, 74404 <at> debbugs.gnu.org,
 Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

close 74492 31.1
quit

Hi,

Sean Whitton <spwhitton@HIDDEN> writes:

> Hello,
>
> On Sun 17 Nov 2024 at 12:16pm -05, Stefan Monnier via "Bug reports for
> GNU Emacs, the Swiss army knife of text editors" wrote:
>
>> BTW, maybe we should add some notion of minor mode precedence since such
>> problems are actually fairly common.  We could do something similar to
>> what we do with `add-hook`, so `add-minor-mode` takes care of obeying
>> the ordering constraints.
>
> We could also have a customisation option that allows the user to
> override the default priorities.  As minor modes are always interned
> symbols, this would be possible in a way that it isn't for hook
> priorities.

I've opened bug#74492 to discuss this broader topic of explicit minor
mode precedence.  For now, I've pushed my patch solving this particular
issue with Completion Preview mode to master (commit 30bcba27c8c).

With that, I'm closing this bug.


Thanks,

Eshel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.

Message received at 74404 <at> debbugs.gnu.org:


Received: (at 74404) by debbugs.gnu.org; 22 Nov 2024 10:08:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 22 05:08:58 2024
Received: from localhost ([127.0.0.1]:53105 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tEQaw-0001NG-LS
	for submit <at> debbugs.gnu.org; Fri, 22 Nov 2024 05:08:58 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:35066)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <spwhitton@HIDDEN>) id 1tEQau-0001Mw-0b
 for 74404 <at> debbugs.gnu.org; Fri, 22 Nov 2024 05:08:57 -0500
DKIM-Signature: a=rsa-sha256;
 b=yeEJGu947eHh7U5PnO4DtphC7Kpf+ajF1aJxay7Yf36SZmfcp4sIT+h5odLiTAXaR2OoTzCsqx4lNv8ZULoGQj1jCbdpH5NrSXP21ue005+9jjXUUEWSnaL61xfm3q1q1K7agWvDbI2CE9Hj2mCDjbzeQA44+izVaRotAM5DjamYcNZ06wK27+MNfdqrtZYOk4WT/IQXu+YFqrEXOoFRDnYTk9fBVMSNQ1SYzFXeeyryvVr6FquG1jdKND1iOAQs1t5+pji9dwjm4zwGlAIXCYejVq1cbwhnLAtZFtCgGIg8sdTXpzVSXbyMR0dvqXybXmvQxIJEjNcOcs+LQRWnbA==;
 s=purelymail3; d=spwhitton.name; v=1;
 bh=+8GrkYWqain6r8lg81wAw6hDpIfEu1C0L4hIeQXaRso=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=jddjnLZmTIzI3uhNpLM0J6WbDTKTizj4/qu0/A58St66qkC2+yrDYtqscwvGJ7YTHgcXJkya9U9HoD3MdZNxcZvW4jBRzVyoU7nE4sUnQBCnzNfmvqdfQkOYK3AeWJej/t4bUFJXHbZDNWKuDABiBWV+75hqmNkbdbIxv8Otmb/KzUQt2dr0lMxC12nKhgD9spHrdSsgwl1f+6qonRCa2Lg18VHhg4zs83vkVZGC7b7rWsYUcdRg7l68Tse8CpVmh2tZs77wogWMrRUCkTrKGwwRdJLAl5yIJOErS/rRJaexLrW+hl/7pKRV9PYuU/gwIbHlaVGZfPSVEpcA1u0/jw==;
 s=purelymail3; d=purelymail.com; v=1;
 bh=+8GrkYWqain6r8lg81wAw6hDpIfEu1C0L4hIeQXaRso=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 74404 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1054700279; 
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Fri, 22 Nov 2024 10:08:49 +0000 (UTC)
Received: by melete.silentflame.com (Postfix, from userid 1000)
 id 234C47E10B1; Fri, 22 Nov 2024 18:08:47 +0800 (CST)
From: Sean Whitton <spwhitton@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 74404 <at> debbugs.gnu.org,  Eshel Yaron <me@HIDDEN>
Subject: Re: bug#74404: [PATCH] Give Completion Preview bindings higher
 precedence
In-Reply-To: <jwvserpyefx.fsf-monnier+emacs@HIDDEN> (Stefan Monnier via's
 message of "Sun, 17 Nov 2024 12:16:29 -0500")
References: <m1jzd1j008.fsf@HIDDEN> <86ttc5vljy.fsf@HIDDEN>
 <jwvserpyefx.fsf-monnier+emacs@HIDDEN>
Date: Fri, 22 Nov 2024 18:08:47 +0800
Message-ID: <87mshry40g.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74404
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello,

On Sun 17 Nov 2024 at 12:16pm -05, Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> BTW, maybe we should add some notion of minor mode precedence since such
> problems are actually fairly common.  We could do something similar to
> what we do with `add-hook`, so `add-minor-mode` takes care of obeying
> the ordering constraints.

We could also have a customisation option that allows the user to
override the default priorities.  As minor modes are always interned
symbols, this would be possible in a way that it isn't for hook
priorities.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.

Message received at 74404 <at> debbugs.gnu.org:


Received: (at 74404) by debbugs.gnu.org; 17 Nov 2024 17:31:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 12:31:10 2024
Received: from localhost ([127.0.0.1]:58446 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCj78-0005Hi-3M
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:31:10 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:45166 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1tCj74-0005HY-P5
 for 74404 <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:31:09 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1731864666;
 bh=FI3ZreQa9iajvJ3O6IeWvFFGbQSWnFIwjVc0uFpWvvo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=MGcWAMH4wwU3c3QfeHyYjQenF2wtZqcX4ZQNyY6Oe2fVxkZ8X2NzqmD44+PYDoJha
 nkEP9DgJhtJGFMpJmpbCEkoRvnCtapomrm8TwWW9bUOt+1H9XQf65WK0LvlwWQKegV
 KgwYPYyoEZDTlZ/TolEbkudW36MhL5JPKcCpaJyaOv+1upP3mNBci3LIpsV/EnaHe6
 fUxS7oyNbQ4P7pHCQJWNhIGGMW7IhZ3ueqmrraAdcWJcyfAadg6onvBxsl1XZ3f2/M
 7XyayCaefhPJEEMtyDfsHJndCA7JaPnnkdpAvnWmptXOfDnG7KH23BXmpGXL1Z6XjR
 AxUBd85EgxzwA==
From: Eshel Yaron <me@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#74404: [PATCH] Give Completion Preview bindings higher
 precedence
In-Reply-To: <jwvserpyefx.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Sun, 17 Nov 2024 12:16:29 -0500")
References: <m1jzd1j008.fsf@HIDDEN> <86ttc5vljy.fsf@HIDDEN>
 <jwvserpyefx.fsf-monnier+emacs@HIDDEN>
Date: Sun, 17 Nov 2024 18:31:03 +0100
Message-ID: <m14j45ix7s.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74404
Cc: Eli Zaretskii <eliz@HIDDEN>, 74404 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Stefan Monnier <monnier@HIDDEN> writes:

>>> 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.

I thought about that, but no, we can't easily use that, since the
overlay is not necessarily at point: it is generally at the end of the
symbol, and point may be at the middle of the symbol.

>> Adding Stefan, in case he has comments or suggestions.
>
> Assuming the minor mode is disabled as soon as point moves away from the
> completion, I wouldn't have a clear preference between `keymap` and
> `minor-mode-overriding-map-alist`.

Indeed, the minor mode is disabled as soon as the completion preview is
dismissed for whatever reason, including moving point elsewhere.

> BTW, maybe we should add some notion of minor mode precedence since such
> problems are actually fairly common.  We could do something similar to
> what we do with `add-hook`, so `add-minor-mode` takes care of obeying
> the ordering constraints.

That'd be nice, I think.


Thanks,

Eshel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.

Message received at 74404 <at> debbugs.gnu.org:


Received: (at 74404) by debbugs.gnu.org; 17 Nov 2024 17:16:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 12:16:42 2024
Received: from localhost ([127.0.0.1]:58409 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCit7-0004as-QI
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:16:42 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48594)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1tCit5-0004ae-1J
 for 74404 <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:16:40 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 87639807F5;
 Sun, 17 Nov 2024 12:16:32 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1731863791;
 bh=Ov8C7cRXuJHSB8Z9hjk+eNoydzE2yviGk/IetYe7iY4=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=gTN9hCVE3IVI0fDp+TJ86TwPCDe+ANqhBTpfKT84xDs7L+MIJAmiILsbpGdkswUHt
 syUuLXVM1mgCE9ON1bGOlv2OCsBuwGsMJ2tKvuPMRKEbYwNV9OhAxeL0Pei9Y6Jsn8
 R9nlLAZRD5bbthIpkCn155GoLpiRZBwJYl3CbCRp+jdTPh0J/LTTdYHjWcTrOqw4sQ
 o/9HA3t5ehkgtnYmz0Z538ndNjIswBCsnhBLi1Wk6hRcvIrfJU+P4iPW7yqFnOxveR
 3T8EWfLZVzvrYQVFDzYY8dfZKtlbAbN48gvZLRZ4oCDobdCMIIw421tXG6FebYIM0z
 ZcFwJ+6iaQLWA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B203E80672;
 Sun, 17 Nov 2024 12:16:31 -0500 (EST)
Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 155B31203DB;
 Sun, 17 Nov 2024 12:16:31 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#74404: [PATCH] Give Completion Preview bindings higher
 precedence
In-Reply-To: <86ttc5vljy.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 17 Nov
 2024 19:04:33 +0200")
Message-ID: <jwvserpyefx.fsf-monnier+emacs@HIDDEN>
References: <m1jzd1j008.fsf@HIDDEN> <86ttc5vljy.fsf@HIDDEN>
Date: Sun, 17 Nov 2024 12:16:29 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.006 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 74404
Cc: 74404 <at> debbugs.gnu.org, Eshel Yaron <me@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> 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.

Assuming the minor mode is disabled as soon as point moves away from the
completion, I wouldn't have a clear preference between `keymap` and
`minor-mode-overriding-map-alist`.

BTW, maybe we should add some notion of minor mode precedence since such
problems are actually fairly common.  We could do something similar to
what we do with `add-hook`, so `add-minor-mode` takes care of obeying
the ordering constraints.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.

Message received at 74404 <at> debbugs.gnu.org:


Received: (at 74404) by debbugs.gnu.org; 17 Nov 2024 17:04:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 12:04:47 2024
Received: from localhost ([127.0.0.1]:58373 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCiha-0003yo-KR
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:04:46 -0500
Received: from eggs.gnu.org ([209.51.188.92]:51342)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1tCihY-0003yY-Kv
 for 74404 <at> debbugs.gnu.org; Sun, 17 Nov 2024 12:04:45 -0500
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 <eliz@HIDDEN>)
 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==;
Date: Sun, 17 Nov 2024 19:04:33 +0200
Message-Id: <86ttc5vljy.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Eshel Yaron <me@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <m1jzd1j008.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#74404: [PATCH] Give Completion Preview bindings higher
 precedence
References: <m1jzd1j008.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 74404
Cc: 74404 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> 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" <bug-gnu-emacs@HIDDEN>
> 
> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Nov 2024 16:30:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 11:30:56 2024
Received: from localhost ([127.0.0.1]:58255 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tCiAp-0002Qf-Tv
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 11:30:56 -0500
Received: from lists.gnu.org ([209.51.188.17]:32780)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1tCiAn-0002QW-OC
 for submit <at> debbugs.gnu.org; Sun, 17 Nov 2024 11:30:54 -0500
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 <me@HIDDEN>) id 1tCiAn-0003uo-0q
 for bug-gnu-emacs@HIDDEN; Sun, 17 Nov 2024 11:30:53 -0500
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 <me@HIDDEN>) id 1tCiAl-0005Yd-JQ
 for bug-gnu-emacs@HIDDEN; 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==
From: Eshel Yaron <me@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Give Completion Preview bindings higher precedence
X-Hashcash: 1:20:241117:bug-gnu-emacs@HIDDEN::wFlDTZpzQKKrTonm:Btou
Date: Sun, 17 Nov 2024 17:30:47 +0100
Message-ID: <m1jzd1j008.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@HIDDEN;
 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-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
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 <me@HIDDEN>
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


--=-=-=--




Acknowledgement sent to Eshel Yaron <me@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#74404; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.