From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Reverting but keeping undo Date: Wed, 15 May 2013 12:38:40 +0200 Message-ID: <87mwrwede7.fsf@wanadoo.es> 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 1368614350 31712 80.91.229.3 (15 May 2013 10:39:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 May 2013 10:39:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 15 12:39:10 2013 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 1UcZ6y-00080e-A7 for geh-help-gnu-emacs@m.gmane.org; Wed, 15 May 2013 12:39:08 +0200 Original-Received: from localhost ([::1]:39150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcZ6x-0006fJ-UA for geh-help-gnu-emacs@m.gmane.org; Wed, 15 May 2013 06:39:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcZ6o-0006fA-5S for help-gnu-emacs@gnu.org; Wed, 15 May 2013 06:38:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcZ6j-0006ie-2v for help-gnu-emacs@gnu.org; Wed, 15 May 2013 06:38:58 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:41581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcZ6i-0006iK-SB for help-gnu-emacs@gnu.org; Wed, 15 May 2013 06:38:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UcZ6h-0007pc-My for help-gnu-emacs@gnu.org; Wed, 15 May 2013 12:38:51 +0200 Original-Received: from 149.red-83-40-116.dynamicip.rima-tde.net ([83.40.116.149]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 May 2013 12:38:51 +0200 Original-Received: from ofv by 149.red-83-40-116.dynamicip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 May 2013 12:38:51 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 23 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 149.red-83-40-116.dynamicip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:Frn1hMXd2oZYeyFIpKoqtmGrox8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:90802 Archived-At: `revert-buffer' discards undo history. I can understand that undo history might be in conflict with the new contents of the buffer. How dangerous is that? Apart from that, what could be wrong with using the recipe published in http://www.emacswiki.org/emacs/RevertBuffer#toc4 ? For your convenience, this is the recipe: (defun revert-buffer-keep-undo (&rest -) "Revert buffer but keep undo history." (interactive) (let ((inhibit-read-only t)) (erase-buffer) (insert-file-contents (buffer-file-name)) (set-visited-file-modtime (visited-file-modtime)) (set-buffer-modified-p nil))) Install in command ‘revert-buffer’ with (setq revert-buffer-function 'revert-buffer-keep-undo)