1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 10:31:37 -08:00

Make vtable narrow/widen functions take a prefix

* lisp/emacs-lisp/vtable.el (vtable-narrow-current-column)
(vtable-widen-current-column): Allow using the prefix to say how
much to narrow/widen the columns.
This commit is contained in:
Lars Ingebrigtsen 2022-04-14 02:47:23 +02:00
parent ffb7612d2c
commit c3b6cfda36

View file

@ -758,9 +758,12 @@ This also updates the displayed table."
"Minor mode for buffers with vtables with headers." "Minor mode for buffers with vtables with headers."
:keymap vtable-header-mode-map) :keymap vtable-header-mode-map)
(defun vtable-narrow-current-column () (defun vtable-narrow-current-column (&optional n)
"Narrow the current column." "Narrow the current column by N characters.
(interactive) If N isn't given, N defaults to 1.
Interactively, N is the prefix argument."
(interactive "p")
(let* ((table (vtable-current-table)) (let* ((table (vtable-current-table))
(column (vtable-current-column)) (column (vtable-current-column))
(widths (vtable--widths table))) (widths (vtable--widths table)))
@ -768,18 +771,23 @@ This also updates the displayed table."
(user-error "No column under point")) (user-error "No column under point"))
(setf (aref widths column) (setf (aref widths column)
(max (* (vtable--char-width table) 2) (max (* (vtable--char-width table) 2)
(- (aref widths column) (vtable--char-width table)))) (- (aref widths column)
(* (vtable--char-width table) (or n 1)))))
(vtable-revert))) (vtable-revert)))
(defun vtable-widen-current-column () (defun vtable-widen-current-column (&optional n)
"Widen the current column." "Widen the current column by N characters.
(interactive) If N isn't given, N defaults to 1.
Interactively, N is the prefix argument."
(interactive "p")
(let* ((table (vtable-current-table)) (let* ((table (vtable-current-table))
(column (vtable-current-column)) (column (vtable-current-column))
(widths (nth 1 (vtable--cache table)))) (widths (nth 1 (vtable--cache table))))
(unless column (unless column
(user-error "No column under point")) (user-error "No column under point"))
(cl-incf (aref widths column) (vtable--char-width table)) (cl-incf (aref widths column)
(* (vtable--char-width table) (or n 1)))
(vtable-revert))) (vtable-revert)))
(defun vtable-previous-column () (defun vtable-previous-column ()