From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: buffer is modified after commit Date: Thu, 14 Feb 2008 09:57:26 -0500 Message-ID: References: <47B3639E.9070007@gmx.at> <47B3F384.6080809@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203001073 22720 80.91.229.12 (14 Feb 2008 14:57:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Feb 2008 14:57:53 +0000 (UTC) Cc: Juanma Barranquero , Richard Sharman , Emacs Devel To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 14 15:58:16 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JPfXH-0001aJ-Ix for ged-emacs-devel@m.gmane.org; Thu, 14 Feb 2008 15:58:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JPfWn-0006kq-LW for ged-emacs-devel@m.gmane.org; Thu, 14 Feb 2008 09:57:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JPfWk-0006jO-BI for emacs-devel@gnu.org; Thu, 14 Feb 2008 09:57:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JPfWi-0006j0-Pb for emacs-devel@gnu.org; Thu, 14 Feb 2008 09:57:29 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JPfWi-0006ix-Ms for emacs-devel@gnu.org; Thu, 14 Feb 2008 09:57:28 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JPfWi-00025x-9U for emacs-devel@gnu.org; Thu, 14 Feb 2008 09:57:28 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAMfls0fO+IZjdGdsb2JhbACQQAEwniR/ X-IronPort-AV: E=Sophos;i="4.25,352,1199682000"; d="scan'208";a="14483392" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 14 Feb 2008 09:57:27 -0500 Original-Received: from pastel.home ([206.248.134.99]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id UQT36327; Thu, 14 Feb 2008 09:57:27 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 72BFE80A4; Thu, 14 Feb 2008 09:57:26 -0500 (EST) In-Reply-To: <47B3F384.6080809@gmx.at> (martin rudalics's message of "Thu, 14 Feb 2008 08:53:40 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:89079 Archived-At: >> edit >> save >> rotate >> edit >> save >> undo undo undo... > Maybe define > (defun restore-buffer-unmodified-unless-saved (arg) > (when (or (and (not (buffer-file-name)) (not arg)) > (and (file-exists-p (buffer-file-name)) > (equal arg (nth 5 (file-attributes (buffer-file-name)))))) > (restore-buffer-modified nil))) > and add > (setq buffer-undo-list > (cons '(apply restore-buffer-unmodified-unless-saved > (when (and (buffer-file-name) > (file-exists-p (buffer-file-name))) > (nth 5 (file-attributes (buffer-file-name))))) > buffer-undo-list)) > to `highlight-changes-rotate-faces', but that would constitute yet > another ugly hack. > What's really needed is a new entry type for `buffer-undo-list' like the > (nil PROPERTY VALUE BEG . END) one but when applied not causing a change > in the buffer-modified status. There's no such need. The `apply' entry is all-powerful. What hilit-chg needs to do is something like: (defun hilit-chg-undo-nomodify (undo-list) (let ((modified (buffer-modified-p))) (while undo-list (setq undo-list (primitive-undo 1 undo-list))) (unless modified (restore-buffer-modified-p nil)))) and then use something like: (push (let* ((buffer-undo-list nil)) ...do your thing... `(apply 'hilit-chg-undo-nomodify ,buffer-undo-list)) buffer-undo-list) Of course, another option is to define a reverse function from (unrotate) and put that one on the undo-list (that's what I (try to) do with diff-reverse-direction, diff-context->unified, and diff-unified->context). Stefan