all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* tabulated-list-resize-current-column
@ 2018-06-11 18:06 Boruch Baum
  0 siblings, 0 replies; only message in thread
From: Boruch Baum @ 2018-06-11 18:06 UTC (permalink / raw)
  To: Emacs-Devel List; +Cc: Chong Yidong

[-- Attachment #1: Type: text/plain, Size: 619 bytes --]

Attached is a proposed contribution for the package `tabulated-list.el'.

The idea is to offer to emacs users a feature long-common in GUI
tabulated list widgets - the ability to dynamically resize columns. I
only use emacs in nox, so in my selfishness (and in my ignorance of most
programming things GUI) that's all this function provides, but it's a
start for anyone wanting to extend to that environment.

An obvious follow-up idea is a companion function to change the
sequence of columns, also a long-common feature in GUI environments.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: tabulated-list-resize-current-column.el --]
[-- Type: text/plain, Size: 890 bytes --]

(defun tabulated-list-resize-current-column (&optional num)
  "Change width of the current column by N columns.

This is a buffer-local change. To permanently change a column's
size, see defcustom `tabulated-list-format'."
  (interactive "N(In/De)crease size of current column by:")
  (let ((col (current-column))
        (total-column-count 0)
        (len (length tabulated-list-format))
	(idx 0) this-column-size found)
   (while (and (not found) (< idx len))
     (if (> col (setq total-column-count
                    (+ total-column-count
                       (setq this-column-size
                         (cadr (aref tabulated-list-format idx))))))
       (setq idx (1+ idx))
      (setf (cadr (aref tabulated-list-format idx)) (max 1 (+ this-column-size num)))
      (setq found t)
      (tabulated-list-init-header)
      (tabulated-list-print)
      (move-to-column col)))))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-11 18:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-11 18:06 tabulated-list-resize-current-column Boruch Baum

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.