From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.emacs.help Subject: How to copy current buffer to a temporary buffer Date: Fri, 16 May 2014 09:59:12 +0200 Organization: Decebal Computing Message-ID: <87y4y2cfxr.fsf@Equus.Decebal.nl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1400227526 8870 80.91.229.3 (16 May 2014 08:05:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 May 2014 08:05:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 16 10:05:22 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WlD8q-0002r7-K3 for geh-help-gnu-emacs@m.gmane.org; Fri, 16 May 2014 10:05:20 +0200 Original-Received: from localhost ([::1]:34001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlD8q-0001mt-5A for geh-help-gnu-emacs@m.gmane.org; Fri, 16 May 2014 04:05:20 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!rt.uk.eu.org!feed.xsnews.nl!border01.ams.xsnews.nl!feeder02.ams.xsnews.nl!feeder03.ams.xsnews.nl!frontend-F10-04.ams.news.kpn.nl Original-Newsgroups: gnu.emacs.help X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:kpeORcjEuAgD+mz7IBKFlxun7r8= Original-Lines: 39 Original-NNTP-Posting-Host: 77.171.42.144 Original-X-Trace: 1400227211 news.kpn.nl 28208 77.171.42.144@kpn/77.171.42.144:60244 Original-Xref: usenet.stanford.edu gnu.emacs.help:205423 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97691 Archived-At: 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