unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to do write-region, but modify
@ 2014-10-25 14:58 Marcin Borkowski
  2014-10-25 18:44 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Marcin Borkowski @ 2014-10-25 14:58 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I'd like to have a variant of write-region, which (instead of saving to
a file) "saves" the region to a temporary buffer and lets me change it
somehow there.

What I'm doing now is something like this:

--8<---------------cut here---------------start------------->8---
(let ((text (buffer-substring beg end)))
  (with-temp-buffer
    (insert text)
    (do-some manipulation)
    (write-region (point-min) (point-max) filename)))
--8<---------------cut here---------------end--------------->8---

This feels not optimal, since the text is copied twice (once to the
variable `text' and then to the temporary buffer).

Any suggestions on how to improve this code?

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



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

end of thread, other threads:[~2014-10-25 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-25 14:58 How to do write-region, but modify Marcin Borkowski
2014-10-25 18:44 ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).