From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: keep|flush-lines, how-many to be used backward. Date: Mon, 24 Sep 2007 18:08:22 +0200 Organization: Epita/LRDE Message-ID: <87d4w8ujux.fsf@cadilhac.name> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0492321331==" X-Trace: sea.gmane.org 1190650331 28549 80.91.229.12 (24 Sep 2007 16:12:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Sep 2007 16:12:11 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 24 18:12:01 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IZqXD-0007RN-8m for ged-emacs-devel@m.gmane.org; Mon, 24 Sep 2007 18:11:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZqXA-000503-F5 for ged-emacs-devel@m.gmane.org; Mon, 24 Sep 2007 12:11:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IZqQB-0007cN-Pe for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:04:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IZqQ8-0007aS-Lk for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:04:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZqQ8-0007aE-AG for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:04:28 -0400 Original-Received: from ext.lri.fr ([129.175.15.4]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IZqQ6-0002Qj-Ey for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:04:27 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 70233A471B for ; Mon, 24 Sep 2007 18:04:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr Original-Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SlJ2zGtHi-1K for ; Mon, 24 Sep 2007 18:04:22 +0200 (CEST) Original-Received: from smtp.lri.fr (vhost3-23 [129.175.3.23]) by ext.lri.fr (Postfix) with ESMTP id 459AFA4731 for ; Mon, 24 Sep 2007 18:04:22 +0200 (CEST) Original-Received: from lri4-154 (pc4-154 [129.175.4.154]) by smtp.lri.fr (Postfix) with ESMTP id 1AFF0E04DC for ; Mon, 24 Sep 2007 18:04:22 +0200 (CEST) X-Website: http://michael.cadilhac.name Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEVWPh+Tai+5r5YKBAEU CQQzGAtiq7gjAAACR0lEQVQ4jW2UzW7lIAyFzVW8BzTZX5DmCZLuU2H2pMXv/ypzbK7aSh2kRCRf /HNsE0q7Sg+RQ7JFKaqtrRNAl5AIIKe6D5DBqgbmUAe5hBI1wIRFAHjeM0RKtZi7XVVEpb0BSNfA IddChChT5DildSLWOWhY5IEItMnncZgFcUAc/5jjwCMsDosRNdfKPDTFEdVBW8C+RebDb4N5Orio RhM1+11IJyx0ng2+LryFHBMPDQDYHrY6IfGuU3ouiXTQNE8LIJDKOWpNxERTFrggQwRPd7USUsTW fJ0XbR3bdj5KgBYy4SACpxDeUYEUAzLmtJ1iIrD2gczPq8Qomjhsh/RjGIgKIO8p7NITjwlx7WID nsnQe5NeuTvoBpi8LX6vLLOh5icjOHqBypgnuSp7M+RE1agbQKHQr5E2z1WObhYW4gMqeGQL7joM jCf2DxSk5ApADSYHfFF4igNfJZL1z0GKP0FN02s4XiDXr7V5P94W6I9v8MfBOQDmfwAaVYt+x8Da v4DJvX8BAdin3Knm5yMZYAO4ABDkDniZLLfi4P40gP1F0TPGZOu0CGwA1lcowxwlGy6A9705mD0V jHCxwVZT/hYdRJVUGZNlx6l7ScQBTluof6Wj6bsPYlvpwoTvXFD9gHPn2TZPF3ntI2ecxVrW5MrV XiCie5EeNa7BlWu/HNSkprDUva163PHxAv5jyGV7gVzyAghSKOTnat85UIYFICXbD2NV9rRiv0BS tKQsg6OHH4A15F1WW+UHKHHa32h6aPnAm3/pUcWp+WYnTQAAAABJRU5ErkJggg== User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) X-Detected-Kernel: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:79702 Archived-At: --===============0492321331== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= I've been using this for a few days, and I find it quite useful. It may be good to install. The effect: C-u M-x how-many RET is how-many'ing in the text *before* point. Same for C-u M-x keep-lines. If this is not the right thing to do for such a feature, just say it, I'll not insist too much. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=replace.patch Content-Transfer-Encoding: quoted-printable =2D-- replace.el 26 Jul 2007 07:26:32 +0200 1.259 +++ replace.el 24 Sep 2007 18:04:34 +0200=09 @@ -525,10 +525,15 @@ =20 (defun keep-lines-read-args (prompt) "Read arguments for `keep-lines' and friends. =2DPrompt for a regexp with PROMPT. +Prompt for a regexp with PROMPT followed by some information and a colon. Value is a list, (REGEXP)." =2D (list (read-from-minibuffer prompt nil nil nil =2D 'regexp-history nil t) + (list (read-from-minibuffer (concat prompt + (if (and transient-mark-mode mark-active) + " in the region: " + (if current-prefix-arg + " backward: " + ": "))) + nil nil nil 'regexp-history nil t) nil nil t)) =20 (defun keep-lines (regexp &optional rstart rend interactive) @@ -547,7 +552,8 @@ =20 Interactively, in Transient Mark mode when the mark is active, operate on all lines whose accessible part is entirely contained in the region. =2DOtherwise, the command applies to all lines starting after point. +Otherwise, the command applies to all lines starting after point (or before +point if a prefix argument is provided). When calling this function from Lisp, you can pretend that it was called interactively by passing a non-nil INTERACTIVE argument. =20 @@ -558,7 +564,7 @@ (interactive (progn (barf-if-buffer-read-only) =2D (keep-lines-read-args "Keep lines (containing match for regexp): ")= )) + (keep-lines-read-args "Keep lines (containing match for regexp)"))) (if rstart (progn (goto-char (min rstart rend)) @@ -576,8 +582,8 @@ (unless (or (bolp) (eobp)) (forward-line 0)) (point-marker))) =2D (setq rstart (point) =2D rend (point-max-marker))) + (setq rstart (if current-prefix-arg (point-min) (point)) + rend (if current-prefix-arg (point-marker) (point-max-marker)))) (goto-char rstart)) (save-excursion (or (bolp) (forward-line 1)) @@ -620,9 +626,10 @@ =20 Interactively, in Transient Mark mode when the mark is active, operate on the contents of the region. Otherwise, operate from point to the =2Dend of (the accessible portion of) the buffer. When calling this functi= on =2Dfrom Lisp, you can pretend that it was called interactively by passing =2Da non-nil INTERACTIVE argument. +end of (the accessible portion of) the buffer (or its beginning if a prefix +argument is provided). +When calling this function from Lisp, you can pretend that it was called +interactively by passing a non-nil INTERACTIVE argument. =20 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 @@ -631,7 +638,7 @@ (interactive (progn (barf-if-buffer-read-only) =2D (keep-lines-read-args "Flush lines (containing match for regexp): "= ))) + (keep-lines-read-args "Flush lines (containing match for regexp)"))) (if rstart (progn (goto-char (min rstart rend)) @@ -639,8 +646,8 @@ (if (and interactive transient-mark-mode mark-active) (setq rstart (region-beginning) rend (copy-marker (region-end))) =2D (setq rstart (point) =2D rend (point-max-marker))) + (setq rstart (if current-prefix-arg (point-min) (point)) + rend (if current-prefix-arg (point-marker) (point-max-marker)))) (goto-char rstart)) (let ((case-fold-search (and case-fold-search (isearch-no-upper-case-p regexp t)))) @@ -668,14 +675,16 @@ =20 Interactively, in Transient Mark mode when the mark is active, operate on the contents of the region. Otherwise, operate from point to the =2Dend of (the accessible portion of) the buffer. +end of (the accessible portion of) the buffer (or its beginning if a +prefix argument is provided). =20 This function starts looking for the next match from the end of the previous match. Hence, it ignores matches that overlap a previously found match." =20 (interactive =2D (keep-lines-read-args "How many matches for (regexp): ")) + (keep-lines-read-args "How many matches for (regexp)")) + (save-excursion (if rstart (progn @@ -684,8 +693,8 @@ (if (and interactive transient-mark-mode mark-active) (setq rstart (region-beginning) rend (region-end)) =2D (setq rstart (point) =2D rend (point-max))) + (setq rstart (if current-prefix-arg (point-min) (point)) + rend (if current-prefix-arg (point) (point-max)))) (goto-char rstart)) (let ((count 0) opoint --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable =2D-=20 | Micha=EBl `Micha' Cadilhac | In a World without Walls and Fence= s, | | http://michael.cadilhac.name | who needs Windows and Gates? = | | JID/MSN: | -- Dino Esposito = | `---- michael.cadilhac@gmail.com | - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.6 (GNU/Linux) iD8DBQFG9+D3UJhDmOfFA3URAungAKDCVP8Q8i48hQrmrokZJLGmf1mstQCgtO5a dWvWamEQLLPec1eKw6ukX6U= =W2DU -----END PGP SIGNATURE----- --==-=-=-- --===============0492321331== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0492321331==--