all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bulk replacement on region, buffer, file?
@ 2015-12-10  2:21 Tom Roche
  2015-12-10  3:21 ` Emanuel Berg
  2015-12-10 16:40 ` Bob Proulx
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Roche @ 2015-12-10  2:21 UTC (permalink / raw
  To: help-gnu-emacs


I would appreciate pointers to code that enables "bulk replacement" of numerous string tuples ({to-replace, replace-with}) in a single call. What I mean, why I ask:

I frequently scrape blocks of text from PDFs into Emacs text buffers. After I do so, I usually want to replace lots of strings in the buffer. E.g. (using '|' to delimit the strings),

|CO 2| -> |CO2|
|- | -> ||
|“| -> |"|
|”| -> |"|
|[weird unicodes used for bulleting]| -> |*|

which I do manually by calling `M-x replace-string` or similar interactive or regexp function. I'd prefer instead to call something that

1. could be called on a region (if selected) or buffer (if not)

2. could read from a user-editable property file of replacement tuples (like those above), similar to `abbrev_defs` but without some constraints of the latter that annoy in this usecase. E.g. (unless I'm missing something), I cannot use `abbrev` to replace the space-delimited 'CO 2' with 'CO2'.

3. would, for every {to-replace, replace-with} tuple in the file,

* if `to-replace` found, replace every instance with `replace-with`
* if `to-replace` not found, goto next tuple

Is there elisp to do this? Alternatively, pointers to non-elisp (that I could invoke on a buffer's file and then `revert-buffer`) would also be appreciated. (And, yes, I know this sounds easy to write, but I have other priorities at present and no wish to reinvent any well-working wheels.)

Apologies if this is a FAQ, but a brief websearch found nothing that looked useful.

TIA, Tom Roche <Tom_Roche@pobox.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-15  4:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1767.1449714096.31583.help-gnu-emacs@gnu.org>
2015-12-10  3:13 ` bulk replacement on region, buffer, file? Pascal J. Bourguignon
2015-12-15  4:16   ` Tom Roche
2015-12-10  2:21 Tom Roche
2015-12-10  3:21 ` Emanuel Berg
2015-12-10 16:40 ` Bob Proulx

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.