Commit 90582f05 authored by Glenn Morris's avatar Glenn Morris
Browse files

Add a major-mode for the *Messages* buffer

Ref: http://lists.gnu.org/archive/html/emacs-devel/2010-02/msg00135.html

* lisp/simple.el (messages-buffer-mode): New major mode.
(messages-buffer): New function.

* lisp/startup.el (normal-top-level): Switch mode of *Messages* buffer.

* src/xdisp.c (message_dolog): If we create *Messages*,
switch it to messages-buffer-mode.

* lisp/emacs-lisp/ert.el (ert--force-message-log-buffer-truncation)
(ert-run-test): Use `message-buffer' function.
(ert--force-message-log-buffer-truncation): Ignore read-only.

* lisp/help.el (view-echo-area-messages): Use `message-buffer' function.

* lisp/mail/emacsbug.el (report-emacs-bug): Use `message-buffer' function.

* lisp/gnus/gnus-util.el (gnus-message-with-timestamp-1):
Use `message-buffer' function if available.  Ignore read-only.

* etc/NEWS: Mention this.
parent 33b83dd7
......@@ -93,6 +93,10 @@ simply disabling Transient Mark mode does the same thing.
** `initial-buffer-choice' can now specify a function to set up the
initial buffer.
** The *Messages* buffer is created in a new major mode `messages-buffer-mode',
and read-only. Code that might create the *Messages* buffer should
call the function `messages-buffer' to do so and set the mode.
** `remember-notes' creates a buffer whose content is saved on kill-emacs.
You may think of it as a *scratch* buffer whose content is preserved.
In fact, it was designed as a replacement for *scratch* buffer and can
......
2013-09-17 Glenn Morris <rgm@gnu.org>
* simple.el (messages-buffer-mode): New major mode.
(messages-buffer): New function.
* startup.el (normal-top-level): Switch mode of *Messages* buffer.
* emacs-lisp/ert.el (ert--force-message-log-buffer-truncation)
(ert-run-test): Use `message-buffer' function.
(ert--force-message-log-buffer-truncation): Ignore read-only.
* help.el (view-echo-area-messages): Use `message-buffer' function.
* mail/emacsbug.el (report-emacs-bug): Use `message-buffer' function.
2013-09-17 Stefan Monnier <monnier@iro.umontreal.ca>
* subr.el (eval-after-load): Preserve evaluation order (bug#15389).
......
......@@ -785,7 +785,7 @@ This mainly sets up debugger-related bindings."
"Immediately truncate *Messages* buffer according to `message-log-max'.
This can be useful after reducing the value of `message-log-max'."
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (messages-buffer)
;; This is a reimplementation of this part of message_dolog() in xdisp.c:
;; if (NATNUMP (Vmessage_log_max))
;; {
......@@ -798,7 +798,8 @@ This can be useful after reducing the value of `message-log-max'."
(end (save-excursion
(goto-char (point-max))
(forward-line (- message-log-max))
(point))))
(point)))
(inhibit-read-only t))
(delete-region begin end)))))
(defvar ert--running-tests nil
......@@ -818,7 +819,7 @@ Returns the result and stores it in ERT-TEST's `most-recent-result' slot."
(setf (ert-test-most-recent-result ert-test) nil)
(cl-block error
(let ((begin-marker
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (messages-buffer)
(point-max-marker))))
(unwind-protect
(let ((info (make-ert--test-execution-info
......@@ -837,7 +838,7 @@ Returns the result and stores it in ERT-TEST's `most-recent-result' slot."
(ert--run-test-internal info))
(let ((result (ert--test-execution-info-result info)))
(setf (ert-test-result-messages result)
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (messages-buffer)
(buffer-substring begin-marker (point-max))))
(ert--force-message-log-buffer-truncation)
(setq should-form-accu (nreverse should-form-accu))
......
2013-09-17 Glenn Morris <rgm@gnu.org>
* gnus-util.el (gnus-message-with-timestamp-1):
Use `message-buffer' function if available. Ignore read-only.
2013-09-16 Katsumi Yamaoka <yamaoka@jpl.org>
* message.el (message-expand-group, message-completion-in-region):
......
......@@ -514,11 +514,14 @@ but also to the ones displayed in the echo area."
(> message-log-max 0)
(/= (length str) 0))
(setq time (current-time))
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (if (fboundp 'messages-buffer)
(messages-buffer)
(get-buffer-create "*Messages*"))
(goto-char (point-max))
(insert ,timestamp str "\n")
(forward-line (- message-log-max))
(delete-region (point-min) (point))
(let ((inhibit-read-only t))
(insert ,timestamp str "\n")
(forward-line (- message-log-max))
(delete-region (point-min) (point)))
(goto-char (point-max))))
str)
(gnus-add-timestamp-to-message
......
;;; help.el --- help commands for Emacs
;; Copyright (C) 1985-1986, 1993-1994, 1998-2013 Free Software
;; Foundation, Inc.
;; Copyright (C) 1985-1986, 1993-1994, 1998-2013 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: help, internal
......@@ -412,7 +411,7 @@ With argument, display info only for the selected version."
The number of messages retained in that buffer
is specified by the variable `message-log-max'."
(interactive)
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (messages-buffer)
(goto-char (point-max))
(display-buffer (current-buffer))))
......
;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list
;; Copyright (C) 1985, 1994, 1997-1998, 2000-2013 Free Software
;; Foundation, Inc.
;; Copyright (C) 1985, 1994, 1997-1998, 2000-2013
;; Free Software Foundation, Inc.
;; Author: K. Shane Hartman
;; Maintainer: FSF
......@@ -160,7 +160,7 @@ Prompts for bug subject. Leaves you in a mail buffer."
(report-emacs-bug-can-use-osx-open)))
user-point message-end-point)
(setq message-end-point
(with-current-buffer (get-buffer-create "*Messages*")
(with-current-buffer (messages-buffer)
(point-max-marker)))
(compose-mail report-emacs-bug-address topic)
;; The rest of this does not execute if the user was asked to
......
......@@ -7344,6 +7344,18 @@ and setting it to nil."
buffer-invisibility-spec)
(setq buffer-invisibility-spec nil)))
(define-derived-mode messages-buffer-mode special-mode "Messages"
"Major mode used in the \"*Messages*\" buffer.")
(defun messages-buffer ()
"Return the \"*Messages*\" buffer.
If it does not exist, create and it switch it to `messages-buffer-mode'."
(or (get-buffer "*Messages*")
(with-current-buffer (get-buffer-create "*Messages*")
(messages-buffer-mode)
(current-buffer))))
;; Minibuffer prompt stuff.
;;(defun minibuffer-prompt-modification (start end)
......
;;; startup.el --- process Emacs shell arguments -*- lexical-binding: t -*-
;; Copyright (C) 1985-1986, 1992, 1994-2013 Free Software Foundation,
;; Inc.
;; Copyright (C) 1985-1986, 1992, 1994-2013 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
......@@ -494,6 +493,7 @@ It is the default value of the variable `top-level'."
(setq command-line-processed t)
(let ((dir default-directory))
(with-current-buffer "*Messages*"
(messages-buffer-mode)
;; Make it easy to do like "tail -f".
(set (make-local-variable 'window-point-insertion-type) t)
;; Give *Messages* the same default-directory as *scratch*,
......
2013-09-17 Glenn Morris <rgm@gnu.org>
* xdisp.c (message_dolog): If we create *Messages*,
switch it to messages-buffer-mode.
2013-09-17 Paul Eggert <eggert@cs.ucla.edu>
Don't overuse 'const' in types of locals.
......
/* Display generation from window structure and buffer text.
Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
Inc.
Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
......@@ -9538,7 +9537,20 @@ message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte)
old_deactivate_mark = Vdeactivate_mark;
oldbuf = current_buffer;
Fset_buffer (Fget_buffer_create (Vmessages_buffer_name));
/* Ensure the Messages buffer exists, and switch to it.
If we created it, set the major-mode. */
{
int newbuffer = 0;
if (NILP (Fget_buffer (Vmessages_buffer_name))) newbuffer = 1;
Fset_buffer (Fget_buffer_create (Vmessages_buffer_name));
if (newbuffer &&
!NILP (Ffboundp (intern ("messages-buffer-mode"))))
call0 (intern ("messages-buffer-mode"));
}
bset_undo_list (current_buffer, Qt);
oldpoint = message_dolog_marker1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment