GNU bug report logs - #49844
Highlight non-selected minibuffer prompt

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 3 Aug 2021 08:16:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49844 in the body.
You can then email your comments to 49844 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Tue, 03 Aug 2021 08:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 03 Aug 2021 08:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Highlight non-selected minibuffer prompt
Date: Tue, 03 Aug 2021 10:47:59 +0300
[Message part 1 (text/plain, inline)]
Severity: wishlist
Tags: patch

As suggested in https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00011.html
here is the patch that implements this feature:

[minibuffer-depth-nonselected.patch (text/x-diff, inline)]
diff --git a/lisp/mb-depth.el b/lisp/mb-depth.el
index 88003afb40..ed0ebf800b 100644
--- a/lisp/mb-depth.el
+++ b/lisp/mb-depth.el
@@ -47,11 +47,36 @@ minibuffer-depth-indicator
   :group 'minibuffer
   :version "28.1")
 
+(defface minibuffer-depth-nonselected
+  '((t (:background "yellow" :foreground "dark red" :weight bold)))
+  "Face for non-selected minibuffer prompts.
+It's used after leaving the minibuffer window while the minibuffer remains active."
+  :group 'minibuffer
+  :version "28.1")
+
+(defcustom minibuffer-depth-indicate-nonselected t
+  "If non-nil, indicate the non-selected minibuffer.
+Use the face `minibuffer-depth-nonselected'."
+  :type 'boolean
+  :group 'minibuffer
+  :version "28.1")
+
 ;; An overlay covering the prompt.  This is a buffer-local variable in
 ;; each affected minibuffer.
 ;;
-(defvar minibuffer-depth-overlay)
-(make-variable-buffer-local 'minibuffer-depth-overlay)
+(defvar-local minibuffer-depth-overlay nil)
+(defvar-local minibuffer-depth-nonselected-overlay nil)
+
+(defun minibuffer-depth-select (w)
+  (if (eq (window-buffer w) (current-buffer))
+      (when (overlayp minibuffer-depth-nonselected-overlay)
+        (delete-overlay minibuffer-depth-nonselected-overlay))
+    (unless (eq major-mode 'completion-list-mode)
+      (with-current-buffer (window-buffer w)
+        (let ((ov (make-overlay (point-min) (point-max))))
+          (overlay-put ov 'face 'minibuffer-depth-nonselected)
+          (overlay-put ov 'evaporate t)
+          (setq minibuffer-depth-nonselected-overlay ov))))))
 
 ;; This function goes on minibuffer-setup-hook
 (defun minibuffer-depth-setup ()
@@ -68,7 +93,9 @@ minibuffer-depth-setup
                                          'face
                                          'minibuffer-depth-indicator)
                              " ")))
-      (overlay-put minibuffer-depth-overlay 'evaporate t))))
+      (overlay-put minibuffer-depth-overlay 'evaporate t)))
+  (when minibuffer-depth-indicate-nonselected
+    (add-hook 'window-state-change-functions 'minibuffer-depth-select nil t)))
 
 ;;;###autoload
 (define-minor-mode minibuffer-depth-indicate-mode

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 04 Aug 2021 07:44:02 GMT) Full text and rfc822 format available.

Message #8 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 04 Aug 2021 09:42:54 +0200
Juri Linkov <juri <at> linkov.net> writes:

> Severity: wishlist
> Tags: patch
>
> As suggested in
> https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00011.html
> here is the patch that implements this feature:

I like it -- but does this need to be tied to
minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
active in this way may be attractive even if you don't have that
switched on?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 04 Aug 2021 08:47:03 GMT) Full text and rfc822 format available.

Message #11 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 04 Aug 2021 11:41:54 +0300
>> here is the patch that implements this feature:
>
> I like it -- but does this need to be tied to
> minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
> active in this way may be attractive even if you don't have that
> switched on?

Yeah, I don't like tying to minibuffer-depth-indicate-mode too.
But I have no idea where to put it otherwise.
Adding a new package for 25 lines makes no sense.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 04 Aug 2021 08:54:01 GMT) Full text and rfc822 format available.

Message #14 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 04 Aug 2021 10:53:43 +0200
Juri Linkov <juri <at> linkov.net> writes:

>>> here is the patch that implements this feature:
>>
>> I like it -- but does this need to be tied to
>> minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
>> active in this way may be attractive even if you don't have that
>> switched on?
>
> Yeah, I don't like tying to minibuffer-depth-indicate-mode too.
> But I have no idea where to put it otherwise.
> Adding a new package for 25 lines makes no sense.

Can't we just put it in minibuffer.el?  (But then there should probably
be a user option to switch it on/off.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 04 Aug 2021 22:05:01 GMT) Full text and rfc822 format available.

Message #17 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 05 Aug 2021 00:32:19 +0300
>>> I like it -- but does this need to be tied to
>>> minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
>>> active in this way may be attractive even if you don't have that
>>> switched on?
>>
>> Yeah, I don't like tying to minibuffer-depth-indicate-mode too.
>> But I have no idea where to put it otherwise.
>> Adding a new package for 25 lines makes no sense.
>
> Can't we just put it in minibuffer.el?  (But then there should probably
> be a user option to switch it on/off.)

Ironically, minibuffer.el is intended for code that deals with
completions.  Its first line is

  ;;; minibuffer.el --- Minibuffer completion functions

But most code that deals with the minibuffer
is somewhere in the middle of simple.el.

So neither minibuffer.el nor simple.el is suitable.
Perhaps this was the reason why there are a lot of tiny
packages that provide various minibuffer features,
such as mb-depth.el, minibuf-eldef.el, rfn-eshadow.el, etc.

Maybe it would make sense to create a new file with the name e.g.
minibuf-x.el as a mixed bag of tiny minibuffer features?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Thu, 05 Aug 2021 05:54:02 GMT) Full text and rfc822 format available.

Message #20 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 05 Aug 2021 08:53:46 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Date: Thu, 05 Aug 2021 00:32:19 +0300
> Cc: 49844 <at> debbugs.gnu.org
> 
> > Can't we just put it in minibuffer.el?  (But then there should probably
> > be a user option to switch it on/off.)
> 
> Ironically, minibuffer.el is intended for code that deals with
> completions.  Its first line is
> 
>   ;;; minibuffer.el --- Minibuffer completion functions

That's not carved in stone, though.  We could change that heading
accordingly, and start adding stuff to minibuffer.el that doesn't
necessarily deal with completion.

> But most code that deals with the minibuffer
> is somewhere in the middle of simple.el.

Which is somewhat sub-optimal, I think.

> Maybe it would make sense to create a new file with the name e.g.
> minibuf-x.el as a mixed bag of tiny minibuffer features?

I don't think a new file is justified at this time.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Thu, 05 Aug 2021 11:01:02 GMT) Full text and rfc822 format available.

Message #23 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 05 Aug 2021 13:00:20 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Ironically, minibuffer.el is intended for code that deals with
>> completions.  Its first line is
>> 
>>   ;;; minibuffer.el --- Minibuffer completion functions
>
> That's not carved in stone, though.  We could change that heading
> accordingly, and start adding stuff to minibuffer.el that doesn't
> necessarily deal with completion.

And there already is a lot of that in minibuffer.el -- just scroll to
the bottom of the file and page up a bit.  At least the last 100 lines
have nothing to do with completion.

So I think we should just change the heading and put more minibuffer
stuff in minibuffer.el.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Sat, 06 Nov 2021 02:42:01 GMT) Full text and rfc822 format available.

Message #26 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Sat, 06 Nov 2021 03:41:25 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> So I think we should just change the heading and put more minibuffer
> stuff in minibuffer.el.

I've now done so in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Sat, 06 Nov 2021 02:43:02 GMT) Full text and rfc822 format available.

Message #29 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Sat, 06 Nov 2021 03:42:18 +0100
Juri Linkov <juri <at> linkov.net> writes:

>> I like it -- but does this need to be tied to
>> minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
>> active in this way may be attractive even if you don't have that
>> switched on?
>
> Yeah, I don't like tying to minibuffer-depth-indicate-mode too.
> But I have no idea where to put it otherwise.
> Adding a new package for 25 lines makes no sense.

Juri -- please go ahead and put this in minibuffer.el.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Sat, 06 Nov 2021 19:11:02 GMT) Full text and rfc822 format available.

Message #32 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Sat, 06 Nov 2021 20:43:31 +0200
>>> I like it -- but does this need to be tied to
>>> minibuffer-depth-indicate-mode?  Indicating that the minibuffer isn't
>>> active in this way may be attractive even if you don't have that
>>> switched on?
>>
>> Yeah, I don't like tying to minibuffer-depth-indicate-mode too.
>> But I have no idea where to put it otherwise.
>> Adding a new package for 25 lines makes no sense.
>
> Juri -- please go ahead and put this in minibuffer.el.

ISTR, in bug#50141 we decided to add more generalized code to windmove.el
that will provide 4 customizable types of window backgrounds colors
with different faces:

1. selected window
2. non-selected window
3. selected minibuffer window
4. non-selected minibuffer window




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Sat, 06 Nov 2021 21:15:02 GMT) Full text and rfc822 format available.

Message #35 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Sat, 06 Nov 2021 22:14:46 +0100
Juri Linkov <juri <at> linkov.net> writes:

> ISTR, in bug#50141 we decided to add more generalized code to windmove.el
> that will provide 4 customizable types of window backgrounds colors
> with different faces:
>
> 1. selected window
> 2. non-selected window
> 3. selected minibuffer window
> 4. non-selected minibuffer window

But...  isn't think pretty much unrelated to windmove, too?  I'd just
like to have the minibuffer light up when I've moved point somewhere
else (because it can be confusing sometimes).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Sun, 07 Nov 2021 17:48:02 GMT) Full text and rfc822 format available.

Message #38 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Sun, 07 Nov 2021 19:31:25 +0200
>> ISTR, in bug#50141 we decided to add more generalized code to windmove.el
>> that will provide 4 customizable types of window backgrounds colors
>> with different faces:
>>
>> 1. selected window
>> 2. non-selected window
>> 3. selected minibuffer window
>> 4. non-selected minibuffer window
>
> But...  isn't think pretty much unrelated to windmove, too?  I'd just
> like to have the minibuffer light up when I've moved point somewhere
> else (because it can be confusing sometimes).

This was intended to address different requests.  So far the requests
were: to highlight the background of the selected window, to highlight
the selected minibuffer window, and to highlight the non-selected
active minibuffer.  The last case actually is more complex:
the non-selected minibuffer should not be highlighted
when the Completions window is selected.  Only after moving point
out of both the minibuffer and the Completions window, the minibuffer
window should be highlighted.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Mon, 22 Aug 2022 11:05:02 GMT) Full text and rfc822 format available.

Message #41 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Mon, 22 Aug 2022 13:04:48 +0200
Juri Linkov <juri <at> linkov.net> writes:

> The last case actually is more complex: the non-selected minibuffer
> should not be highlighted when the Completions window is selected.
> Only after moving point out of both the minibuffer and the Completions
> window, the minibuffer window should be highlighted.

This was a year ago -- did you make any progress here?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 17 Sep 2025 15:09:01 GMT) Full text and rfc822 format available.

Message #44 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 17 Sep 2025 18:07:56 +0300
[Message part 1 (text/plain, inline)]
>> > Can't we just put it in minibuffer.el?  (But then there should probably
>> > be a user option to switch it on/off.)
>> 
>> Ironically, minibuffer.el is intended for code that deals with
>> completions.  Its first line is
>> 
>>   ;;; minibuffer.el --- Minibuffer completion functions
>
> That's not carved in stone, though.  We could change that heading
> accordingly, and start adding stuff to minibuffer.el that doesn't
> necessarily deal with completion.

Sorry for the long delay - I came back to this while dealing
with non-selected windows in bug#64993.  Here is the patch
after moving code to minibuffer.el:

[minibuffer-nonselected-mode.patch (text/x-diff, inline)]
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 8d58189ef85..ae16b6b6149 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -5595,6 +5596,47 @@ minibuffer-regexp-mode
     (remove-hook 'minibuffer-setup-hook #'minibuffer--regexp-setup)
     (remove-hook 'minibuffer-exit-hook #'minibuffer--regexp-exit)))
 
+
+(defface minibuffer-nonselected
+  '((t (:background "yellow" :foreground "dark red" :weight bold)))
+  "Face for non-selected minibuffer prompts.
+It's used after leaving the minibuffer window
+while the minibuffer remains active."
+  :version "31.1")
+
+(defvar-local minibuffer-nonselected-overlay nil)
+
+(defun minibuffer-nonselected-check (w)
+  "Check when point leaves the minibuffer.
+Use overlay to highlight the minibuffer when another window is selected.
+But don't warn in case when the *Completions* window is selected."
+  (if (eq w (selected-window))
+      (when (overlayp minibuffer-nonselected-overlay)
+        (delete-overlay minibuffer-nonselected-overlay))
+    (unless (eq major-mode 'completion-list-mode)
+      (with-current-buffer (window-buffer w)
+        (let ((ov (make-overlay (point-min) (point-max))))
+          (overlay-put ov 'face 'minibuffer-nonselected)
+          (overlay-put ov 'window w)
+          (overlay-put ov 'evaporate t)
+          (setq minibuffer-nonselected-overlay ov))))))
+
+(defun minibuffer-nonselected-setup ()
+  (add-hook 'window-selection-change-functions
+            'minibuffer-nonselected-check nil t))
+
+(define-minor-mode minibuffer-nonselected-mode
+  "Minor mode to warn about non-selected active minibuffer.
+Use the face `minibuffer-nonselected' to highlight the minibuffer
+after moving point out of the minibuffer window."
+  :global t
+  :initialize 'custom-initialize-delay
+  :init-value t
+  (if minibuffer-nonselected-mode
+      (add-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)
+    (remove-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)))
+
+
 (provide 'minibuffer)
 
 ;;; minibuffer.el ends here

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 17 Sep 2025 17:54:01 GMT) Full text and rfc822 format available.

Message #47 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 17 Sep 2025 20:53:05 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 49844 <at> debbugs.gnu.org
> Date: Wed, 17 Sep 2025 18:07:56 +0300
> 
> Sorry for the long delay - I came back to this while dealing
> with non-selected windows in bug#64993.  Here is the patch
> after moving code to minibuffer.el:

Thanks.

> +(defface minibuffer-nonselected
> +  '((t (:background "yellow" :foreground "dark red" :weight bold)))
> +  "Face for non-selected minibuffer prompts.
> +It's used after leaving the minibuffer window
> +while the minibuffer remains active."
> +  :version "31.1")
> +
> +(defvar-local minibuffer-nonselected-overlay nil)
> +
> +(defun minibuffer-nonselected-check (w)
> +  "Check when point leaves the minibuffer.
> +Use overlay to highlight the minibuffer when another window is selected.
> +But don't warn in case when the *Completions* window is selected."

These two doc strings use problematic wording.  Point cannot "leave" a
buffer, including the minibuffer.  I think what you mean is that the
minibuffer remains active, but the mini-window is no longer selected.

> +(define-minor-mode minibuffer-nonselected-mode
> +  "Minor mode to warn about non-selected active minibuffer.
> +Use the face `minibuffer-nonselected' to highlight the minibuffer
> +after moving point out of the minibuffer window."
> +  :global t
> +  :initialize 'custom-initialize-delay
> +  :init-value t
> +  (if minibuffer-nonselected-mode
> +      (add-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)
> +    (remove-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)))

The new minor mode and the new face should be in NEWS.

Also, don't we want to have :version tags in the modes as well?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Wed, 17 Sep 2025 19:04:02 GMT) Full text and rfc822 format available.

Message #50 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Wed, 17 Sep 2025 21:52:05 +0300
[Message part 1 (text/plain, inline)]
> These two doc strings use problematic wording.  Point cannot "leave" a
> buffer, including the minibuffer.  I think what you mean is that the
> minibuffer remains active, but the mini-window is no longer selected.
>
>> +(define-minor-mode minibuffer-nonselected-mode
>> +  "Minor mode to warn about non-selected active minibuffer.
>> +Use the face `minibuffer-nonselected' to highlight the minibuffer
>> +after moving point out of the minibuffer window."
>> +  :global t
>> +  :initialize 'custom-initialize-delay
>> +  :init-value t
>> +  (if minibuffer-nonselected-mode
>> +      (add-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)
>> +    (remove-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)))
>
> The new minor mode and the new face should be in NEWS.
>
> Also, don't we want to have :version tags in the modes as well?

Hopefully this is a better version:

[minibuffer-nonselected-mode_2.patch (text/x-diff, inline)]
diff --git a/etc/NEWS b/etc/NEWS
index 1d8e85f7d1a..bd928345283 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -253,6 +253,13 @@ that your popup interface uses for a more integrated experience.
 ('completion-preview-sort-function' was already present in Emacs 30.1,
 but as a plain Lisp variable, not a user option.)
 
+---
+*** New mode 'minibuffer-nonselected-mode'.
+This mode enabled by default directs the attention to the active
+minibuffer window using the 'minibuffer-nonselected' face in case
+when the minibuffer window is no longer selected, but the minibuffer
+is still waiting for input.
+
 ** Mouse
 
 *** New mode 'mouse-shift-adjust-mode' extends selection with 'S-<mouse-1>'.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 8d58189ef85..6557f17a636 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -5595,6 +5596,50 @@ minibuffer-regexp-mode
     (remove-hook 'minibuffer-setup-hook #'minibuffer--regexp-setup)
     (remove-hook 'minibuffer-exit-hook #'minibuffer--regexp-exit)))
 
+
+(defface minibuffer-nonselected
+  '((t (:background "yellow" :foreground "dark red" :weight bold)))
+  "Face for non-selected minibuffer prompts.
+It's displayed on the minibuffer window when the minibuffer
+remains active, but the minibuffer window is no longer selected."
+  :version "31.1")
+
+(defvar-local minibuffer-nonselected-overlay nil)
+
+(defun minibuffer-nonselected-check (w)
+  "Check when the active minibuffer's window is no longer selected.
+Use overlay to highlight the minibuffer window when another window
+is selected.  But don't warn in case when the *Completions* window
+becomes selected."
+  (if (eq w (selected-window))
+      (when (overlayp minibuffer-nonselected-overlay)
+        (delete-overlay minibuffer-nonselected-overlay))
+    (unless (eq major-mode 'completion-list-mode)
+      (with-current-buffer (window-buffer w)
+        (let ((ov (make-overlay (point-min) (point-max))))
+          (overlay-put ov 'face 'minibuffer-nonselected)
+          (overlay-put ov 'window w)
+          (overlay-put ov 'evaporate t)
+          (setq minibuffer-nonselected-overlay ov))))))
+
+(defun minibuffer-nonselected-setup ()
+  (add-hook 'window-selection-change-functions
+            'minibuffer-nonselected-check nil t))
+
+(define-minor-mode minibuffer-nonselected-mode
+  "Minor mode to warn about non-selected active minibuffer.
+Use the face `minibuffer-nonselected' to highlight the minibuffer
+window when the minibuffer remains active, but the minibuffer window
+is no longer selected."
+  :global t
+  :initialize 'custom-initialize-delay
+  :init-value t
+  :version "31.1"
+  (if minibuffer-nonselected-mode
+      (add-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)
+    (remove-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)))
+
+
 (provide 'minibuffer)
 
 ;;; minibuffer.el ends here

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Thu, 18 Sep 2025 04:55:02 GMT) Full text and rfc822 format available.

Message #53 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 18 Sep 2025 07:54:39 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 49844 <at> debbugs.gnu.org
> Date: Wed, 17 Sep 2025 21:52:05 +0300
> 
> > These two doc strings use problematic wording.  Point cannot "leave" a
> > buffer, including the minibuffer.  I think what you mean is that the
> > minibuffer remains active, but the mini-window is no longer selected.
> >
> >> +(define-minor-mode minibuffer-nonselected-mode
> >> +  "Minor mode to warn about non-selected active minibuffer.
> >> +Use the face `minibuffer-nonselected' to highlight the minibuffer
> >> +after moving point out of the minibuffer window."
> >> +  :global t
> >> +  :initialize 'custom-initialize-delay
> >> +  :init-value t
> >> +  (if minibuffer-nonselected-mode
> >> +      (add-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)
> >> +    (remove-hook 'minibuffer-setup-hook #'minibuffer-nonselected-setup)))
> >
> > The new minor mode and the new face should be in NEWS.
> >
> > Also, don't we want to have :version tags in the modes as well?
> 
> Hopefully this is a better version:

Thanks, LGTM.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Thu, 18 Sep 2025 09:53:02 GMT) Full text and rfc822 format available.

Message #56 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Rudolf Adamkovič <rudolf <at> adamkovic.org>
To: Juri Linkov <juri <at> linkov.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 18 Sep 2025 11:51:51 +0200
Juri Linkov <juri <at> linkov.net> writes:

>>> +(define-minor-mode minibuffer-nonselected-mode

The documentation says "no longer selected", so why not

  minibuffer-deselected-mode or
  minibuffer-unselected-mode

or better, use a more descriptive name, such as

  minibuffer-deselected-highlight-mode or
  minibuffer-unselected-highlight-mode

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
--- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič <rudolf <at> adamkovic.org> [he/him]
http://adamkovic.org




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Thu, 18 Sep 2025 15:23:02 GMT) Full text and rfc822 format available.

Message #59 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Rudolf Adamkovič <rudolf <at> adamkovic.org>
Cc: 49844 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Thu, 18 Sep 2025 18:16:08 +0300
>>>> +(define-minor-mode minibuffer-nonselected-mode
>
> The documentation says "no longer selected", so why not
>
>   minibuffer-deselected-mode or
>   minibuffer-unselected-mode
>
> or better, use a more descriptive name, such as
>
>   minibuffer-deselected-highlight-mode or
>   minibuffer-unselected-highlight-mode

"non-selected" is the standard terminology, e.g.:

  cursor-face-highlight-nonselected-window
  highlight-nonselected-windows

However, some names contain additional dash:

  cursor-in-non-selected-windows
  mode-line-in-non-selected-windows
  mouse-1-click-in-non-selected-windows

that I think is quite controversial since such dashes
differ from other dashes that replace spaces.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Fri, 19 Sep 2025 06:18:01 GMT) Full text and rfc822 format available.

Message #62 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Rudolf Adamkovič <rudolf <at> adamkovic.org>
Cc: 49844 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Fri, 19 Sep 2025 09:10:06 +0300
>>>> +(define-minor-mode minibuffer-nonselected-mode
>
> The documentation says "no longer selected", so why not
>
>   minibuffer-deselected-mode or
>   minibuffer-unselected-mode
>
> or better, use a more descriptive name, such as
>
>   minibuffer-deselected-highlight-mode or
>   minibuffer-unselected-highlight-mode

Also adding "-highlight" would make the name longer
that makes it less handy (e.g. for completions, etc.).
The documentation says that it highlights the minibuffer,
so this should be really sufficient.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49844; Package emacs. (Fri, 19 Sep 2025 15:20:02 GMT) Full text and rfc822 format available.

Message #65 received at 49844 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 49844 <at> debbugs.gnu.org
Subject: Re: bug#49844: Highlight non-selected minibuffer prompt
Date: Fri, 19 Sep 2025 18:16:35 +0300
close 49844 31.0.50
thanks

>> Hopefully this is a better version:
>
> Thanks, LGTM.

So now pushed and closed.  I'm still open to possible renames.
The current name is based on the name 'minibuffer-regexp-mode'
for regexp highlighting that doesn't contain the word '-highlight-'
in the mode name.




bug marked as fixed in version 31.0.50, send any further explanations to 49844 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Fri, 19 Sep 2025 15:20:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 18 Oct 2025 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 46 days ago.

Previous Next


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