Changeset 4111 for trunk/lisp/diff-mode.el
- Timestamp:
- 2006年07月16日 08時36分52秒 (2 years ago)
- Files:
-
- trunk/lisp/diff-mode.el (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/diff-mode.el
r4098 r4111 47 47 ;; possible to apply them to <file>, <hunk-src>, or <hunk-dst>. 48 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 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 55 ;; - Handle `diff -b' output in context->unified. 53 56 54 57 ;;; Code: 55 56 58 (eval-when-compile (require 'cl)) 57 59 … … 129 131 ;;("j" . diff-show-difference) ;jump to Nth diff 130 132 ;;("q" . diff-quit) 131 ;; Not useful if you have to metafy them.132 ;;(" " . scroll-up)133 ;;("\177" . scroll-down)134 ;; Standard M-a is useful, so don't change M-A.135 ;;("A" . diff-ediff-patch)136 ;; Standard M-r is useful, so don't change M-r or M-R.137 ;;("r" . diff-restrict-view)138 ;;("R" . diff-reverse-direction)133 ;; Not useful if you have to metafy them. 134 ;;(" " . scroll-up) 135 ;;("\177" . scroll-down) 136 ;; Standard M-a is useful, so don't change M-A. 137 ;;("A" . diff-ediff-patch) 138 ;; Standard M-r is useful, so don't change M-r or M-R. 139 ;;("r" . diff-restrict-view) 140 ;;("R" . diff-reverse-direction) 139 141 ("q" . quit-window)) 140 142 "Basic keymap for `diff-mode', bound to various prefix keys.") … … 582 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 587 "Return the file corresponding to the current patch. 586 Non-nil OLD means that we want the old file." 588 Non-nil OLD means that we want the old file. 589 PREFIX is only used internally: don't use it." 587 590 (save-excursion 588 591 (unless (looking-at diff-file-header-re) … … 590 593 (re-search-forward diff-file-header-re nil t))) 591 594 (let ((fs (diff-hunk-file-names old))) 595 (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) 592 596 (or 593 597 ;; use any previously used preference … … 611 615 (let ((file (substring buffer-file-name 0 (match-beginning 0)))) 612 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 624 ;; if all else fails, ask the user 614 625 (let ((file (read-file-name (format "Use file %s: " (or (first fs) "")) … … 640 651 (list (region-beginning) (region-end)) 641 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 654 (let (;;(diff-inhibit-after-change t) 644 655 (inhibit-read-only t)) … … 730 741 (if to-context 731 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 744 (let ( ;;(diff-inhibit-after-change t) 734 745 (inhibit-read-only t)) … … 802 813 (list (region-beginning) (region-end)) 803 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 816 (let (;;(diff-inhibit-after-change t) 806 817 (inhibit-read-only t)) … … 980 991 You can also switch between context diff and unified diff with \\[diff-context->unified], 981 992 or vice versa with \\[diff-unified->context] and you can also reverse the direction of 982 a diff with \\[diff-reverse-direction]." 993 a diff with \\[diff-reverse-direction]. 994 \\{diff-mode-map}" 983 995 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) 984 996 (set (make-local-variable 'outline-regexp) diff-outline-regexp) … … 1005 1017 (add-hook 'post-command-hook 'diff-post-command-hook nil t)) 1006 1018 ;; Neat trick from Dave Love to add more bindings in read-only mode: 1007 (le t ((ro-bind (cons 'buffer-read-only diff-mode-shared-map)))1019 (lexical-let ((ro-bind (cons 'buffer-read-only diff-mode-shared-map))) 1008 1020 (add-to-list 'minor-mode-overriding-map-alist ro-bind) 1009 1021 ;; Turn off this little trick in case the buffer is put in view-mode. 1010 1022 (add-hook 'view-mode-hook 1011 `(lambda ()1012 (setq minor-mode-overriding-map-alist1013 (delq ',ro-bind minor-mode-overriding-map-alist)))1023 (lambda () 1024 (setq minor-mode-overriding-map-alist 1025 (delq ro-bind minor-mode-overriding-map-alist))) 1014 1026 nil t)) 1015 1027 ;; add-log support … … 1032 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 1048 (defun diff-delete-if-empty ()
