]> code.delx.au - gnu-emacs/blobdiff - lisp/diff-mode.el
Added checks that distinguish between cygwin and windows in some
[gnu-emacs] / lisp / diff-mode.el
index c46d152d97e3d6b0e92e08b2e4e6748381ef5afa..69621a6425979009a434668518c3eca999b30504 100644 (file)
@@ -1,9 +1,9 @@
-;;; diff-mode.el --- A mode for viewing/editing context diffs
+;;; diff-mode.el --- a mode for viewing/editing context diffs
 
 ;; Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
-;; Keywords: patch diff
+;; Keywords: convenience patch diff
 
 ;; This file is part of GNU Emacs.
 
 ;; commands, editing and various conversions as well as jumping
 ;; to the corresponding source file.
 
-;; inspired by Pavel Machek's patch-mode.el (<pavel@atrey.karlin.mff.cuni.cz>)
-;; some efforts were spent to have it somewhat compatible with XEmacs'
+;; Inspired by Pavel Machek's patch-mode.el (<pavel@atrey.karlin.mff.cuni.cz>)
+;; Some efforts were spent to have it somewhat compatible with XEmacs'
 ;; diff-mode as well as with compilation-minor-mode
 
-;; to use it, simply add to your .emacs the following lines:
-;; 
-;; (autoload 'diff-mode "diff-mode" "Diff major mode" t)
-;; (add-to-list 'auto-mode-alist '("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode))
-
 ;; Bugs:
 
 ;; - Reverse doesn't work with normal diffs.
@@ -173,27 +168,27 @@ when editing big diffs)."
 
 (defface diff-header-face
   '((((type tty pc) (class color) (background light))
-     (:foreground "blue1" :bold t))
+     (:foreground "blue1" :weight bold))
     (((type tty pc) (class color) (background dark))
-     (:foreground "green" :bold t))
+     (:foreground "green" :weight bold))
     (((class color) (background light))
      (:background "grey85"))
     (((class color) (background dark))
      (:background "grey45"))
-    (t (:bold t)))
+    (t (:weight bold)))
   "`diff-mode' face inherited by hunk and index header faces.")
 (defvar diff-header-face 'diff-header-face)
 
 (defface diff-file-header-face
   '((((type tty pc) (class color) (background light))
-     (:foreground "yellow" :bold t))
+     (:foreground "yellow" :weight bold))
     (((type tty pc) (class color) (background dark))
-     (:foreground "cyan" :bold t))
+     (:foreground "cyan" :weight bold))
     (((class color) (background light))
-     (:background "grey70" :bold t))
+     (:background "grey70" :weight bold))
     (((class color) (background dark))
-     (:background "grey60" :bold t))
-    (t (:bold t)))                     ; :height 1.3
+     (:background "grey60" :weight bold))
+    (t (:weight bold)))                        ; :height 1.3
   "`diff-mode' face used to highlight file header lines.")
 (defvar diff-file-header-face 'diff-file-header-face)
 
@@ -219,9 +214,9 @@ when editing big diffs)."
 
 (defface diff-changed-face
   '((((type tty pc) (class color) (background light))
-     (:foreground "magenta" :bold t :italic t))
+     (:foreground "magenta" :weight bold :slant italic))
     (((type tty pc) (class color) (background dark))
-     (:foreground "yellow" :bold t :italic t))
+     (:foreground "yellow" :weight bold :slant italic))
     (t ()))
   "`diff-mode' face used to highlight changed lines.")
 (defvar diff-changed-face 'diff-changed-face)
@@ -747,10 +742,7 @@ else cover the whole bufer."
                           (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))))))))))
@@ -824,7 +816,7 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
     (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 ()
@@ -833,6 +825,8 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
     (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
@@ -849,7 +843,7 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
        (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)))
 
@@ -1188,8 +1182,8 @@ For use in `add-log-current-defun-function'."
            (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)))