Show
Ignore:
Timestamp:
2006年07月16日 08時36分52秒 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/diff-mode.el

    r4098 r4111  
    4747;;   possible to apply them to <file>, <hunk-src>, or <hunk-dst>. 
    4848;;   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. 
    4950;; 
    5051;; - 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. 
    5255;; - Handle `diff -b' output in context->unified. 
    5356 
    5457;;; Code: 
    55  
    5658(eval-when-compile (require 'cl)) 
    5759 
     
    129131    ;;("j" . diff-show-difference)      ;jump to Nth diff 
    130132    ;;("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) 
    139141    ("q" . quit-window)) 
    140142  "Basic keymap for `diff-mode', bound to various prefix keys.") 
     
    582584                     (if old (match-string 4) (match-string 2))))))))) 
    583585 
    584 (defun diff-find-file-name (&optional old
     586(defun diff-find-file-name (&optional old prefix
    585587  "Return the file corresponding to the current patch. 
    586 Non-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." 
    587590  (save-excursion 
    588591    (unless (looking-at diff-file-header-re) 
     
    590593          (re-search-forward diff-file-header-re nil t))) 
    591594    (let ((fs (diff-hunk-file-names old))) 
     595      (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) 
    592596      (or 
    593597       ;; use any previously used preference 
     
    611615            (let ((file (substring buffer-file-name 0 (match-beginning 0)))) 
    612616              (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))) 
    613624       ;; if all else fails, ask the user 
    614625       (let ((file (read-file-name (format "Use file %s: " (or (first fs) "")) 
     
    640651                   (list (region-beginning) (region-end)) 
    641652                 (list (point-min) (point-max)))) 
    642   (unless (markerp end) (setq end (copy-marker end))) 
     653  (unless (markerp end) (setq end (copy-marker end t))) 
    643654  (let (;;(diff-inhibit-after-change t) 
    644655        (inhibit-read-only t)) 
     
    730741  (if to-context 
    731742      (diff-unified->context start end) 
    732     (unless (markerp end) (setq end (copy-marker end))) 
     743    (unless (markerp end) (setq end (copy-marker end t))) 
    733744    (let ( ;;(diff-inhibit-after-change t) 
    734745          (inhibit-read-only t)) 
     
    802813                   (list (region-beginning) (region-end)) 
    803814                 (list (point-min) (point-max)))) 
    804   (unless (markerp end) (setq end (copy-marker end))) 
     815  (unless (markerp end) (setq end (copy-marker end t))) 
    805816  (let (;;(diff-inhibit-after-change t) 
    806817        (inhibit-read-only t)) 
     
    980991You can also switch between context diff and unified diff with \\[diff-context->unified], 
    981992or vice versa with \\[diff-unified->context] and you can also reverse the direction of 
    982 a diff with \\[diff-reverse-direction]." 
     993a diff with \\[diff-reverse-direction]. 
     994\\{diff-mode-map}" 
    983995  (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) 
    984996  (set (make-local-variable 'outline-regexp) diff-outline-regexp) 
     
    10051017    (add-hook 'post-command-hook 'diff-post-command-hook nil t)) 
    10061018  ;; 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))) 
    10081020    (add-to-list 'minor-mode-overriding-map-alist ro-bind) 
    10091021    ;; Turn off this little trick in case the buffer is put in view-mode. 
    10101022    (add-hook 'view-mode-hook 
    1011               `(lambda () 
    1012                 (setq minor-mode-overriding-map-alist 
    1013                       (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))) 
    10141026              nil t)) 
    10151027  ;; add-log support 
     
    10321044    (add-hook 'post-command-hook 'diff-post-command-hook nil t))) 
    10331045 
    1034 ;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
     1046;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
    10351047 
    10361048(defun diff-delete-if-empty ()