From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: How to copy current buffer to a temporary buffer
Date: Fri, 16 May 2014 09:59:12 +0200 [thread overview]
Message-ID: <87y4y2cfxr.fsf@Equus.Decebal.nl> (raw)
I want to copy the current buffer to a temporary buffer, to do some
edits on it. (Converting a text file to a html file.)
The following works:
(defun make-html-file ()
(interactive)
(let ((buffer-name (generate-new-buffer-name "tempori.html")))
(copy-region-as-kill (point-min) (point-max))
(switch-to-buffer buffer-name)
(html-mode)
(yank)))
But the ‘problem’ is that this adds your current buffer to the kill
ring. That is a side effect that should be circumvented.
So I tried the following:
(defun make-html-file ()
(interactive)
(let ((buffer-name (generate-new-buffer-name "tempori.html"))
(old-buffer (current-buffer)))
(switch-to-buffer buffer-name)
(auto-fill-mode 0)
(insert-buffer-substring old-buffer)
(html-mode)))
The problem is that this formats the lines and because of this the
regular expressions that are used for the converting do not work
anymore. How can I write the function in such a way that it does not
add to the kill ring, without the lines being formatted?
I could of-course use:
(pop kill-ring)
in the first function, but could the second function made to work?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
next reply other threads:[~2014-05-16 7:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 7:59 Cecil Westerhof [this message]
2014-05-16 9:31 ` How to copy current buffer to a temporary buffer Pascal J. Bourguignon
2014-05-16 10:13 ` Eli Zaretskii
[not found] ` <mailman.1456.1400235243.1147.help-gnu-emacs@gnu.org>
2014-05-16 11:49 ` Cecil Westerhof
2014-05-16 18:22 ` Pascal J. Bourguignon
2014-05-16 19:05 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y4y2cfxr.fsf@Equus.Decebal.nl \
--to=cecil@decebal.nl \
--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.
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).