diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2019-09-16 03:48:47 +0200 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2019-09-26 17:24:35 +0200 |
commit | 814cab3b4d89066dbd9a7aaad7d98c382a5a3485 (patch) | |
tree | 7d66bbbe159ee537a8d7c737e45bda1050cbea87 /lisp/emacs-lisp/tabulated-list.el | |
parent | 45524b9702b4a6face2cf453eb02ddf10a496b45 (diff) | |
download | emacs-814cab3b4d89066dbd9a7aaad7d98c382a5a3485.tar.gz |
Add new function to clear tags in tabulated list
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-clear-all-tags):
New function to clear all tags from padding area in current buffer.
* doc/lispref/modes.texi (Tabulated List Mode): Document it.
* etc/NEWS: Announce it.
Diffstat (limited to 'lisp/emacs-lisp/tabulated-list.el')
-rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index f30e2c0ec8e..ade60285883 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -192,6 +192,19 @@ If ADVANCE is non-nil, move forward by one line afterwards." (if advance (forward-line))) +(defun tabulated-list-clear-all-tags () + "Clear all tags from the padding area in the current buffer." + (unless (> tabulated-list-padding 0) + (error "There can be no tags in current buffer")) + (save-excursion + (goto-char (point-min)) + (let ((inhibit-read-only t) + ;; Match non-space in the first n characters. + (re (format "^ \\{0,%d\\}[^ ]" (1- tabulated-list-padding))) + (empty (make-string tabulated-list-padding ? ))) + (while (re-search-forward re nil 'noerror) + (tabulated-list-put-tag empty))))) + (defvar tabulated-list-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map (make-composed-keymap |