]> code.delx.au - gnu-emacs-elpa/commitdiff
Add lv-force-update
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 26 Apr 2015 07:21:52 +0000 (09:21 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 26 Apr 2015 07:21:52 +0000 (09:21 +0200)
* 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
lv.el

index 8c2a046faaaf6b0769d3750e382981c84014e6a3..45daf2f608abdc1abcb5e33d6dcc9dd7fe80156d 100644 (file)
--- 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 69e8497a97c20a5ff089b465403e1e2eed681cfe..76094b58f7209f96f1e217f7bad8a907a7cdc890 100644 (file)
--- a/lv.el
+++ b/lv.el
           (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."