From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Daniel_Mart=C3=ADn?= Newsgroups: gmane.emacs.help Subject: Re: Select/highlight and *copy* matches of some regex Date: Tue, 28 Jun 2022 11:29:51 +0200 Message-ID: References: <82a978f3-e974-4d8f-b87e-5707ffec0b5b@www.fastmail.com> <8543a730-b78f-491f-a3a9-66e23034f0d9@www.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5570"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (darwin) Cc: fatiparty--- To: Joost Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 28 11:43:59 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o67lH-0001I7-IU for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 11:43:59 +0200 Original-Received: from localhost ([::1]:51826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o67lG-00012l-IT for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 05:43:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o67Xr-00032p-3X for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 05:30:07 -0400 Original-Received: from sonic312-25.consmr.mail.ir2.yahoo.com ([77.238.178.96]:46265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o67Xl-0006PF-04 for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 05:30:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1656408596; bh=YcF8FYtvilxEUF6jyyABZzXJ87DQ+mziX40EPgyIf4Q=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=rGahHTccpfCI5AoJ0h8FQMtp0ui54agZn9JORomIMj4C05ZzDv7GfGNDiiBn3vPjNkEDeSonvyy2CRlKEi1FWxDTLxeC1Y2SGGJtxi8brHlTTKl/sqWfHXUa61T0UDM1+WoLE+KF6RbBWYNhpM8B/hBmfL/GEY9Qzh+OkoHoZb1+EV+Pw+tCRXvqZ2msTjc8WvyhpfqRCS2cDolCogxKjcz8FwOlhZprnhRmoEazO9l2P3CNNe1hYhxOL/Er6z17nB7Qd2qfZkR3jYOh3WJ1T3vxRsychbGdM+6KNgCjpUEdHhp2XPvZ6P3kIBmtqp+ZfVJbzYBh5K7IM8pcfiGBlw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1656408596; bh=fmynN+WXz08/xzGehP1kehbvThLxN5NRz/rxGurZp4q=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=EbpQkCN+YbHOJEnLhO8aSp3yqwXCm28qjcbqCWOQmJIaqXoslaVJsTDzXIS+T20WHmMssOnI56OmmkTkoYvc8RL1YqDopC9JXFKv5PUsEsWI+EOzaiZ1KacjhNc2v+ODVqNTXIiEFbY2UXDDn8FXdxa4z7W9kvbOuEaf01UIvOyyznhSoo+0Qfl1jEnX0zrkt/3ea2I64FLbB2jFeZelGar6gmhdGMavdgopPi+XCAyp7PUNLmLB0Z3VICH9xWB7+tZQgsEtgFR/0kGPTe1uEayPjmCAd550Nrmc14Q1x+I+gGOnXj1B9JTUA8USI7X4HTo6wMGb9lRtMdsXMA6ldQ== X-YMail-OSG: wrZZPqwVM1lIdUv87PCS3A4Q40kcK7SQXMeyBdeHRHghKs0BGFd4YdOBOuG7Pj_ HctUN_Bw.bxcq_4VY1bW2LbmsHoZIV7Cx.7kDjxM9nPTXIaPWwIivIpy5BDSjnQBcYZDk6fI5Jty 7Rs8kQ5xy55nbuYStkU_wOKLzTCTxfvuPMhrQP4sCVSZYjBHI4L.mo9urSrA0lrH35ycETakJcCg Ti7MGcGX5YV_1bT95_5JAk3htMHrKFt2.UTu8ZTC9M1KKhCLMJSPVxMk5hDcijtHnOActfDYFW_3 zOsi0AjSfHNSbTKVGB8IH9xY5KspST8EJcUEgqYi.c0pOSiJkHr8_.K5u2WObZxRysnUi0YIFAXb 3efBK9LHZKlnjEHXsQcBTf8uYVs64C0rzbm5dFAy05s_MH6rV9ndAXaQfTisFSLBZyJqiwGar0uY i6RxaqRtlqG9vITOI1z7frfjeyzsMv2.kTbAkNtahIWrxmnvRUIGeg8pE2pbG_MM6nkNURNkqpZI D35sPJb99DK6KPFQd2rUiB5QyhjloXW.KFkwyDPV8ci6cVeaFrSXkfJ3hNEXxnk2fOjWWlKGYAaz JRN2gBvnzueqvwPDtV4yXfsx.wICNZs2PFNH_05cogWQMQIe3NXXC93XdNd86sjTfh3ZMiWLFkpK _93FpXKC4eNa7.CLQUvhp0Yxq9x3LZzC7vmBsAWL59zgJwm81hLj9gcbdIR6B385y3fh4HpChBcH 6BFdFC6AOX.ah0EgbxuhSdIKK3D7pJJ46btgaZ5zLpscr5bsLHYZnav60pAqr.Moz6aRce0k2A6m 7vGtE5RqJFsTx3kcQuY0gbUpJMV74vjUMo7mBxOHi_ X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ir2.yahoo.com with HTTP; Tue, 28 Jun 2022 09:29:56 +0000 Original-Received: by hermes--canary-production-ir2-c9bf9d9bc-xch2h (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6c3c40b9a2cf5c33b359b957f9ff2ef9; Tue, 28 Jun 2022 09:29:52 +0000 (UTC) In-Reply-To: <8543a730-b78f-491f-a3a9-66e23034f0d9@www.fastmail.com> (Joost's message of "Mon, 27 Jun 2022 19:16:27 +0200") X-Mailer: WebService/1.1.20280 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=77.238.178.96; envelope-from=mardani29@yahoo.es; helo=sonic312-25.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138152 Archived-At: Joost writes: > On Mon, 27 Jun 2022, at 18:12, tomas@tuxteam.de wrote: >> Not a direct answer to your question, but perhaps similar. If you >> can live with selecting /lines/ containing a match, there's "occur" >> (M-x occur). > > Sorry, I meant to mention that, but I forgot. No, selecting lines is not an option, because it's the non-matching parts of each line that I'm trying to get rid of. > > In my particular use case, I'm trying to clean up a file that looks something like this: > > ``` > blah blah lang=en bla > lang=de > lang=fr blah blah > blah lang=pt > ``` > > The part I'm interested in is "lang=xx", the rest needs to be > removed. Each line contains this part (with different language codes), > but may contain more text, which is irrelevant to me. There's no > pattern to the irrelevant part, it can basically be any text. > > I can highlight them with `highlight-regexp`, search for them with isearch, but there doesn't seem to be a straightforward way to copy or kill them... You can pass the universal argument to occur to only show the matches for the regexp, excluding the rest of the line. For example: C-u C-s REGEXP C-u M-s o This will show an *Occur* buffer with only the matching parts of REGEXP in the current buffer, which you can save to a file, etc.