Commit 5d68c2c2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

*** empty log message ***

parent 6c43f2f9
...@@ -53,6 +53,15 @@ subexpression gives the line number in the old file, and NEW-IDX'th ...@@ -53,6 +53,15 @@ subexpression gives the line number in the old file, and NEW-IDX'th
subexpression gives the line number in the new file. If OLD-IDX or NEW-IDX subexpression gives the line number in the new file. If OLD-IDX or NEW-IDX
is nil, REGEXP matches only half a section.") is nil, REGEXP matches only half a section.")
(defvar diff-old-file nil
"This is the old file name in the comparison in this buffer.")
(defvar diff-new-file nil
"This is the new file name in the comparison in this buffer.")
(defvar diff-old-temp-file nil
"This is the name of a temp file to be deleted after diff finishes.")
(defvar diff-new-temp-file nil
"This is the name of a temp file to be deleted after diff finishes.")
;; See compilation-parse-errors-function (compile.el). ;; See compilation-parse-errors-function (compile.el).
(defun diff-parse-differences (limit-search find-at-least) (defun diff-parse-differences (limit-search find-at-least)
(setq compilation-error-list nil) (setq compilation-error-list nil)
...@@ -118,7 +127,8 @@ is nil, REGEXP matches only half a section.") ...@@ -118,7 +127,8 @@ is nil, REGEXP matches only half a section.")
(if (nth 2 g) ;NEW-IDX (if (nth 2 g) ;NEW-IDX
(funcall new-error diff-new-file (nth 2 g))) (funcall new-error diff-new-file (nth 2 g)))
(if (or (and find-at-least (>= nfound find-at-least)) (if (or (and find-at-least
(>= compilation-num-errors-found find-at-least))
(and limit-search (>= (point) limit-search))) (and limit-search (>= (point) limit-search)))
;; We have found as many new errors as the user wants, ;; We have found as many new errors as the user wants,
;; or the user wanted a specific diff, and we're past it. ;; or the user wanted a specific diff, and we're past it.
...@@ -166,8 +176,8 @@ With prefix arg, prompt for diff switches." ...@@ -166,8 +176,8 @@ With prefix arg, prompt for diff switches."
(message "Comparing files %s %s..." new old) (message "Comparing files %s %s..." new old)
(setq new (expand-file-name new) (setq new (expand-file-name new)
old (expand-file-name old)) old (expand-file-name old))
(let ((old-alt (diff-prepare old new)) (let ((old-alt (file-local-copy old))
(new-alt (diff-prepare new old)) (new-alt (file-local-copy new))
buf) buf)
(unwind-protect (unwind-protect
(let ((command (let ((command
...@@ -188,26 +198,16 @@ With prefix arg, prompt for diff switches." ...@@ -188,26 +198,16 @@ With prefix arg, prompt for diff switches."
(save-excursion (save-excursion
(set-buffer buf) (set-buffer buf)
(set (make-local-variable 'diff-old-file) old) (set (make-local-variable 'diff-old-file) old)
(set (make-local-variable 'diff-new-file) new)) (set (make-local-variable 'diff-new-file) new)
buf) (set (make-local-variable 'diff-old-temp-file) old-alt)
(if old-alt (delete-file old-alt)) (set (make-local-variable 'diff-new-temp-file) new-alt)
(if new-alt (delete-file new-alt))))) (set (make-local-variable 'compilation-finish-function)
(function (lambda (buff msg)
;; Copy the file FILE into a temporary file if that is necessary (if diff-old-temp-file
;; for comparison. (This is only necessary if the file name has a handler.) (delete-file diff-old-temp-file))
;; OTHER is the other file to be compared. (if diff-new-temp-file
(defun diff-prepare (file other) (delete-file diff-new-temp-file))))))
(let (handler handlers) buf))))
(setq handlers file-name-handler-alist)
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers)))
(if handler
(funcall handler 'diff-prepare file other)
nil)))
;;;###autoload ;;;###autoload
(defun diff-backup (file &optional switches) (defun diff-backup (file &optional switches)
......
...@@ -221,6 +221,23 @@ and ignores this variable.") ...@@ -221,6 +221,23 @@ and ignores this variable.")
This is an interface to the function `load'." This is an interface to the function `load'."
(interactive "sLoad library: ") (interactive "sLoad library: ")
(load library)) (load library))
;; OTHER is the other file to be compared.
(defun file-local-copy (file)
"Copy the file FILE into a temporary file on this machine.
Returns the name of the local copy, or nil, if FILE is directly
accessible."
(let (handler (handlers file-name-handler-alist))
(save-match-data
(while (and (consp handlers) (null handler))
(if (and (consp (car handlers))
(stringp (car (car handlers)))
(string-match (car (car handlers)) file))
(setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))))
(if handler
(funcall handler 'file-local-copy file)
nil)))
(defun switch-to-buffer-other-window (buffer) (defun switch-to-buffer-other-window (buffer)
"Select buffer BUFFER in another window." "Select buffer BUFFER in another window."
...@@ -831,12 +848,13 @@ redefine it. ...@@ -831,12 +848,13 @@ redefine it.
If the optional argument KEEP-BACKUP-VERSION is non-nil, If the optional argument KEEP-BACKUP-VERSION is non-nil,
we do not remove backup version numbers, only true file version numbers." we do not remove backup version numbers, only true file version numbers."
(let (handler (handlers file-name-handler-alist)) (let (handler (handlers file-name-handler-alist))
(save-match-data
(while (and (consp handlers) (null handler)) (while (and (consp handlers) (null handler))
(if (and (consp (car handlers)) (if (and (consp (car handlers))
(stringp (car (car handlers))) (stringp (car (car handlers)))
(string-match (car (car handlers)) name)) (string-match (car (car handlers)) name))
(setq handler (cdr (car handlers)))) (setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))) (setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'file-name-sans-versions name keep-backup-version) (funcall handler 'file-name-sans-versions name keep-backup-version)
(substring name 0 (substring name 0
...@@ -1430,12 +1448,13 @@ This works by running a directory listing program ...@@ -1430,12 +1448,13 @@ This works by running a directory listing program
whose name is in the variable `ls-program'. whose name is in the variable `ls-program'.
If WILDCARD, it also runs the shell specified by `shell-file-name'." If WILDCARD, it also runs the shell specified by `shell-file-name'."
(let (handler (handlers file-name-handler-alist)) (let (handler (handlers file-name-handler-alist))
(save-match-data
(while (and (consp handlers) (null handler)) (while (and (consp handlers) (null handler))
(if (and (consp (car handlers)) (if (and (consp (car handlers))
(stringp (car (car handlers))) (stringp (car (car handlers)))
(string-match (car (car handlers)) file)) (string-match (car (car handlers)) file))
(setq handler (cdr (car handlers)))) (setq handler (cdr (car handlers))))
(setq handlers (cdr handlers))) (setq handlers (cdr handlers))))
(if handler (if handler
(funcall handler 'insert-directory file switches (funcall handler 'insert-directory file switches
wildcard full-directory-p) wildcard full-directory-p)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment