From f79c33b39f195d1b30d7a3e085804e45ab76358e Mon Sep 17 00:00:00 2001 From: Sam Steingold Date: Wed, 22 Nov 2017 16:14:22 -0500 Subject: [PATCH] Use special-mode for read-only buffers. * lisp/progmodes/etags.el (tags-table-mode): Define using `define-derived-mode', inheriting from `special-mode'. Not only the buffer is now read-only, but you can bury it with "q". (select-tags-table-mode): No need to set `buffer-read-only' explicitly, `special-mode' takes care of that. * lisp/vc/log-edit.el (log-edit-show-files): Use `special-mode' instead of setting `buffer-read-only' explicitly. --- lisp/progmodes/etags.el | 9 +++------ lisp/vc/log-edit.el | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 619c2ed6877..50a9f8190db 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -274,12 +274,9 @@ buffer-local and set them to nil." (run-hook-with-args-until-success 'tags-table-format-functions)) ;;;###autoload -(defun tags-table-mode () +(define-derived-mode tags-table-mode special-mode "Tags Table" "Major mode for tags table file buffers." - (interactive) - (setq major-mode 'tags-table-mode ;FIXME: Use define-derived-mode. - mode-name "Tags Table" - buffer-undo-list t) + (setq buffer-undo-list t) (initialize-new-tags-table)) ;;;###autoload @@ -2060,7 +2057,7 @@ see the doc of that variable if you want to add names to the list." (define-derived-mode select-tags-table-mode special-mode "Select Tags Table" "Major mode for choosing a current tags table among those already loaded." - (setq buffer-read-only t)) + ) (defun select-tags-table-select (button) "Select the tags table named on this line." diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 44e7cd78ee5..30457d1e2d3 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -623,7 +623,7 @@ Also saves its contents in the comment history and hides (setq buffer-read-only nil) (erase-buffer) (cvs-insert-strings files) - (setq buffer-read-only t) + (special-mode) (goto-char (point-min)) (save-selected-window (cvs-pop-to-buffer-same-frame buf) -- 2.39.2