X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a62d56ab3b4701d890237ff0bfb031e7769526a6..ae95a95a9c144a8ceefb9b2c9c09497705209ab1:/lisp/diff-mode.el diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index b01ea535ac..2c86b1fbeb 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el @@ -1,6 +1,6 @@ ;;; diff-mode.el --- A mode for viewing/editing context diffs -;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. ;; Author: Stefan Monnier ;; Keywords: patch diff @@ -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,8 +896,9 @@ This mode runs `diff-mode-hook'. ;; (substring buffer-file-name 0 (match-beginning 0)))) ;; (compilation-shell-minor-mode 1) + (when (and (> (point-max) (point-min)) diff-default-read-only) + (toggle-read-only t)) ;; setup change hooks - (toggle-read-only t) (if (not diff-update-on-the-fly) (add-hook 'write-contents-hooks 'diff-write-contents-hooks) (make-local-variable 'diff-unhandled-changes)