Skip to content

Commit 7dbdb31

Browse files
committed
Persistent status message by timeout
1 parent 7b2a897 commit 7dbdb31

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

resize-window.el

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,28 @@ Main data structure of the dispatcher with the form:
155155
"List of aliases for commands.
156156
Rather than have to use n, etc, you can alias keys for others.")
157157

158+
(defvar resize-window--notify-timers nil
159+
"Notify callback timers.")
160+
161+
(defun resize-window--cancel-notify ()
162+
"Cancel all the notify callback timers."
163+
(mapc 'cancel-timer resize-window--notify-timers)
164+
(setq resize-window--notify-timers nil))
165+
158166
(defun resize-window--notify (&rest info)
159167
"Notify with INFO, a string or list (format-string object...).
160-
This is just a pass through to message usually. However, it can be
161-
overridden in tests to test the output of message."
162-
(when resize-window-notify-with-messages (apply #'message info)))
168+
Display the status message again after a timeout.
169+
Can be overridden in tests to test the output."
170+
(resize-window--cancel-notify)
171+
(when resize-window-notify-with-messages
172+
(message "Resize mode: %s" (apply #'format info))
173+
(push (run-with-timer 1.5 nil #'resize-window--notify-status)
174+
resize-window--notify-timers)))
175+
176+
(defun resize-window--notify-status ()
177+
"Display status message."
178+
(when resize-window-notify-with-messages
179+
(message "Resize mode: insert KEY, ? for help, q or SPACE to quit")))
163180

164181
(defun resize-window--key-str (key)
165182
"Return the string representation of KEY.
@@ -297,9 +314,7 @@ CHOICE is a \(key function documentation allows-capitals\).
297314
If SCALED, then call action with the `resize-window-uppercase-argument'."
298315
(let ((action (resize-window--choice-lambda choice))
299316
(description (resize-window--choice-documentation choice)))
300-
(unless (resize-window--keys-equal
301-
(resize-window--choice-keybinding choice) [??])
302-
(resize-window--notify "%s" description))
317+
(resize-window--notify "%s" description)
303318
(condition-case nil
304319
(if scaled
305320
(funcall action (resize-window-uppercase-argument))
@@ -320,7 +335,7 @@ to resize right."
320335
;; NOTE: Do not trim the stack here. Let stack requests to handle
321336
;; window configurations in excess.
322337
(resize-window--add-backgrounds)
323-
(resize-window--notify "Resize mode: insert KEY, ? for help")
338+
(resize-window--notify-status)
324339
(condition-case nil
325340
(let ((reading-keys t)
326341
;; allow mini-buffer to collapse after displaying menu
@@ -343,6 +358,7 @@ to resize right."
343358
(resize-window--keys-equal key [? ])
344359
(resize-window--keys-equal key "C-g"))
345360
(setq reading-keys nil)
361+
(resize-window--cancel-notify)
346362
(resize-window--display-menu 'kill)
347363
(resize-window--remove-backgrounds))
348364
(t

0 commit comments

Comments
 (0)