# HG changeset patch # User Stefan Monnier # Date 1026826635 0 # Node ID 4c43982491087cf973c0e50b4ef6cde4a1f4e436 # Parent 72f4c4b108355e633eb9fe9ae641eda7b927d516 (diff-reverse-direction): Simplify. (diff-after-change-function): Fix typo. (diff-post-command-hook): Take care of edge cases. (diff-current-defun): Do `goto-char' after setting the mode. diff -r 72f4c4b10835 -r 4c4398249108 lisp/diff-mode.el --- a/lisp/diff-mode.el Tue Jul 16 13:33:29 2002 +0000 +++ b/lisp/diff-mode.el Tue Jul 16 13:37:15 2002 +0000 @@ -742,10 +742,7 @@ (delete-char 1) (insert "-") t) ((?\\ ?#) t) (t (when (and first last (< first last)) - (let ((str - (save-excursion - (delete-and-extract-region first last)))) - (insert str))) + (insert (delete-and-extract-region first last))) (setq first nil last nil) (equal ?\ c))) (forward-line 1)))))))))) @@ -819,7 +816,7 @@ (if diff-unhandled-changes (setq diff-unhandled-changes (cons (min beg (car diff-unhandled-changes)) - (max beg (cdr diff-unhandled-changes)))) + (max end (cdr diff-unhandled-changes)))) (setq diff-unhandled-changes (cons beg end))))) (defun diff-post-command-hook () @@ -828,6 +825,8 @@ (ignore-errors (save-excursion (goto-char (car diff-unhandled-changes)) + ;; Maybe we've cut the end of the hunk before point. + (if (and (bolp) (not (bobp))) (backward-char 1)) ;; We used to fixup modifs on all the changes, but it turns out ;; that it's safer not to do it on big changes, for example ;; when yanking a big diff, since we might then screw up perfectly @@ -844,7 +843,7 @@ (diff-beginning-of-hunk) (when (save-excursion (diff-end-of-hunk) - (> (point) (cdr diff-unhandled-changes))) + (>= (point) (cdr diff-unhandled-changes))) (diff-fixup-modifs (point) (cdr diff-unhandled-changes))))) (setq diff-unhandled-changes nil))) @@ -1183,8 +1182,8 @@ (let ((old (if switched dst src))) (with-temp-buffer (insert (car old)) - (goto-char (cdr old)) (funcall (with-current-buffer buf major-mode)) + (goto-char (+ (point-min) (cdr old))) (add-log-current-defun)))) (with-current-buffer buf (goto-char (+ (car pos) (cdr src)))