From: Spencer Baugh Date: Wed, 28 Jun 2023 12:48:01 +0000 (-0400) Subject: Make newly-created smerge-diff-buffers read-only X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5b019360d681f808f4336188cd85ada2f3593438;p=emacs.git Make newly-created smerge-diff-buffers read-only Buffers name *vc-diff* are usually created by vc, which makes them read-only. If we create such a buffer, let's make it read-only too. If the buffer already exists, though, don't change that since the user might have deliberately made it writable. * lisp/vc/smerge-mode.el (smerge-diff): Make newly-created smerge-diff-buffers read-only. (bug#64071) --- diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el index 7847a6c7670..e42b82c7064 100644 --- a/lisp/vc/smerge-mode.el +++ b/lisp/vc/smerge-mode.el @@ -1239,7 +1239,11 @@ spacing of the \"Lower\" chunk." (write-region beg1 end1 file1 nil 'nomessage) (write-region beg2 end2 file2 nil 'nomessage) (unwind-protect - (with-current-buffer (get-buffer-create smerge-diff-buffer-name) + (save-current-buffer + (if-let (buffer (get-buffer smerge-diff-buffer-name)) + (set-buffer buffer) + (set-buffer (get-buffer-create smerge-diff-buffer-name)) + (setq buffer-read-only t)) (setq default-directory dir) (let ((inhibit-read-only t)) (erase-buffer)