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

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

[elpa] 211/255: scale column width by buffer width


From: Eric Schulte
Subject: [elpa] 211/255: scale column width by buffer width
Date: Sun, 16 Mar 2014 01:02:50 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 23cce461ff52fc04ed1dbea3f6383f4c98a38408
Author: Eric Schulte <address@hidden>
Date:   Tue Aug 6 12:32:09 2013 -0600

    scale column width by buffer width
---
 list-buffer.el |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/list-buffer.el b/list-buffer.el
index e8d8cd6..5a98f53 100644
--- a/list-buffer.el
+++ b/list-buffer.el
@@ -38,7 +38,8 @@
 (defun list-buffer-create (buffer list &optional headers)
   (pop-to-buffer buffer)
   (set (make-local-variable '*buffer-list*) list)
-  (set (make-local-variable '*buffer-headers*) headers)
+  (set (make-local-variable '*buffer-headers*)
+       (mapcar (curry #'format "%s") headers))
   ;; set commands at the bottom
   (list-buffer-refresh))
 
@@ -54,11 +55,15 @@
 (defun list-buffer-refresh ()
   (let* ((strings (mapcar (curry #'mapcar (curry #'format "%s")) 
*buffer-list*))
          (lengths (mapcar (curry #'mapcar #'length) strings))
-         (widths (apply #'cl-mapcar (compose '1+ #'max) lengths)))
+         (widths (apply #'cl-mapcar (compose '1+ #'max) lengths))
+         ;; scale widths by buffer width
+         (widths (mapcar (compose #'floor (curry #'* (/ (window-total-width)
+                                              (float (apply #'+ widths)))))
+                         widths)))
     ;; write headers
     (when *buffer-headers*
       (set (make-local-variable 'header-line-format)
-           (list-format-row widths *buffer-headers*)))
+           (concat " " (list-format-row widths *buffer-headers*))))
     ;; write rows
     (delete (point-min) (point-max))
     (insert (mapconcat (curry #'list-format-row widths) strings "\n"))))



reply via email to

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