emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 814cab3: Add new function to clear tags in tabulate


From: Stefan Kangas
Subject: [Emacs-diffs] master 814cab3: Add new function to clear tags in tabulated list
Date: Thu, 26 Sep 2019 11:35:41 -0400 (EDT)

branch: master
commit 814cab3b4d89066dbd9a7aaad7d98c382a5a3485
Author: Stefan Kangas <address@hidden>
Commit: Stefan Kangas <address@hidden>

    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.
---
 doc/lispref/modes.texi            |  5 +++++
 etc/NEWS                          |  5 +++++
 lisp/emacs-lisp/tabulated-list.el | 13 +++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 7185c24..2e0c9e4 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1201,6 +1201,11 @@ width of which is governed by 
@code{tabulated-list-padding}.
 function advances point by one line.
 @end defun
 
+@defun tabulated-list-clear-all-tags
+This function clears all tags from the padding area in the current
+buffer.
+@end defun
+
 @defun tabulated-list-set-col col desc &optional change-entry-data
 This function changes the tabulated list entry at point, setting
 @var{col} to @var{desc}.  @var{col} is the column number to change, or
diff --git a/etc/NEWS b/etc/NEWS
index 4b693aa..0939443 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1766,6 +1766,11 @@ near the current column in Tabulated Lists (see variables
 list mode: 'w' (which widens the current column) and 'c' which makes
 the current column contract.
 
++++
+*** New function 'tabulated-list-clear-all-tags'.
+This function clears all tags from the padding area in the current
+buffer.  Tags are typically added by calling 'tabulated-list-put-tag'.
+
 ** Text mode
 
 +++
diff --git a/lisp/emacs-lisp/tabulated-list.el 
b/lisp/emacs-lisp/tabulated-list.el
index f30e2c0..ade6028 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



reply via email to

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