unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49844: Highlight non-selected minibuffer prompt
@ 2021-08-03  7:47 Juri Linkov
  2021-08-04  7:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Juri Linkov @ 2021-08-03  7:47 UTC (permalink / raw)
  To: 49844

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: minibuffer-depth-nonselected.patch --]
[-- Type: text/x-diff, Size: 2154 bytes --]

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-08-22 11:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  7:47 bug#49844: Highlight non-selected minibuffer prompt Juri Linkov
2021-08-04  7:42 ` Lars Ingebrigtsen
2021-08-04  8:41   ` Juri Linkov
2021-08-04  8:53     ` Lars Ingebrigtsen
2021-08-04 21:32       ` Juri Linkov
2021-08-05  5:53         ` Eli Zaretskii
2021-08-05 11:00           ` Lars Ingebrigtsen
2021-11-06  2:41             ` Lars Ingebrigtsen
2021-11-06  2:42     ` Lars Ingebrigtsen
2021-11-06 18:43       ` Juri Linkov
2021-11-06 21:14         ` Lars Ingebrigtsen
2021-11-07 17:31           ` Juri Linkov
2022-08-22 11:04             ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).