From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: How to copy current buffer to a temporary buffer Date: Fri, 16 May 2014 20:22:43 +0200 Organization: Informatimago Message-ID: <878uq1k2h8.fsf@kuiper.lan.informatimago.com> References: <87y4y2cfxr.fsf@Equus.Decebal.nl> <87ha4qjci7.fsf@kuiper.lan.informatimago.com> <87ppjec5ar.fsf@Equus.Decebal.nl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400264729 5522 80.91.229.3 (16 May 2014 18:25:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 May 2014 18:25:29 +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 20:25:24 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 1WlMou-0001JK-4s for geh-help-gnu-emacs@m.gmane.org; Fri, 16 May 2014 20:25:24 +0200 Original-Received: from localhost ([::1]:37248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlMot-0001BX-L2 for geh-help-gnu-emacs@m.gmane.org; Fri, 16 May 2014 14:25:23 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-X-Trace: individual.net 3A/TvkIP387AYJlmTJJCxg6brZIfbLisnrtHGDOI9zwbVfDLDe Cancel-Lock: sha1:YzNkMDAwZjAyNGQwYzdiNTM1YmVmMjc2OGI0ZTA5YzhjNDIyYjUwOA== sha1:GgqRHcXqUeFK5HLBjA78FXFfwkk= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:205449 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:97717 Archived-At: Cecil Westerhof writes: > Op Friday 16 May 2014 12:13 CEST schreef Eli Zaretskii: > >>> From: "Pascal J. Bourguignon" >>> Date: Fri, 16 May 2014 11:31:28 +0200 >>> >>> Cecil Westerhof writes: >>> >>>> 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.) >>> >>> >>> (let ((contents (buffer-substring (point-min) (point-max)))) >>> (with-temp-buffer >>> (insert contents) >>> (do-something))) >> >> I think using the insert-buffer function will make this more >> efficient (since no string needs to be consed, something that might >> not be trivial with large buffers). Oops, I knew I was missing something. > I used insert-buffer earlier on, but that formatted the lines and that > is not acceptable. You can do this then: (let ((source-buffer (current-buffer))) (with-temp-buffer (insert-buffer source-buffer) (set-text-properties (point-min) (point-max) '()) (do-something))) -- __Pascal Bourguignon__ http://www.informatimago.com/ "Le mercure monte ? C'est le moment d'acheter !"