From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Angus Comber Newsgroups: gmane.emacs.help Subject: How to do search and replace with a lookup Date: Mon, 11 Dec 2017 00:49:47 -0800 (PST) Message-ID: <2a6008be-da30-401d-b48f-da36884bafbd@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1512982229 21613 195.159.176.226 (11 Dec 2017 08:50:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 11 Dec 2017 08:50:29 +0000 (UTC) Injection-Date: Mon, 11 Dec 2017 08:49:47 +0000 User-Agent: G2/1.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 11 09:50:26 2017 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 1eOJn7-0005LU-LG for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Dec 2017 09:50:25 +0100 Original-Received: from localhost ([::1]:51764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOJnE-0001BD-UI for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Dec 2017 03:50:32 -0500 X-Received: by 10.200.47.57 with SMTP id j54mr15682195qta.18.1512982187567; Mon, 11 Dec 2017 00:49:47 -0800 (PST) X-Received: by 10.31.162.19 with SMTP id l19mr2118533vke.4.1512982187315; Mon, 11 Dec 2017 00:49:47 -0800 (PST) Original-Path: usenet.stanford.edu!m31no2762233qtf.0!news-out.google.com!v55ni2199qtc.0!nntp.google.com!g35no2757474qtk.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.194.194.72; posting-account=SYwseQoAAABBYGT-AD1YXrcTXHxLkDZy Original-NNTP-Posting-Host: 80.194.194.72 Original-Xref: usenet.stanford.edu gnu.emacs.help:221218 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:115331 Archived-At: I have log file output like this: Received device state message: pen state = 11 - uig state 10 where pen state and uig state are enums. I want to do a search and replace where if for example pen state 11 enum is diagnostics and uig state 10 enum is starting, then I want the line to be updated to: Received device state message: pen state = diagnostics - uig state starting What is the easiest way to do this? I can do search and replace using c-m-% and change for each permutation of number to string but that would be fairly labour intensive if enums were fairly long. Can I combine that with a lookup somehow? What is best way to do it?