branch: master commit 00d2c0c6f97fe2910849cdc4cddb77d24bc73e51 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Add lv-force-update * hydra.el (hydra-keyboard-quit): Don't clear the message when `hydra--ignore' is t. * lv.el (lv-force-update): New defvar. (lv-message): Refresh the window unless both the window contents haven't changed and `lv-force-update' is nil. Fixes #121 --- hydra.el | 7 ++++--- lv.el | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hydra.el b/hydra.el index 8c2a046..45daf2f 100644 --- a/hydra.el +++ b/hydra.el @@ -387,9 +387,10 @@ Return DEFAULT if PROP is not in H." (hydra-disable) (cancel-timer hydra-timeout-timer) (cancel-timer hydra-message-timer) - (if hydra-lv - (lv-delete-window) - (message "")) + (unless hydra--ignore + (if hydra-lv + (lv-delete-window) + (message ""))) nil) (defun hydra--hint (body heads) diff --git a/lv.el b/lv.el index 69e8497..76094b5 100644 --- a/lv.el +++ b/lv.el @@ -56,22 +56,24 @@ (set-window-parameter lv-wnd 'no-other-window t)) (select-window ori))))) +(defvar lv-force-update t + "When non-nil, `lv-message' will refresh even for the same string.") + (defun lv-message (format-string &rest args) "Set LV window contents to (`format' FORMAT-STRING ARGS)." - (let* ((ori (selected-window)) - (str (apply #'format format-string args)) + (let* ((str (apply #'format format-string args)) (n-lines (cl-count ?\n str)) deactivate-mark golden-ratio-mode) - (select-window (lv-window)) - (unless (string= (buffer-string) str) - (delete-region (point-min) (point-max)) - (insert str) - (setq-local window-min-height n-lines) - (setq truncate-lines (> n-lines 1)) - (fit-window-to-buffer nil nil 1)) - (goto-char (point-min)) - (select-window ori))) + (with-selected-window (lv-window) + (unless (and (string= (buffer-string) str) + (null lv-force-update)) + (delete-region (point-min) (point-max)) + (insert str) + (setq-local window-min-height n-lines) + (setq truncate-lines (> n-lines 1)) + (fit-window-to-buffer nil nil 1)) + (goto-char (point-min))))) (defun lv-delete-window () "Delete LV window and kill its buffer."