summaryrefslogtreecommitdiff
path: root/lisp/diff-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2001-09-22 19:11:24 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2001-09-22 19:11:24 +0000
commit769dd0f172ae5b1973af73eca0a1aa1c1cbf31b7 (patch)
tree172201ed20e0b5cd4f6ede5f4d26e1e2cc8cf408 /lisp/diff-mode.el
parent4b7dd7e2ff5d93bee2e1e591aa37d2b0ca4b617b (diff)
downloademacs-769dd0f172ae5b1973af73eca0a1aa1c1cbf31b7.tar.gz
emacs-769dd0f172ae5b1973af73eca0a1aa1c1cbf31b7.tar.bz2
emacs-769dd0f172ae5b1973af73eca0a1aa1c1cbf31b7.zip
(diff-default-read-only): New var.
(diff-mode): Use it.
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r--lisp/diff-mode.el16
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index 6d630e5a8ad..2c86b1fbeb3 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -69,6 +69,11 @@
:group 'tools
:group 'diff)
+(defcustom diff-default-read-only t
+ "If non-nil, `diff-mode' buffers default to being read-only."
+ :type 'boolean
+ :group 'diff-mode)
+
(defcustom diff-jump-to-old-file nil
"*Non-nil means `diff-goto-source' jumps to the old file.
Else, it jumps to the new file."
@@ -862,10 +867,9 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
;;;###autoload
(define-derived-mode diff-mode fundamental-mode "Diff"
"Major mode for viewing/editing context diffs.
-Supports unified and context diffs as well as (to a lesser extent) normal diffs.
-When the buffer is read-only, the ESC prefix is not necessary.
-This mode runs `diff-mode-hook'.
-\\{diff-mode-map}"
+Supports unified and context diffs as well as (to a lesser extent)
+normal diffs.
+When the buffer is read-only, the ESC prefix is not necessary."
(set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults)
(set (make-local-variable 'outline-regexp) diff-outline-regexp)
(set (make-local-variable 'imenu-generic-expression)
@@ -892,9 +896,9 @@ This mode runs `diff-mode-hook'.
;; (substring buffer-file-name 0 (match-beginning 0))))
;; (compilation-shell-minor-mode 1)
- ;; setup change hooks
- (unless (and (bobp) (eobp))
+ (when (and (> (point-max) (point-min)) diff-default-read-only)
(toggle-read-only t))
+ ;; setup change hooks
(if (not diff-update-on-the-fly)
(add-hook 'write-contents-hooks 'diff-write-contents-hooks)
(make-local-variable 'diff-unhandled-changes)