From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#34520: delete-matching-lines should report how many lines it deleted Date: Wed, 27 Feb 2019 23:36:53 +0200 Organization: LINKOV.NET Message-ID: <87tvgoud56.fsf@mail.linkov.net> References: <87o97aq6gz.fsf@jidanni.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="30642"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 34520@debbugs.gnu.org To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 27 22:39:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gz6v4-0007mf-Eh for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2019 22:39:14 +0100 Original-Received: from localhost ([127.0.0.1]:51032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz6v3-0006V6-Ew for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2019 16:39:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz6ux-0006TZ-2n for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 16:39:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gz6uw-0001LE-7u for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 16:39:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gz6us-0001HF-CB for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 16:39:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gz6us-0005nz-4q for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2019 16:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Feb 2019 21:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34520 X-GNU-PR-Package: emacs Original-Received: via spool by 34520-submit@debbugs.gnu.org id=B34520.155130350422246 (code B ref 34520); Wed, 27 Feb 2019 21:39:02 +0000 Original-Received: (at 34520) by debbugs.gnu.org; 27 Feb 2019 21:38:24 +0000 Original-Received: from localhost ([127.0.0.1]:54449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gz6uG-0005mk-GQ for submit@debbugs.gnu.org; Wed, 27 Feb 2019 16:38:24 -0500 Original-Received: from golden.birch.relay.mailchannels.net ([23.83.209.73]:64084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gz6uD-0005mW-Uq for 34520@debbugs.gnu.org; Wed, 27 Feb 2019 16:38:23 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B2FA85C40A4; Wed, 27 Feb 2019 21:38:19 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a65.g.dreamhost.com (unknown [100.96.35.41]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 494835C4494; Wed, 27 Feb 2019 21:38:19 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a65.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.3); Wed, 27 Feb 2019 21:38:19 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Bored-Shade: 13b65002551beabe_1551303499519_4179143905 X-MC-Loop-Signature: 1551303499519:2819318205 X-MC-Ingress-Time: 1551303499519 Original-Received: from pdx1-sub0-mail-a65.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a65.g.dreamhost.com (Postfix) with ESMTP id E3053819A3; Wed, 27 Feb 2019 13:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=Z7A32yRMeI2BIrFR+PCf9bi9axU=; b= opDRwngPmVfL0AiE1upRjE4O4rSyzst9vDNFfHHgSFBQanuuDjAUW6bf2pGoUFVa Qq6yftVuPREeMTEMyoxzfE0z7IMbat4mMEaCGZlFQy2LGAfbYr1tN0oHwz2eG6sM I+e2g2JAF86r6ruyOmAPunZQOJ3ZoWzxe5gv+5XPJPE= Original-Received: from mail.jurta.org (m91-129-98-103.cust.tele2.ee [91.129.98.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a65.g.dreamhost.com (Postfix) with ESMTPSA id 4B23B819A0; Wed, 27 Feb 2019 13:38:16 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a65 In-Reply-To: <87o97aq6gz.fsf@jidanni.org> ("=?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson"'s message of "Mon, 18 Feb 2019 08:35:08 +0800") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrvddugdduhedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohhfffgjkfgfgggtsehmtderredtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledrleekrddutdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledrleekrddutdefpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtohepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghenucevlhhushhtvghrufhiiigvpedt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155884 Archived-At: --=-=-= Content-Type: text/plain > 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=flush-lines-count.patch 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) --=-=-=--