aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2006-06-06 14:06:13 +0000
committerChong Yidong2006-06-06 14:06:13 +0000
commit53dd481c3fc408b0ebf32ae37a5884b3bd47cfee (patch)
treebec76072886098a3ff1f411ab11c71e1de1a9d58 /lisp
parent2e8e9e91955f7b75e832246a9de8763347353936 (diff)
downloademacs-53dd481c3fc408b0ebf32ae37a5884b3bd47cfee.tar.gz
emacs-53dd481c3fc408b0ebf32ae37a5884b3bd47cfee.zip
* diff-mode.el (diff-mode): Set buffer-read-only to t when
diff-default-read-only is non-nill. * diff.el (diff-sentinel, diff): Set inhibit-read-only to t when modifying the *Diff* buffer. (diff-process-filter): New filter function for diff process that sets inhibit-read-only to t when modifying the *Diff* buffer.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/diff-mode.el3
-rw-r--r--lisp/diff.el32
3 files changed, 35 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 10a133e6456..0dc4bdbba45 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12006-06-06 Chong Yidong <cyd@stupidchicken.com>
2
3 * diff-mode.el (diff-mode): Set buffer-read-only to t when
4 diff-default-read-only is non-nill.
5
6 * diff.el (diff-sentinel, diff): Set inhibit-read-only to t when
7 modifying the *Diff* buffer.
8 (diff-process-filter): New filter function for diff process that
9 sets inhibit-read-only to t when modifying the *Diff* buffer.
10
12006-06-06 Carsten Dominik <dominik@science.uva.nl> 112006-06-06 Carsten Dominik <dominik@science.uva.nl>
2 12
3 * textmodes/org.el: (org-archive-subtree): Use end-of-subtree as 13 * textmodes/org.el: (org-archive-subtree): Use end-of-subtree as
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index 1a8402e06c4..f78ce1ae155 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -993,8 +993,7 @@ a diff with \\[diff-reverse-direction]."
993 ;; compile support 993 ;; compile support
994 (set (make-local-variable 'next-error-function) 'diff-next-error) 994 (set (make-local-variable 'next-error-function) 'diff-next-error)
995 995
996 (when (and (> (point-max) (point-min)) diff-default-read-only) 996 (setq buffer-read-only diff-default-read-only)
997 (toggle-read-only t))
998 ;; setup change hooks 997 ;; setup change hooks
999 (if (not diff-update-on-the-fly) 998 (if (not diff-update-on-the-fly)
1000 (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t) 999 (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
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.