From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Parker, Matthew" Newsgroups: gmane.emacs.help Subject: RE: Remove all lines containig a keyword Date: Fri, 3 Oct 2008 10:06:49 -0400 Message-ID: <9E067A1AECCB154485D4CF7E4BEF4D8E0A154A8C@post07.corp.seic.com> References: <9884393F63F8AF4EA99527DC3C9141E22DD51C@zw67246c.societe.mma.fr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223042880 20272 80.91.229.12 (3 Oct 2008 14:08:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Oct 2008 14:08:00 +0000 (UTC) To: "Bourgneuf Francois" , "Chris Patterson" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 03 16:08:56 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KllKQ-0008D5-Fg for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Oct 2008 16:08:22 +0200 Original-Received: from localhost ([127.0.0.1]:59978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KllJN-0000Tm-65 for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Oct 2008 10:07:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KllJ3-0000Tc-CT for help-gnu-emacs@gnu.org; Fri, 03 Oct 2008 10:06:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KllJ2-0000TJ-Jq for help-gnu-emacs@gnu.org; Fri, 03 Oct 2008 10:06:56 -0400 Original-Received: from [199.232.76.173] (port=49663 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KllJ2-0000TG-HC for help-gnu-emacs@gnu.org; Fri, 03 Oct 2008 10:06:56 -0400 Original-Received: from exprod5og102.obsmtp.com ([64.18.0.143]:49268) by monty-python.gnu.org with smtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KllJ1-0007Qv-Pm for help-gnu-emacs@gnu.org; Fri, 03 Oct 2008 10:06:56 -0400 Original-Received: from source ([12.20.48.151]) (using TLSv1) by exprod5ob102.postini.com ([64.18.4.12]) with SMTP; Fri, 03 Oct 2008 07:06:51 PDT Original-Received: from tm.mx1.seic.com ([192.168.0.81]) by ms.mx1.seic.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 3 Oct 2008 10:06:50 -0400 Original-Received: from POST01.corp.seic.com ([10.40.40.211]) by tm.mx1.seic.com with InterScan Messaging Security Suite; Fri, 03 Oct 2008 10:06:50 -0400 Original-Received: from post07.corp.seic.com ([10.40.40.217]) by POST01.corp.seic.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 3 Oct 2008 10:06:49 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message In-Reply-To: <9884393F63F8AF4EA99527DC3C9141E22DD51C@zw67246c.societe.mma.fr> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Remove all lines containig a keyword Thread-Index: Ackj0OF8T2v52pjhQb+yNLOvC3+9oABjeyRwAAB8PAA= X-OriginalArrivalTime: 03 Oct 2008 14:06:49.0980 (UTC) FILETIME=[47956BC0:01C92561] X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:58328 Archived-At: Hide-lines.el is also useful http://www.emacswiki.org/cgi-bin/wiki/hide-lines.el from the commentary... ;; Now, when you type C-c h, you will be prompted for a regexp ;; (regular expression). All lines matching this regexp will be ;; hidden in the buffer. ;;=20 ;; Alternatively, you can type C-u C-c h (ie. provide a prefix ;; argument to the hide-lines command) to hide all lines that *do not* ;; match the specified regexp. ;;=20 ;; If you want to make all of the hidden areas re-appear again, type: ;; M-x show-all-invisible ;; Or you can bind show-all-invisible to a key and use that to show ;; all the hidden areas again. And from the emacs manual... 20.10 Other Search-and-Loop Commands =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Here are some other commands that find matches for a regular expression. They all ignore case in matching, if the pattern contains no upper-case letters and `case-fold-search' is non-`nil'. Aside from `occur' and its variants, all operate on the text from point to the end of the buffer, or on the active region in Transient Mark mode. `M-x occur REGEXP ' Display a list showing each line in the buffer that contains a match for REGEXP. To limit the search to part of the buffer, narrow to that part (*note Narrowing::). A numeric argument N specifies that N lines of context are to be displayed before and after each matching line. Currently, `occur' can not correctly handle multiline matches. The buffer `*Occur*' containing the output serves as a menu for finding the occurrences in their original context. Click `Mouse-2' on an occurrence listed in `*Occur*', or position point there and type ; this switches to the buffer that was searched and moves point to the original of the chosen occurrence. `o' and `C-o' display the match in another window; `C-o' does not select it. After using `M-x occur', you can use `next-error' to visit the occurrences found, one by one. *Note Compilation Mode::. `M-x list-matching-lines' Synonym for `M-x occur'. `M-x multi-occur BUFFERS REGEXP ' This function is just like `occur', except it is able to search through multiple buffers. It asks you to specify the buffer names one by one. `M-x multi-occur-in-matching-buffers BUFREGEXP REGEXP ' This function is similar to `multi-occur', except the buffers to search are specified by a regular expression that matches visited file names. With a prefix argument, it uses the regular expression to match buffer names instead. `M-x how-many REGEXP ' Print the number of matches for REGEXP that exist in the buffer after point. In Transient Mark mode, if the region is active, the command operates on the region instead. `M-x flush-lines REGEXP ' This command deletes each line that contains a match for REGEXP, operating on the text after point; it deletes the current line if it contains a match starting after point. In Transient Mark mode, if the region is active, the command operates on the region instead; it deletes a line partially contained in the region if it contains a match entirely contained in the region. If a match is split across lines, `flush-lines' deletes all those lines. It deletes the lines before starting to look for the next match; hence, it ignores a match starting on the same line at which another match ended. `M-x keep-lines REGEXP ' This command deletes each line that _does not_ contain a match for REGEXP, operating on the text after point; if point is not at the beginning of a line, it always keeps the current line. In Transient Mark mode, if the region is active, the command operates on the region instead; it never deletes lines that are only partially contained in the region (a newline that ends a line counts as part of that line). If a match is split across lines, this command keeps all those lines. Matthew Parker SEI | 1 Freedom Valley Drive | Oaks, PA 19456 | p: 610-676-1279 | f: = 484-676-1279 | www.seic.com -----Original Message----- From: help-gnu-emacs-bounces+mparker=3Dseic.com@gnu.org = [mailto:help-gnu-emacs-bounces+mparker=3Dseic.com@gnu.org] On Behalf Of = Bourgneuf Francois Sent: Friday, October 03, 2008 9:54 AM To: Chris Patterson; help-gnu-emacs@gnu.org Subject: RE: Remove all lines containig a keyword C-M-% .*sold.*C-q C-j Enter ! I explain : C-M-% : query-replace-regexp .*sold.*C-q C-j : 0-n character followed by "sold" followed by 0-n = character followed by NEWLINE ( C-q C-j ) Bour9 > -----Message d'origine----- > De :=20 > help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.fr@gnu.or > g=20 > [mailto:help-gnu-emacs-bounces+francois.bourgneuf=3Dgroupe-mma.f > r@gnu.org] De la part de Chris Patterson > Envoy=E9 : lundi 29 septembre 2008 04:46 > =C0 : help-gnu-emacs@gnu.org > Objet : Re: Remove all lines containig a keyword >=20 > Christian Herenz writes: >=20 > > Hi, > > I have a huge list of "stuff" I sell / sold. > > To print out an actual list, without the stuff that is sold already, > > It would be nice to have a command for doing this task automated - > > Remove all lines with the keyword "sold". > > Thanks for your Help, > > Christian >=20 > Looks like you have several suggestions. I'll chime in with M-x > flush-lines. >=20 >=20