emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 3c4b3fd 16/28: lv.el: Update truncation rules


From: Oleh Krehel
Subject: [elpa] master 3c4b3fd 16/28: lv.el: Update truncation rules
Date: Sun, 22 Mar 2015 16:34:44 +0000

branch: master
commit 3c4b3fd8609af2b114536e25cc15e2078b8d2441
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    lv.el: Update truncation rules
    
    * lv.el (lv-window): Defer `truncate-lines' to `lv-message'. Set window
      hscroll to 0, just in case.
    (lv-message): If STR is one-line, set `truncate-lines' to nil, otherwise
    set it to t. Make `window-min-height' buffer-local and set it to the
    amount of newlines in STR.
    
    Re #40.
---
 lv.el |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lv.el b/lv.el
index bb47175..969f5cb 100644
--- a/lv.el
+++ b/lv.el
@@ -49,7 +49,7 @@
         (if (setq buf (get-buffer "*LV*"))
             (switch-to-buffer buf)
           (switch-to-buffer "*LV*")
-          (setq truncate-lines nil)
+          (set-window-hscroll lv-wnd 0)
           (setq mode-line-format nil)
           (setq cursor-type nil)
           (set-window-dedicated-p lv-wnd t)
@@ -58,14 +58,18 @@
 
 (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))
-        deactivate-mark
-        golden-ratio-mode)
+  (let* ((ori (selected-window))
+         (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)
+      (set (make-variable-buffer-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)))



reply via email to

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