From 6198fb2b57a9c8267d86baac40406d05ef62eb2a Mon Sep 17 00:00:00 2001 From: Thuna Date: Sat, 2 Jul 2022 18:24:34 +0300 Subject: [PATCH 4/4] Allow interactive hiding of a specific column in tabulated-list * tabulated-list.el (tabulated-list-hide-column tabulated-list-hide-current-column): The command `tabulated-list-hide-current-column' is now a wrapper for `tabulated-list-hide-column', a function which takes the name of the column and hides it. This can be called interactively similar to `tabulated-list-make-column-visible' --- lisp/emacs-lisp/tabulated-list.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 96607307fa..c04a539ed8 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -778,8 +778,21 @@ tabulated-list-narrow-current-column (defun tabulated-list-hide-current-column () "Hide the current tabulated list column." (interactive) - (let ((col-nb (tabulated-list--column-number - (tabulated-list-get-column)))) + (tabulated-list-hide-column + (tabulated-list-get-column))) + +(defun tabulated-list-hide-column (name) + "Hide the tabulated list column NAME. +Interactively, NAME is a visible column prompted for with +`completing-read'" + (interactive + (list + (completing-read "Column name" + (append tabulated-list-format nil) + (lambda (col) + (not (plist-get (nthcdr 3 col) :hidden))) + t))) + (let ((col-nb (tabulated-list--column-number name))) ;; `tabulated-list-format' may be a constant (sharing list ;; structures), so copy it before mutating. (setq tabulated-list-format (copy-tree tabulated-list-format t)) -- 2.35.1