From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Rogers Newsgroups: gmane.emacs.devel Subject: Re: *vc-diff* keeps undo information Date: Sat, 3 Jun 2006 14:07:21 -0400 Message-ID: <17537.53209.582665.610494@rgrjr.dyndns.org> References: <17535.23719.576201.366323@rgrjr.dyndns.org> <87bqtbj4b9.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1149358062 23243 80.91.229.2 (3 Jun 2006 18:07:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 3 Jun 2006 18:07:42 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 03 20:07:40 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FmaXB-0006jQ-G3 for ged-emacs-devel@m.gmane.org; Sat, 03 Jun 2006 20:07:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FmaXB-0007kS-07 for ged-emacs-devel@m.gmane.org; Sat, 03 Jun 2006 14:07:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FmaWy-0007gT-Sr for emacs-devel@gnu.org; Sat, 03 Jun 2006 14:07:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FmaWx-0007dK-6D for emacs-devel@gnu.org; Sat, 03 Jun 2006 14:07:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FmaWw-0007dH-Un for emacs-devel@gnu.org; Sat, 03 Jun 2006 14:07:22 -0400 Original-Received: from [24.128.218.106] (helo=rgrjr.dyndns.org) by monty-python.gnu.org with smtp (Exim 4.52) id 1Fmadg-0007TU-Su for emacs-devel@gnu.org; Sat, 03 Jun 2006 14:14:21 -0400 Original-Received: (qmail 6610 invoked by uid 500); 3 Jun 2006 18:07:21 -0000 Original-To: Thien-Thi Nguyen In-Reply-To: X-Mailer: VM 7.19 under Emacs 22.0.50.1 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:55670 Archived-At: From: Thien-Thi Nguyen Date: 03 Jun 2006 08:30:55 -0400 Richard Stallman writes: > That is a good point. So the thing to do is turn off undo > temporarily while the diff is being received, then turn it on > with an empty undo list. the following patch does this. i am not confident about it because i had to change several places, and suspect other diff cases (or other commands) may not behave as desired. thi Your patch works for me; thanks. It also goes beyond solving the original problem in that it does the same thing for buffers with output from vc-print-log, etc, which is really nice. I found that dired-diff calls diff to do its work, and diff already does half the job. The patch below adds the other half. As for other modes, pcvs seems to DTRT, and log-view calls vc-version-diff. Since emerge and ediff present an indirect interface to diff output, I assume that we don't need to worry about them. (But there are a lot of grep hits to "diff" in the codebase, so there's a good chance I've missed something.) -- Bob ------------------------------------------------------------------------ Index: lisp/diff.el =================================================================== RCS file: /sources/emacs/emacs/lisp/diff.el,v retrieving revision 1.59 diff -c -r1.59 diff.el *** lisp/diff.el 6 Feb 2006 14:33:32 -0000 1.59 --- lisp/diff.el 3 Jun 2006 16:06:13 -0000 *************** *** 69,75 **** (goto-char (point-max)) (insert (format "\nDiff finished%s. %s\n" (if (equal 0 code) " (no differences)" "") ! (current-time-string))))) ;;;###autoload (defun diff (old new &optional switches no-async) --- 69,78 ---- (goto-char (point-max)) (insert (format "\nDiff finished%s. %s\n" (if (equal 0 code) " (no differences)" "") ! (current-time-string))) ! ;; undo was turned off by diff; turn it on again to allow the user ! ;; to split hunks (e.g.). ! (buffer-enable-undo (current-buffer)))) ;;;###autoload (defun diff (old new &optional switches no-async) *************** *** 118,126 **** (display-buffer buf) (set-buffer buf) (setq buffer-read-only nil) (buffer-disable-undo (current-buffer)) (erase-buffer) - (buffer-enable-undo (current-buffer)) (diff-mode) (set (make-local-variable 'revert-buffer-function) `(lambda (ignore-auto noconfirm) --- 121,130 ---- (display-buffer buf) (set-buffer buf) (setq buffer-read-only nil) + ;; recording the erase-buffer and diff content insertion for + ;; undo is wasteful. diff-sentinel turns it back on afterwards. (buffer-disable-undo (current-buffer)) (erase-buffer) (diff-mode) (set (make-local-variable 'revert-buffer-function) `(lambda (ignore-auto noconfirm)