From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.help Subject: Re: Search and replace for a single file using a pattern file Date: Thu, 04 Jan 2018 11:28:42 +0100 Message-ID: <87y3ldapet.fsf@gmail.com> References: <240d8da5-5078-4ecc-a285-0719841d124a@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1515061643 6272 195.159.176.226 (4 Jan 2018 10:27:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 4 Jan 2018 10:27:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Angus Comber Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 04 11:27:19 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX2k1-00018J-PM for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Jan 2018 11:27:17 +0100 Original-Received: from localhost ([::1]:48177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX2lz-0006eK-E8 for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Jan 2018 05:29:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX2lW-0006eD-Ge for help-gnu-emacs@gnu.org; Thu, 04 Jan 2018 05:28:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eX2lS-0003xP-Iq for help-gnu-emacs@gnu.org; Thu, 04 Jan 2018 05:28:50 -0500 Original-Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:34999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eX2lS-0003vt-Bv for help-gnu-emacs@gnu.org; Thu, 04 Jan 2018 05:28:46 -0500 Original-Received: by mail-wm0-x230.google.com with SMTP id a79so2534643wma.0 for ; Thu, 04 Jan 2018 02:28:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:user-agent:mime-version; bh=wLO6Snrkk3p7jWxX46UsTRSIWBGmp3PV4dcWJ0GWolg=; b=mW+l+42w7U03j5nrBkIANdftInPMzG1zRZa9J64gs46DNGQgGpDcbxUD3ecv2FvP6J xjHlLQUf7fvSMUbw9fiyhxeujq14JznS7xFYHo+ymITCuCnsQcum8MZVXGcaNxnXl4xX zywdD1HR4XuLYyjeBHEjdaV+rKeqQgsRkHapHahCNmlXTT3Nb4pDu+9wL4BL7+hf5kPz HfeLWaFXlNx/rNQRBxPJxS4ZxRO25hoLYrk+FI4R2AVDRL7znGZsyyqCeKSXvkk4R4/+ WzvFhRCiXnnFSAXXi5Rc622z4CYWq7IkwwWVBccE42BpzOLIE/as3Lkd9KeWFlqK2LAk fzdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:user-agent :mime-version; bh=wLO6Snrkk3p7jWxX46UsTRSIWBGmp3PV4dcWJ0GWolg=; b=nJxEJFa9fYBPqn9SGy4HuHcz+VlyEpS/WDaJUTnPY+Y+JKMGPVuw2OCgTwJec2uOln zt9VtKjhWX0Vfq1nTOnCnbLFlF1JOXcgGg1BfoesmHFYd/LzAldJCYhu30Atg8XpQNQ9 C2iuF7G5NJQnguIw0y3wQucTK0Sb1ykjarkvCnXJXAzZmUkrYC3OpcBn39diHcOMb/ju rKlpl8fI+J7NevR41p+zU1T5VofGOsE+oniu6zPksItObJIzgbnzzDXfl9aGoiJUXlrw Y2FeH28BjkHZFEYjGcsGsrR6NDkiMg1sqTQmkymC6n379cqPWVuw7jyYeUhIOjysoJrg XMzg== X-Gm-Message-State: AKGB3mLUkwWhrLJTi0NWDFpxUD58b1vJ1jlL6xY076W8JLjzae49M4kR sYAKY+n7mDGtvg6iiVATNXOgnnZ5 X-Google-Smtp-Source: ACJfBounvdkdoCOakE6jq+p4+wHnU57acywnWvdg5cu1bJSye0xSlIPHGuMYoa68jg8BevSALJTt3g== X-Received: by 10.80.214.139 with SMTP id r11mr6794708edi.17.1515061724625; Thu, 04 Jan 2018 02:28:44 -0800 (PST) Original-Received: from rpluim ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id t19sm1814801edh.49.2018.01.04.02.28.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jan 2018 02:28:43 -0800 (PST) Gmane-Reply-To-List: yes In-Reply-To: <240d8da5-5078-4ecc-a285-0719841d124a@googlegroups.com> (Angus Comber's message of "Thu, 4 Jan 2018 02:02:29 -0800 (PST)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::230 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115567 Archived-At: Angus Comber writes: > I have some horrible logs where integers are printed for states and > I want to do a global search and replace on the file to eg replace > integer x with a string. > > I can obviously do individually using c-m-% but that is fairly > laborious. So use of a search and replace mapping in a text file > would be really convenient. > > Is this possible? any suggestions? Which bit is laborious? The query portion of C-M-%? You can hit ! after the first match, or else do M-: (replace-string "from" "to") multiple times (or wrap that in a function over your list of replacements) Robert