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#70010: 30.0.50; completion-preview-mode behaves mode-local, but is global Date: Tue, 26 Mar 2024 22:49:04 +0100 Message-ID: References: <87o7b1gsfp.fsf@posteo.net> <875xx8g4e8.fsf@posteo.net> 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="34103"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70010@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 26 22:50:34 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 1rpEgj-0008gh-T9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Mar 2024 22:50:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpEgG-000675-86; Tue, 26 Mar 2024 17:50:04 -0400 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 1rpEgE-00066u-Jc for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 17:50:02 -0400 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 1rpEgE-0006Gw-AV for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 17:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rpEgD-0002Af-W9 for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 17:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Mar 2024 21:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70010 X-GNU-PR-Package: emacs Original-Received: via spool by 70010-submit@debbugs.gnu.org id=B70010.17114897508205 (code B ref 70010); Tue, 26 Mar 2024 21:50:01 +0000 Original-Received: (at 70010) by debbugs.gnu.org; 26 Mar 2024 21:49:10 +0000 Original-Received: from localhost ([127.0.0.1]:35405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rpEfN-00028H-H8 for submit@debbugs.gnu.org; Tue, 26 Mar 2024 17:49:09 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:37926 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rpEfL-00027s-9D for 70010@debbugs.gnu.org; Tue, 26 Mar 2024 17:49:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1711489746; bh=X/dIpZ4UcAvpedu8OMuh6R0ocsyAMXoRhIqRVZZHm9k=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=IysPlxD7dnh7bq/Jil5VT5pO4wpcBDhR3djgmxMSzWXaBpGuuRUrbCVIksGnXcFiA 7BozS24hNVR6qypwRuQXeJRINBciZdymGQ6VACETWwupDX2FXfic6FiV/GVmdWDH8r HAYm00zcU++Ygyxn1q+DewHqRn8ziJRMuipyvrhuTBs83huQoLvMpdMcA0VOnA4rAi L8PzQm1N1A8W+g1m30deG+aqgC1FghFRdBKQPvixrVDWTHq1LSzlQGc9fFNhikR5Bz B/1QUF1Gy9MdPNWR+bmE6hjTUmorWO+I2gSRuvS4zRlOWLgOBx+doYzMrIrgtekPWm V2iOPeO/LAhzg== In-Reply-To: <875xx8g4e8.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 26 Mar 2024 19:49:19 +0000") X-Hashcash: 1:20:240326:philipk@posteo.net::wsjUOU5V69u7Sz8h:rNb X-Hashcash: 1:20:240326:70010@debbugs.gnu.org::f0DoR05TXF3xLv8W:14P4 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:282118 Archived-At: --=-=-= Content-Type: text/plain Philip Kaludercic writes: > Eshel Yaron writes: > >> Hello Philip, >> >> Philip Kaludercic writes: >> >>> I tried to enable `completion-preview-mode' by adding >>> >>> (setopt completion-preview-mode t) >>> >>> in my init, but it had not effect. >> >> Indeed, it is a minor mode, so one normally enables it by calling the >> function completion-preview-mode, perhaps interactively via M-x. > > I enable all minor modes as user options, so I'd disagree that using a > function or invoking the command are the only ways to expect a minor > mode to be enabled. Fair enough :) >>> When I check the implementation, I noticed that it modifies >>> `post-command-hook' locally. I think it would make sense to rename >>> the current `completion-preview-mode' to >>> `completion-preview-local-mode', and then use >>> `define-globalized-minor-mode' to define `completion-preview-mode'. >> >> We can add a global variant, although IMO the natural scope for >> completion-preview-mode is per major mode: for some kinds of content you >> want to have completion preview, and for others you may want it off. >> Note that a necessary condition for completion-preview-mode to be useful >> in a certain context is that completion-at-point is useful in that >> context, since otherwise there's nothing to preview. >> >> Therefore, I recommend enabling completion-preview-mode by adding it to >> major mode hooks, such as prog-mode-hook or comint-mode-hook. >> Admittedly, if you do want to enable it for all buffers, the major mode >> hook approach would require adding it to four or five hooks, which is a >> bit less elegant than enabling a global minor mode once. >> >> So I suggest we keep completion-preview-mode local and add a global >> variant, say, completion-preview-global-mode, for enabling it globally. >> WDYT? > > That seems fine as well. All right, here's a patch that adds such a global variant. I find the :predicate argument of define-globalized-minor-mode pretty neat, it adds a user option that lets users choose in which major modes the minor mode should take effect, and we can provide a sane default: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-global-minor-mode-completion-preview-global-mode.patch >From caca8078f95b8e2d6c67ada1da6fdb024262c5bc Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 26 Mar 2024 22:34:51 +0100 Subject: [PATCH] Add global minor mode 'completion-preview-global-mode' This is a global variant of 'completion-preview-mode'. * lisp/completion-preview.el (completion-preview-global-mode): New global minor mode. (Bug#70010) --- lisp/completion-preview.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 75386f96429..f8a3c5ac4a2 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -414,5 +414,9 @@ completion-preview-mode (remove-hook 'post-command-hook #'completion-preview--post-command t) (completion-preview-active-mode -1))) +(define-globalized-minor-mode completion-preview-global-mode + completion-preview-mode completion-preview-mode + :predicate '((not minibuffer-mode special-mode) t)) + (provide 'completion-preview) ;;; completion-preview.el ends here -- 2.44.0 --=-=-=--