Skip to content

Commit

Permalink
lv.el: Update truncation rules
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
abo-abo committed Mar 12, 2015
1 parent bfe65da commit 3c4b3fd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lv.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)))
Expand Down

0 comments on commit 3c4b3fd

Please sign in to comment.