aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1992-09-14 01:39:31 +0000
committerRichard M. Stallman1992-09-14 01:39:31 +0000
commit5d68c2c227eb79f3eca2323f86780f8b7b178c49 (patch)
treef9aaa08b1cd91de4a330699a6769ab0d52c0f3ff
parent6c43f2f9e97b5dbaa9f582444c9c905cda9b29f1 (diff)
downloademacs-5d68c2c227eb79f3eca2323f86780f8b7b178c49.tar.gz
emacs-5d68c2c227eb79f3eca2323f86780f8b7b178c49.zip
*** empty log message ***
-rw-r--r--lisp/diff.el46
-rw-r--r--lisp/files.el43
2 files changed, 54 insertions, 35 deletions
diff --git a/lisp/diff.el b/lisp/diff.el
index 615d64d5fa8..ae49cf1f371 100644
--- a/lisp/diff.el
+++ b/lisp/diff.el
@@ -53,6 +53,15 @@ subexpression gives the line number in the old file, and NEW-IDX'th
53subexpression gives the line number in the new file. If OLD-IDX or NEW-IDX 53subexpression gives the line number in the new file. If OLD-IDX or NEW-IDX
54is nil, REGEXP matches only half a section.") 54is nil, REGEXP matches only half a section.")
55 55
56(defvar diff-old-file nil
57 "This is the old file name in the comparison in this buffer.")
58(defvar diff-new-file nil
59 "This is the new file name in the comparison in this buffer.")
60(defvar diff-old-temp-file nil
61 "This is the name of a temp file to be deleted after diff finishes.")
62(defvar diff-new-temp-file nil
63 "This is the name of a temp file to be deleted after diff finishes.")
64
56;; See compilation-parse-errors-function (compile.el). 65;; See compilation-parse-errors-function (compile.el).
57(defun diff-parse-differences (limit-search find-at-least) 66(defun diff-parse-differences (limit-search find-at-least)
58 (setq compilation-error-list nil) 67 (setq compilation-error-list nil)
@@ -118,7 +127,8 @@ is nil, REGEXP matches only half a section.")
118 (if (nth 2 g) ;NEW-IDX 127 (if (nth 2 g) ;NEW-IDX
119 (funcall new-error diff-new-file (nth 2 g))) 128 (funcall new-error diff-new-file (nth 2 g)))
120 129
121 (if (or (and find-at-least (>= nfound find-at-least)) 130 (if (or (and find-at-least
131 (>= compilation-num-errors-found find-at-least))
122 (and limit-search (>= (point) limit-search))) 132 (and limit-search (>= (point) limit-search)))
123 ;; We have found as many new errors as the user wants, 133 ;; We have found as many new errors as the user wants,
124 ;; or the user wanted a specific diff, and we're past it. 134 ;; or the user wanted a specific diff, and we're past it.
@@ -166,8 +176,8 @@ With prefix arg, prompt for diff switches."
166 (message "Comparing files %s %s..." new old) 176 (message "Comparing files %s %s..." new old)
167 (setq new (expand-file-name new) 177 (setq new (expand-file-name new)
168 old (expand-file-name old)) 178 old (expand-file-name old))
169 (let ((old-alt (diff-prepare old new)) 179 (let ((old-alt (file-local-copy old))
170 (new-alt (diff-prepare new old)) 180 (new-alt (file-local-copy new))
171 buf) 181 buf)
172 (unwind-protect 182 (unwind-protect
173 (let ((command 183 (let ((command
@@ -188,26 +198,16 @@ With prefix arg, prompt for diff switches."
188 (save-excursion 198 (save-excursion
189 (set-buffer buf) 199 (set-buffer buf)
190 (set (make-local-variable 'diff-old-file) old) 200 (set (make-local-variable 'diff-old-file) old)
191 (set (make-local-variable 'diff-new-file) new)) 201 (set (make-local-variable 'diff-new-file) new)
192 buf) 202 (set (make-local-variable 'diff-old-temp-file) old-alt)
193 (if old-alt (delete-file old-alt)) 203 (set (make-local-variable 'diff-new-temp-file) new-alt)
194 (if new-alt (delete-file new-alt))))) 204 (set (make-local-variable 'compilation-finish-function)
195 205 (function (lambda (buff msg)
196;; Copy the file FILE into a temporary file if that is necessary 206 (if diff-old-temp-file
197;; for comparison. (This is only necessary if the file name has a handler.) 207 (delete-file diff-old-temp-file))
198;; OTHER is the other file to be compared. 208 (if diff-new-temp-file
199(defun diff-prepare (file other) 209 (delete-file diff-new-temp-file))))))
200 (let (handler handlers) 210 buf))))
201 (setq handlers file-name-handler-alist)
202 (while (and (consp handlers) (null handler))
203 (if (and (consp (car handlers))
204 (stringp (car (car handlers)))
205 (string-match (car (car handlers)) file))
206 (setq handler (cdr (car handlers))))
207 (setq handlers (cdr handlers)))
208 (if handler
209 (funcall handler 'diff-prepare file other)
210 nil)))
211 211
212;;;###autoload 212;;;###autoload
213(defun diff-backup (file &optional switches) 213(defun diff-backup (file &optional switches)
diff --git a/lisp/files.el b/lisp/files.el
index bd7cf7d8864..f784004c04a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -221,6 +221,23 @@ and ignores this variable.")
221This is an interface to the function `load'." 221This is an interface to the function `load'."
222 (interactive "sLoad library: ") 222 (interactive "sLoad library: ")
223 (load library)) 223 (load library))
224
225;; OTHER is the other file to be compared.
226(defun file-local-copy (file)
227 "Copy the file FILE into a temporary file on this machine.
228Returns the name of the local copy, or nil, if FILE is directly
229accessible."
230 (let (handler (handlers file-name-handler-alist))
231 (save-match-data
232 (while (and (consp handlers) (null handler))
233 (if (and (consp (car handlers))
234 (stringp (car (car handlers)))
235 (string-match (car (car handlers)) file))
236 (setq handler (cdr (car handlers))))
237 (setq handlers (cdr handlers))))
238 (if handler
239 (funcall handler 'file-local-copy file)
240 nil)))
224 241
225(defun switch-to-buffer-other-window (buffer) 242(defun switch-to-buffer-other-window (buffer)
226 "Select buffer BUFFER in another window." 243 "Select buffer BUFFER in another window."
@@ -831,12 +848,13 @@ redefine it.
831If the optional argument KEEP-BACKUP-VERSION is non-nil, 848If the optional argument KEEP-BACKUP-VERSION is non-nil,
832we do not remove backup version numbers, only true file version numbers." 849we do not remove backup version numbers, only true file version numbers."
833 (let (handler (handlers file-name-handler-alist)) 850 (let (handler (handlers file-name-handler-alist))
834 (while (and (consp handlers) (null handler)) 851 (save-match-data
835 (if (and (consp (car handlers)) 852 (while (and (consp handlers) (null handler))
836 (stringp (car (car handlers))) 853 (if (and (consp (car handlers))
837 (string-match (car (car handlers)) name)) 854 (stringp (car (car handlers)))
838 (setq handler (cdr (car handlers)))) 855 (string-match (car (car handlers)) name))
839 (setq handlers (cdr handlers))) 856 (setq handler (cdr (car handlers))))
857 (setq handlers (cdr handlers))))
840 (if handler 858 (if handler
841 (funcall handler 'file-name-sans-versions name keep-backup-version) 859 (funcall handler 'file-name-sans-versions name keep-backup-version)
842 (substring name 0 860 (substring name 0
@@ -1430,12 +1448,13 @@ This works by running a directory listing program
1430whose name is in the variable `ls-program'. 1448whose name is in the variable `ls-program'.
1431If WILDCARD, it also runs the shell specified by `shell-file-name'." 1449If WILDCARD, it also runs the shell specified by `shell-file-name'."
1432 (let (handler (handlers file-name-handler-alist)) 1450 (let (handler (handlers file-name-handler-alist))
1433 (while (and (consp handlers) (null handler)) 1451 (save-match-data
1434 (if (and (consp (car handlers)) 1452 (while (and (consp handlers) (null handler))
1435 (stringp (car (car handlers))) 1453 (if (and (consp (car handlers))
1436 (string-match (car (car handlers)) file)) 1454 (stringp (car (car handlers)))
1437 (setq handler (cdr (car handlers)))) 1455 (string-match (car (car handlers)) file))
1438 (setq handlers (cdr handlers))) 1456 (setq handler (cdr (car handlers))))
1457 (setq handlers (cdr handlers))))
1439 (if handler 1458 (if handler
1440 (funcall handler 'insert-directory file switches 1459 (funcall handler 'insert-directory file switches
1441 wildcard full-directory-p) 1460 wildcard full-directory-p)