all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Highlight non-selected minibuffer prompt
@ 2021-07-31 20:58 Juri Linkov
  2021-08-01 20:02 ` Juri Linkov
  2021-08-01 20:49 ` Clément Pit-Claudel
  0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2021-07-31 20:58 UTC (permalink / raw)
  To: emacs-devel

Only today I realized how to address the long-standing complaint
that sometimes accidentally switching from the minibuffer (that
e.g. asks a yes/no question) remains unnoticed that leaves
the minibuffer active for a long time.

The solution was already invented long ago by minibuffer-depth-indicate-mode
that highlights the recursive minibuffer with the minibuffer-depth-indicator face.

The same solution could be used to add a highlighting to the minibuffer prompt
after switching from the minibuffer that still remains active,
thus turning the attention to a possible problem.

I still have no idea where to implement this feature.  Maybe in the same
package mb-depth.el?  Then should it be a separate mode or better to handle
by a new option in the same minibuffer-depth-indicate-mode?
Should it reuse the same minibuffer-depth-indicator face
or add a new one?



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

* Re: Highlight non-selected minibuffer prompt
  2021-07-31 20:58 Highlight non-selected minibuffer prompt Juri Linkov
@ 2021-08-01 20:02 ` Juri Linkov
  2021-08-01 20:49 ` Clément Pit-Claudel
  1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-08-01 20:02 UTC (permalink / raw)
  To: emacs-devel

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

> I still have no idea where to implement this feature.  Maybe in the same
> package mb-depth.el?  Then should it be a separate mode or better to handle
> by a new option in the same minibuffer-depth-indicate-mode?
> Should it reuse the same minibuffer-depth-indicator face
> or add a new one?

This implements it in mb-depth.el with a new option and a new face:


[-- 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] 6+ messages in thread

* Re: Highlight non-selected minibuffer prompt
  2021-07-31 20:58 Highlight non-selected minibuffer prompt Juri Linkov
  2021-08-01 20:02 ` Juri Linkov
@ 2021-08-01 20:49 ` Clément Pit-Claudel
  2021-08-01 21:13   ` Juri Linkov
  2021-08-05 23:58   ` Juri Linkov
  1 sibling, 2 replies; 6+ messages in thread
From: Clément Pit-Claudel @ 2021-08-01 20:49 UTC (permalink / raw)
  To: emacs-devel

On 7/31/21 4:58 PM, Juri Linkov wrote:
> The same solution could be used to add a highlighting to the
> minibuffer prompt after switching from the minibuffer that still
> remains active, thus turning the attention to a possible problem.

That's a nice idea, thanks!

> sometimes accidentally switching from the minibuffer remains
> unnoticed that leaves the minibuffer active for a long time.

In my experience, the worst part of this is that completing that minibuffer interaction restores the (old) window configuration that was active when the minibuffer became active.  Is there a setting to change that, or should I open a bug report?



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

* Re: Highlight non-selected minibuffer prompt
  2021-08-01 20:49 ` Clément Pit-Claudel
@ 2021-08-01 21:13   ` Juri Linkov
  2021-08-05 23:58   ` Juri Linkov
  1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-08-01 21:13 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

>> sometimes accidentally switching from the minibuffer remains
>> unnoticed that leaves the minibuffer active for a long time.
>
> In my experience, the worst part of this is that completing that minibuffer
> interaction restores the (old) window configuration that was active when
> the minibuffer became active.  Is there a setting to change that, or should
> I open a bug report?

There were several bug reports that asked for such an option.
The last report that I recall was bug#45072 (still unimplemented).



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

* Re: Highlight non-selected minibuffer prompt
  2021-08-01 20:49 ` Clément Pit-Claudel
  2021-08-01 21:13   ` Juri Linkov
@ 2021-08-05 23:58   ` Juri Linkov
  2021-08-06  5:56     ` Clément Pit-Claudel
  1 sibling, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2021-08-05 23:58 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

>> sometimes accidentally switching from the minibuffer remains
>> unnoticed that leaves the minibuffer active for a long time.
>
> In my experience, the worst part of this is that completing that minibuffer
> interaction restores the (old) window configuration that was active when
> the minibuffer became active.  Is there a setting to change that, or should
> I open a bug report?

Thanks to Martin there is now a new option 'read-minibuffer-restore-windows'
that you can customize to nil.



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

* Re: Highlight non-selected minibuffer prompt
  2021-08-05 23:58   ` Juri Linkov
@ 2021-08-06  5:56     ` Clément Pit-Claudel
  0 siblings, 0 replies; 6+ messages in thread
From: Clément Pit-Claudel @ 2021-08-06  5:56 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

On 8/5/21 7:58 PM, Juri Linkov wrote:
>>> sometimes accidentally switching from the minibuffer remains
>>> unnoticed that leaves the minibuffer active for a long time.
>>
>> In my experience, the worst part of this is that completing that minibuffer
>> interaction restores the (old) window configuration that was active when
>> the minibuffer became active.  Is there a setting to change that, or should
>> I open a bug report?
> 
> Thanks to Martin there is now a new option 'read-minibuffer-restore-windows'
> that you can customize to nil.

Thanks to both of you!



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

end of thread, other threads:[~2021-08-06  5:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-31 20:58 Highlight non-selected minibuffer prompt Juri Linkov
2021-08-01 20:02 ` Juri Linkov
2021-08-01 20:49 ` Clément Pit-Claudel
2021-08-01 21:13   ` Juri Linkov
2021-08-05 23:58   ` Juri Linkov
2021-08-06  5:56     ` Clément Pit-Claudel

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.