annotate lisp/efs/dired-diff.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 8fc7fe29b841
children 7e54bd776075 9f59509498e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: dired-diff.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Dired Version: $Revision: 1.1 $
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; Description: Support for diff and related commands.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Author: Sandy Rutherford <sandy@ibm550.sissa.it>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; Created: Fri Jun 24 08:50:20 1994 by sandy on ibm550
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 ;;; This program is free software; you can redistribute it and/or modify
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 1, or (at your option)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;;; any later version.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 ;;; This program is distributed in the hope that it will be useful,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;;; A copy of the GNU General Public License can be obtained from this
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 ;;; program's author (send electronic mail to sandy@ibm550.sissa.it) or
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;;; from the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;;; MA 02139, USA.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 (provide 'dired-diff)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (require 'dired)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 (defvar emerge-last-dir-input)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (defvar emerge-last-dir-output)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 (defvar emerge-last-dir-ancestor)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 (defvar diff-switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (defun dired-diff-read-file-name (prompt)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 ;; Read and return a file name for diff.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 (let* ((mark-active t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (default (and (mark)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 (goto-char (mark))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (dired-get-filename nil t)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (read-file-name (format "%s %s with: %s"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 prompt (dired-get-filename 'no-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 (if default
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (concat "["
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 (dired-make-relative
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 default
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (dired-current-directory) t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 "] ")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 ""))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 (default-directory) default t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (defun dired-diff-read-switches (switchprompt)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 ;; Read and return a list of switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 (or (boundp 'diff-switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (require 'diff)) ; Make sure that `diff-switches' is defined.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (let* ((default (if (listp diff-switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (mapconcat 'identity diff-switches " ")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 diff-switches))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 (read-string (format switchprompt default) default)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 (let (result (start 0))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 (while (string-match "\\(\\S-+\\)" switches start)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (setq result (cons (substring switches (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 (match-end 1))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 result)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 start (match-end 0)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 (nreverse result))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 (defun dired-diff (file &optional switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 "Compare file at point with file FILE using `diff'.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 FILE defaults to the file at the mark.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 The prompted-for file is the first file given to `diff'.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 With a prefix allows the switches for the diff program to be edited."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (dired-diff-read-file-name "Diff")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 (and current-prefix-arg (dired-diff-read-switches "Options for diff: "))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80 (if switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 (diff file (dired-get-filename) switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 (diff file (dired-get-filename))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (defun dired-backup-diff (&optional switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 "Diff this file with its backup file or vice versa.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 Uses the latest backup, if there are several numerical backups.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 If this file is a backup, diff it with its original.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 The backup file is the first file given to `diff'."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 (interactive (list (and current-prefix-arg
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (dired-diff-read-switches "Diff with switches: "))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (if switches
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (diff-backup (dired-get-filename) switches)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (diff-backup (dired-get-filename))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (defun dired-emerge (arg file out-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 "Merge file at point with FILE using `emerge'.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 FILE defaults to the file at the mark."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (let ((file (dired-diff-read-file-name "Merge")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 current-prefix-arg
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (and current-prefix-arg (emerge-read-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 "Output file"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 emerge-last-dir-output
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 (dired-abbreviate-file-name file) file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (emerge-files arg file (dired-get-filename) out-file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (defun dired-emerge-with-ancestor (arg file ancestor file-out)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 "Merge file at point with FILE, using a common ANCESTOR file.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 FILE defaults to the file at the mark."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (let ((file (dired-diff-read-file-name "Merge")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 current-prefix-arg
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 (emerge-read-file-name "Ancestor file" emerge-last-dir-ancestor nil file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (and current-prefix-arg (emerge-read-file-name
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 "Output file"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 emerge-last-dir-output
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (dired-abbreviate-file-name file) file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (emerge-files-with-ancestor arg file (dired-get-filename)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 ancestor file-out))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (defun dired-ediff (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 "Ediff file at point with FILE.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 FILE defaults to the file at the mark."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (interactive (list (dired-diff-read-file-name "Ediff")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (ediff-files file (dired-get-filename)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (defun dired-epatch (file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 "Patch file at point using `epatch'."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (let ((file (dired-get-filename)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (and (or (memq 'patch dired-no-confirm)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 (y-or-n-p (format "Patch %s? "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 (file-name-nondirectory file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (if file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 (ediff-patch-file file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 (message "No file patched.")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 ;;; Autoloads
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 ;;; Diff (diff)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 (autoload 'diff "diff" "Diff two files." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 (autoload 'diff-backup "diff"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150 "Diff this file with its backup or vice versa." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 ;;; Emerge
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 (autoload 'emerge-files "emerge" "Merge two files." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (autoload 'emerge-files-with-ancestor "emerge"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 "Merge two files having a common ancestor." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 (autoload 'emerge-read-file-name "emerge")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 ;; Ediff
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (autoload 'ediff-files "ediff" "Ediff two files." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162 (autoload 'ediff-patch-file "ediff" "Patch a file." t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164 ;;; end of dired-diff.el