From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.help Subject: Re: Select/highlight and *copy* matches of some regex Date: Tue, 28 Jun 2022 10:10:29 +0530 Message-ID: <87fsjpxuwy.fsf@gmail.com> 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; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12814"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: fatiparty--- To: Joost Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 28 20:47:55 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 1o6GFe-00035v-Q1 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 20:47:54 +0200 Original-Received: from localhost ([::1]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o6GFd-0006ZG-JY for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 14:47:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o631n-0005UT-8R for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 00:40:43 -0400 Original-Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o631l-0006Uc-N0 for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 00:40:42 -0400 Original-Received: by mail-pf1-x442.google.com with SMTP id c205so10910883pfc.7 for ; Mon, 27 Jun 2022 21:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=DLi7MZt7jePvEq7j/RS+FtJ1yYQtuVygDmQjIGVnpgY=; b=dI7QYKUwpB7gulTQxnzFN3zhLgFz5ALTjAEM+H7uSfs6g49MoEou9QvJhEtgIod/8Z 6xeds6bqhcEX7r9Adfuv99KeM1MQXLn6P6B+Rob9eYhaq78LBFqCDLwPTy7lkmoAtu+A trrCBzQM4bVkRRgQm0sxmy4ERZPZbJrX/hAU+a71m8IdpRd1DKPoBHrtkMW6+BD1CdwM 2YsaNxlC2LkAXrcZxepTnBKyXwd4qnxnP8JNbH6+VYIMY7co7WS01t79Y/eTghvbmz4q +4h1y2lsoODawS2C4A9rYH8P7sRIejc2MLMXvGI2m5n3mCEvWg3j5kHyLdyO+CRGNQzH hZmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=DLi7MZt7jePvEq7j/RS+FtJ1yYQtuVygDmQjIGVnpgY=; b=7eorYQMKYDZ+oCsIGD1TyOxbhBxUJKBO/9/dsRkN6pL4rcI2HGJJCjdmqdCWc2ys9p hB2v9beM2f+YXZ9nwaWOdl7cPf+o3cs2XoHSkIXp35TfsYPmrrIHiMF6gGktRPMP0X2+ 5xmWATMzfgka8EawTfn02feUVVYOc/FyE9s1GB4rQsp0DUuLAhF9Nu8PMTWZ1OcqEgo6 GkoP/2ariHfJiDWwIWK/zFlNRl3Ol1GfUgA2X4kug4RHERRZjeu1iBYVd96kVpxf1Qib 4H3mVdQGoUDIu8KIL6hom4N76A3Kk2/3Ha72jD/qaq4jaHb8D2RUGFWvBB8ezpHtvJ7r BD2Q== X-Gm-Message-State: AJIora8d84rmgo7fZx0uROpL2ynRuOX7ndn/AqIuzUi4qVsa+MxAuQZz fR7sd2IVIdhpZoMYcpfeTdPO/BEGoks= X-Google-Smtp-Source: AGRyM1uV1xqswIH/UxfVur2VAkrcUJZB1Offeg+TJ8IJmFbtBjdHBHJqbkgfaKv4oZ1riVH7hA/C7g== X-Received: by 2002:aa7:810d:0:b0:525:1345:2a3 with SMTP id b13-20020aa7810d000000b00525134502a3mr1523486pfi.24.1656391239956; Mon, 27 Jun 2022 21:40:39 -0700 (PDT) Original-Received: from localhost ([49.204.130.72]) by smtp.gmail.com with ESMTPSA id k11-20020a6555cb000000b0040d87299ca3sm7817912pgs.54.2022.06.27.21.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:40:39 -0700 (PDT) In-Reply-To: <8543a730-b78f-491f-a3a9-66e23034f0d9@www.fastmail.com> (Joost's message of "Mon, 27 Jun 2022 19:16:27 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=visuweshm@gmail.com; helo=mail-pf1-x442.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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-Mailman-Approved-At: Tue, 28 Jun 2022 14:44:57 -0400 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:138172 Archived-At: [=E0=AE=A4=E0=AE=BF=E0=AE=99=E0=AF=8D=E0=AE=95=E0=AE=B3=E0=AF=8D =E0=AE=9C= =E0=AF=82=E0=AE=A9=E0=AF=8D 27, 2022] Joost wrote: > 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 somet= hing like this: > > ``` > blah blah lang=3Den bla > lang=3Dde > lang=3Dfr blah blah > blah lang=3Dpt > ``` > > The part I'm interested in is "lang=3Dxx", 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 isearc= h, but there doesn't seem to be a straightforward way to copy or kill them.= .. I wonder if you can use C-u M-s o for the job. I did=20 C-u M-s o lang=3D.. then it produced a buffer with the contents lang=3Den lang=3Dde lang=3Dfr lang=3Dpt