aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/diff-mode.el
diff options
context:
space:
mode:
authorKaroly Lorentey2006-07-14 05:56:32 +0000
committerKaroly Lorentey2006-07-14 05:56:32 +0000
commit99715bbc447eb633e45ffa23b87284771ce3ac74 (patch)
tree3a8a53dfe3dbdd9f8e36965e9f043eae522d3c0e /lisp/diff-mode.el
parent556b89447234f15d1784a23dadbfe429464463a8 (diff)
parent763bb2d43615bc3ae816422f965d76d5e1ae4bdd (diff)
downloademacs-99715bbc447eb633e45ffa23b87284771ce3ac74.tar.gz
emacs-99715bbc447eb633e45ffa23b87284771ce3ac74.zip
Merged from emacs@sv.gnu.org.
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-331 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-332 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-333 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-334 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-335 Add note about "link" button-class to etc/TODO * emacs@sv.gnu.org/emacs--devo--0--patch-336 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-337 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-338 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-339 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-340 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-341 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-342 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-343 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-344 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-345 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-346 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-347 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-348 Update for ERC 5.1.3. * emacs@sv.gnu.org/emacs--devo--0--patch-349 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-350 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/gnus--rel--5.10--patch-111 Update from CVS: texi/gnus.texi (Summary Buffer Lines): Fix typo. * emacs@sv.gnu.org/gnus--rel--5.10--patch-112 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-113 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-114 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-572
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r--lisp/diff-mode.el54
1 files changed, 33 insertions, 21 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index 7ea02352b0b..16bdaf152f7 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -46,13 +46,15 @@
46;; of a hunk. Show then the changes between <file> and <hunk> and make it 46;; of a hunk. Show then the changes between <file> and <hunk> and make it
47;; possible to apply them to <file>, <hunk-src>, or <hunk-dst>. 47;; possible to apply them to <file>, <hunk-src>, or <hunk-dst>.
48;; Or maybe just make it into a ".rej to diff3-markers converter". 48;; Or maybe just make it into a ".rej to diff3-markers converter".
49;; Maybe just use `wiggle' (by Neil Brown) to do it for us.
49;; 50;;
50;; - Refine hunk on a word-by-word basis. 51;; - Refine hunk on a word-by-word basis.
51;; 52;;
53;; - in diff-apply-hunk, strip context in replace-match to better
54;; preserve markers and spacing.
52;; - Handle `diff -b' output in context->unified. 55;; - Handle `diff -b' output in context->unified.
53 56
54;;; Code: 57;;; Code:
55
56(eval-when-compile (require 'cl)) 58(eval-when-compile (require 'cl))
57 59
58(defvar add-log-buffer-file-name-function) 60(defvar add-log-buffer-file-name-function)
@@ -128,14 +130,14 @@ when editing big diffs)."
128 ;;("h" . diff-show-header) 130 ;;("h" . diff-show-header)
129 ;;("j" . diff-show-difference) ;jump to Nth diff 131 ;;("j" . diff-show-difference) ;jump to Nth diff
130 ;;("q" . diff-quit) 132 ;;("q" . diff-quit)
131;; Not useful if you have to metafy them. 133 ;; Not useful if you have to metafy them.
132;; (" " . scroll-up) 134 ;;(" " . scroll-up)
133;; ("\177" . scroll-down) 135 ;;("\177" . scroll-down)
134;; Standard M-a is useful, so don't change M-A. 136 ;; Standard M-a is useful, so don't change M-A.
135;; ("A" . diff-ediff-patch) 137 ;;("A" . diff-ediff-patch)
136;; Standard M-r is useful, so don't change M-r or M-R. 138 ;; Standard M-r is useful, so don't change M-r or M-R.
137;; ("r" . diff-restrict-view) 139 ;;("r" . diff-restrict-view)
138;; ("R" . diff-reverse-direction) 140 ;;("R" . diff-reverse-direction)
139 ("q" . quit-window)) 141 ("q" . quit-window))
140 "Basic keymap for `diff-mode', bound to various prefix keys.") 142 "Basic keymap for `diff-mode', bound to various prefix keys.")
141 143
@@ -581,14 +583,16 @@ If the OLD prefix arg is passed, tell the file NAME of the old file."
581 (list (if old (match-string 2) (match-string 4)) 583 (list (if old (match-string 2) (match-string 4))
582 (if old (match-string 4) (match-string 2))))))))) 584 (if old (match-string 4) (match-string 2)))))))))
583 585
584(defun diff-find-file-name (&optional old) 586(defun diff-find-file-name (&optional old prefix)
585 "Return the file corresponding to the current patch. 587 "Return the file corresponding to the current patch.
586Non-nil OLD means that we want the old file." 588Non-nil OLD means that we want the old file.
589PREFIX is only used internally: don't use it."
587 (save-excursion 590 (save-excursion
588 (unless (looking-at diff-file-header-re) 591 (unless (looking-at diff-file-header-re)
589 (or (ignore-errors (diff-beginning-of-file)) 592 (or (ignore-errors (diff-beginning-of-file))
590 (re-search-forward diff-file-header-re nil t))) 593 (re-search-forward diff-file-header-re nil t)))
591 (let ((fs (diff-hunk-file-names old))) 594 (let ((fs (diff-hunk-file-names old)))
595 (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs)))
592 (or 596 (or
593 ;; use any previously used preference 597 ;; use any previously used preference
594 (cdr (assoc fs diff-remembered-files-alist)) 598 (cdr (assoc fs diff-remembered-files-alist))
@@ -610,6 +614,13 @@ Non-nil OLD means that we want the old file."
610 (and (string-match "\\.rej\\'" (or buffer-file-name "")) 614 (and (string-match "\\.rej\\'" (or buffer-file-name ""))
611 (let ((file (substring buffer-file-name 0 (match-beginning 0)))) 615 (let ((file (substring buffer-file-name 0 (match-beginning 0))))
612 (when (file-exists-p file) file))) 616 (when (file-exists-p file) file)))
617 ;; If we haven't found the file, maybe it's because we haven't paid
618 ;; attention to the PCL-CVS hint.
619 (and (not prefix)
620 (boundp 'cvs-pcl-cvs-dirchange-re)
621 (save-excursion
622 (re-search-backward cvs-pcl-cvs-dirchange-re nil t))
623 (diff-find-file-name old (match-string 1)))
613 ;; if all else fails, ask the user 624 ;; if all else fails, ask the user
614 (let ((file (read-file-name (format "Use file %s: " (or (first fs) "")) 625 (let ((file (read-file-name (format "Use file %s: " (or (first fs) ""))
615 nil (first fs) t (first fs)))) 626 nil (first fs) t (first fs))))
@@ -639,7 +650,7 @@ else cover the whole bufer."
639 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active)) 650 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active))
640 (list (region-beginning) (region-end)) 651 (list (region-beginning) (region-end))
641 (list (point-min) (point-max)))) 652 (list (point-min) (point-max))))
642 (unless (markerp end) (setq end (copy-marker end))) 653 (unless (markerp end) (setq end (copy-marker end t)))
643 (let (;;(diff-inhibit-after-change t) 654 (let (;;(diff-inhibit-after-change t)
644 (inhibit-read-only t)) 655 (inhibit-read-only t))
645 (save-excursion 656 (save-excursion
@@ -729,7 +740,7 @@ With a prefix argument, convert unified format to context format."
729 (list (point-min) (point-max) current-prefix-arg))) 740 (list (point-min) (point-max) current-prefix-arg)))
730 (if to-context 741 (if to-context
731 (diff-unified->context start end) 742 (diff-unified->context start end)
732 (unless (markerp end) (setq end (copy-marker end))) 743 (unless (markerp end) (setq end (copy-marker end t)))
733 (let ( ;;(diff-inhibit-after-change t) 744 (let ( ;;(diff-inhibit-after-change t)
734 (inhibit-read-only t)) 745 (inhibit-read-only t))
735 (save-excursion 746 (save-excursion
@@ -801,7 +812,7 @@ else cover the whole bufer."
801 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active)) 812 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active))
802 (list (region-beginning) (region-end)) 813 (list (region-beginning) (region-end))
803 (list (point-min) (point-max)))) 814 (list (point-min) (point-max))))
804 (unless (markerp end) (setq end (copy-marker end))) 815 (unless (markerp end) (setq end (copy-marker end t)))
805 (let (;;(diff-inhibit-after-change t) 816 (let (;;(diff-inhibit-after-change t)
806 (inhibit-read-only t)) 817 (inhibit-read-only t))
807 (save-excursion 818 (save-excursion
@@ -979,7 +990,8 @@ headers for you on-the-fly.
979 990
980You can also switch between context diff and unified diff with \\[diff-context->unified], 991You can also switch between context diff and unified diff with \\[diff-context->unified],
981or vice versa with \\[diff-unified->context] and you can also reverse the direction of 992or vice versa with \\[diff-unified->context] and you can also reverse the direction of
982a diff with \\[diff-reverse-direction]." 993a diff with \\[diff-reverse-direction].
994\\{diff-mode-map}"
983 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) 995 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults)
984 (set (make-local-variable 'outline-regexp) diff-outline-regexp) 996 (set (make-local-variable 'outline-regexp) diff-outline-regexp)
985 (set (make-local-variable 'imenu-generic-expression) 997 (set (make-local-variable 'imenu-generic-expression)
@@ -1004,13 +1016,13 @@ a diff with \\[diff-reverse-direction]."
1004 (add-hook 'after-change-functions 'diff-after-change-function nil t) 1016 (add-hook 'after-change-functions 'diff-after-change-function nil t)
1005 (add-hook 'post-command-hook 'diff-post-command-hook nil t)) 1017 (add-hook 'post-command-hook 'diff-post-command-hook nil t))
1006 ;; Neat trick from Dave Love to add more bindings in read-only mode: 1018 ;; Neat trick from Dave Love to add more bindings in read-only mode:
1007 (let ((ro-bind (cons 'buffer-read-only diff-mode-shared-map))) 1019 (lexical-let ((ro-bind (cons 'buffer-read-only diff-mode-shared-map)))
1008 (add-to-list 'minor-mode-overriding-map-alist ro-bind) 1020 (add-to-list 'minor-mode-overriding-map-alist ro-bind)
1009 ;; Turn off this little trick in case the buffer is put in view-mode. 1021 ;; Turn off this little trick in case the buffer is put in view-mode.
1010 (add-hook 'view-mode-hook 1022 (add-hook 'view-mode-hook
1011 `(lambda () 1023 (lambda ()
1012 (setq minor-mode-overriding-map-alist 1024 (setq minor-mode-overriding-map-alist
1013 (delq ',ro-bind minor-mode-overriding-map-alist))) 1025 (delq ro-bind minor-mode-overriding-map-alist)))
1014 nil t)) 1026 nil t))
1015 ;; add-log support 1027 ;; add-log support
1016 (set (make-local-variable 'add-log-current-defun-function) 1028 (set (make-local-variable 'add-log-current-defun-function)
@@ -1031,7 +1043,7 @@ a diff with \\[diff-reverse-direction]."
1031 (add-hook 'after-change-functions 'diff-after-change-function nil t) 1043 (add-hook 'after-change-functions 'diff-after-change-function nil t)
1032 (add-hook 'post-command-hook 'diff-post-command-hook nil t))) 1044 (add-hook 'post-command-hook 'diff-post-command-hook nil t)))
1033 1045
1034;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1046;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1035 1047
1036(defun diff-delete-if-empty () 1048(defun diff-delete-if-empty ()
1037 ;; An empty diff file means there's no more diffs to integrate, so we 1049 ;; An empty diff file means there's no more diffs to integrate, so we