Merge changes made in Gnus trunk.
[bpt/emacs.git] / lisp / eshell / em-banner.el
CommitLineData
60370d40 1;;; em-banner.el --- sample module that displays a login banner
affbf647 2
3146b070 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
114f9c96 4;; 2008, 2009, 2010 Free Software Foundation, Inc.
affbf647 5
7de5b421
GM
6;; Author: John Wiegley <johnw@gnu.org>
7
affbf647
GM
8;; This file is part of GNU Emacs.
9
4ee57b2a 10;; GNU Emacs is free software: you can redistribute it and/or modify
affbf647 11;; it under the terms of the GNU General Public License as published by
4ee57b2a
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
affbf647
GM
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
4ee57b2a 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
affbf647 22
affbf647
GM
23;;; Commentary:
24
25;; There is nothing to be done or configured in order to use this
26;; module, other than to select it by customizing the variable
27;; `eshell-modules-list'. It will then display a version information
28;; message whenever Eshell is loaded.
29;;
30;; This code is only an example of a how to write a well-formed
31;; extension module for Eshell. The better way to display login text
32;; is to use the `eshell-script' module, and to echo the desired
33;; strings from the user's `eshell-login-script' file.
34;;
35;; There is one configuration variable, which demonstrates how to
36;; properly define a customization variable in an extension module.
37;; In this case, it allows the user to change the string which
38;; displays at login time.
39
784aa376
GM
40;;; Code:
41
42(eval-when-compile
43 (require 'cl)
44 (require 'esh-mode)
45 (require 'eshell))
46
47(require 'esh-util)
48
3146b070
GM
49;;;###autoload
50(eshell-defgroup eshell-banner nil
784aa376
GM
51 "This sample module displays a welcome banner at login.
52It exists so that others wishing to create their own Eshell extension
53modules may have a simple template to begin with."
54 :tag "Login banner"
55 ;; :link '(info-link "(eshell)Login banner")
56 :group 'eshell-module)
57
affbf647
GM
58;;; User Variables:
59
60(defcustom eshell-banner-message "Welcome to the Emacs shell\n\n"
ec60da52 61 "The banner message to be displayed when Eshell is loaded.
affbf647
GM
62This can be any sexp, and should end with at least two newlines."
63 :type 'sexp
64 :group 'eshell-banner)
65
66(put 'eshell-banner-message 'risky-local-variable t)
67
affbf647 68(defcustom eshell-banner-load-hook '(eshell-banner-initialize)
ec60da52 69 "A list of functions to run when `eshell-banner' is loaded."
affbf647
GM
70 :type 'hook
71 :group 'eshell-banner)
72
73(defun eshell-banner-initialize ()
74 "Output a welcome banner on initialization."
75 ;; it's important to use `eshell-interactive-print' rather than
76 ;; `insert', because `insert' doesn't know how to interact with the
77 ;; I/O code used by Eshell
78 (unless eshell-non-interactive-p
79 (assert eshell-mode)
80 (assert eshell-banner-message)
81 (let ((msg (eval eshell-banner-message)))
82 (assert msg)
83 (eshell-interactive-print msg))))
84
85(eshell-deftest banner banner-displayed
86 "Startup banner is displayed at point-min"
87 (assert eshell-banner-message)
88 (let ((msg (eval eshell-banner-message)))
89 (assert msg)
90 (goto-char (point-min))
91 (looking-at msg)))
92
784aa376
GM
93(provide 'em-banner)
94
3146b070
GM
95;; Local Variables:
96;; generated-autoload-file: "esh-groups.el"
97;; End:
98
cbee283d 99;; arch-tag: e738b4ef-8671-42ae-a757-291779b92491
affbf647 100;;; em-banner.el ends here