GNU bug report logs -
#34520
delete-matching-lines should report how many lines it deleted
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
> Got an idea!: Simply keep a count of how many lines were deleted, and
> report that in the minibuffer, if using interactively.
Good idea, this will bring deleting the lines under control:
[flush-lines-count.patch (text/x-diff, inline)]
diff --git a/lisp/replace.el b/lisp/replace.el
index b482d76afc..c3d8278936 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -953,7 +953,10 @@ flush-lines
If a match is split across lines, all the lines it lies in are deleted.
They are deleted _before_ looking for the next match. Hence, a match
-starting on the same line at which another match ended is ignored."
+starting on the same line at which another match ended is ignored.
+
+Return the number of deleted lines. When called interactively,
+also print the number."
(interactive
(progn
(barf-if-buffer-read-only)
@@ -968,7 +971,8 @@ flush-lines
(setq rstart (point)
rend (point-max-marker)))
(goto-char rstart))
- (let ((case-fold-search
+ (let ((count 0)
+ (case-fold-search
(if (and case-fold-search search-upper-case)
(isearch-no-upper-case-p regexp t)
case-fold-search)))
@@ -978,9 +982,13 @@ flush-lines
(delete-region (save-excursion (goto-char (match-beginning 0))
(forward-line 0)
(point))
- (progn (forward-line 1) (point))))))
- (set-marker rend nil)
- nil)
+ (progn (forward-line 1) (point)))
+ (setq count (1+ count))))
+ (set-marker rend nil)
+ (when interactive (message "Deleted %d matching line%s"
+ count
+ (if (= count 1) "" "s")))
+ count))
(defun how-many (regexp &optional rstart rend interactive)
This bug report was last modified 6 years and 139 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.