emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: *vc-diff* keeps undo information


From: Bob Rogers
Subject: Re: *vc-diff* keeps undo information
Date: Sat, 3 Jun 2006 14:07:21 -0400

   From: Thien-Thi Nguyen <address@hidden>
   Date: 03 Jun 2006 08:30:55 -0400

   Richard Stallman <address@hidden> 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]