aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/diff.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/diff.el')
-rw-r--r--lisp/diff.el32
1 files changed, 24 insertions, 8 deletions
diff --git a/lisp/diff.el b/lisp/diff.el
index 221d7b2e363..534a84d4317 100644
--- a/lisp/diff.el
+++ b/lisp/diff.el
@@ -67,9 +67,10 @@ CODE is the exit code of the process. It should be 0 iff no diffs were found."
67 (if diff-new-temp-file (delete-file diff-new-temp-file)) 67 (if diff-new-temp-file (delete-file diff-new-temp-file))
68 (save-excursion 68 (save-excursion
69 (goto-char (point-max)) 69 (goto-char (point-max))
70 (insert (format "\nDiff finished%s. %s\n" 70 (let ((inhibit-read-only t))
71 (if (equal 0 code) " (no differences)" "") 71 (insert (format "\nDiff finished%s. %s\n"
72 (current-time-string))))) 72 (if (equal 0 code) " (no differences)" "")
73 (current-time-string))))))
73 74
74;;;###autoload 75;;;###autoload
75(defun diff (old new &optional switches no-async) 76(defun diff (old new &optional switches no-async)
@@ -119,7 +120,8 @@ With prefix arg, prompt for diff switches."
119 (set-buffer buf) 120 (set-buffer buf)
120 (setq buffer-read-only nil) 121 (setq buffer-read-only nil)
121 (buffer-disable-undo (current-buffer)) 122 (buffer-disable-undo (current-buffer))
122 (erase-buffer) 123 (let ((inhibit-read-only t))
124 (erase-buffer))
123 (buffer-enable-undo (current-buffer)) 125 (buffer-enable-undo (current-buffer))
124 (diff-mode) 126 (diff-mode)
125 (set (make-local-variable 'revert-buffer-function) 127 (set (make-local-variable 'revert-buffer-function)
@@ -128,21 +130,35 @@ With prefix arg, prompt for diff switches."
128 (set (make-local-variable 'diff-old-temp-file) old-alt) 130 (set (make-local-variable 'diff-old-temp-file) old-alt)
129 (set (make-local-variable 'diff-new-temp-file) new-alt) 131 (set (make-local-variable 'diff-new-temp-file) new-alt)
130 (setq default-directory thisdir) 132 (setq default-directory thisdir)
131 (insert command "\n") 133 (let ((inhibit-read-only t))
134 (insert command "\n"))
132 (if (and (not no-async) (fboundp 'start-process)) 135 (if (and (not no-async) (fboundp 'start-process))
133 (progn 136 (progn
134 (setq proc (start-process "Diff" buf shell-file-name 137 (setq proc (start-process "Diff" buf shell-file-name
135 shell-command-switch command)) 138 shell-command-switch command))
139 (set-process-filter proc 'diff-process-filter)
136 (set-process-sentinel 140 (set-process-sentinel
137 proc (lambda (proc msg) 141 proc (lambda (proc msg)
138 (with-current-buffer (process-buffer proc) 142 (with-current-buffer (process-buffer proc)
139 (diff-sentinel (process-exit-status proc)))))) 143 (diff-sentinel (process-exit-status proc))))))
140 ;; Async processes aren't available. 144 ;; Async processes aren't available.
141 (diff-sentinel 145 (let ((inhibit-read-only t))
142 (call-process shell-file-name nil buf nil 146 (diff-sentinel
143 shell-command-switch command)))) 147 (call-process shell-file-name nil buf nil
148 shell-command-switch command)))))
144 buf)) 149 buf))
145 150
151(defun diff-process-filter (proc string)
152 (with-current-buffer (process-buffer proc)
153 (let ((moving (= (point) (process-mark proc))))
154 (save-excursion
155 ;; Insert the text, advancing the process marker.
156 (goto-char (process-mark proc))
157 (let ((inhibit-read-only t))
158 (insert string))
159 (set-marker (process-mark proc) (point)))
160 (if moving (goto-char (process-mark proc))))))
161
146;;;###autoload 162;;;###autoload
147(defun diff-backup (file &optional switches) 163(defun diff-backup (file &optional switches)
148 "Diff this file with its backup file or vice versa. 164 "Diff this file with its backup file or vice versa.