-;;; 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.
(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)
(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)
(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))))))))))
(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 ()
(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
(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)))
(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)))