bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49844: Highlight non-selected minibuffer prompt


From: Juri Linkov
Subject: bug#49844: Highlight non-selected minibuffer prompt
Date: Tue, 03 Aug 2021 10:47:59 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

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:

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]