From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: How to do write-region, but modify
Date: Sat, 25 Oct 2014 16:58:22 +0200 [thread overview]
Message-ID: <877fzo5h81.fsf@wmi.amu.edu.pl> (raw)
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
next reply other threads:[~2014-10-25 14:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 14:58 Marcin Borkowski [this message]
2014-10-25 18:44 ` How to do write-region, but modify Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877fzo5h81.fsf@wmi.amu.edu.pl \
--to=mbork@wmi.amu.edu.pl \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.