1 ;;; em-banner --- sample module that displays a login banner
3 ;; Copyright (C) 1999, 2000 Free Sofware Foundation
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
24 (eval-when-compile (require 'esh-maint
))
26 (defgroup eshell-banner nil
27 "This sample module displays a welcome banner at login.
28 It exists so that others wishing to create their own Eshell extension
29 modules may have a simple template to begin with."
31 :link
'(info-link "(eshell.info)Login banner")
32 :group
'eshell-module
)
36 ;; There is nothing to be done or configured in order to use this
37 ;; module, other than to select it by customizing the variable
38 ;; `eshell-modules-list'. It will then display a version information
39 ;; message whenever Eshell is loaded.
41 ;; This code is only an example of a how to write a well-formed
42 ;; extension module for Eshell. The better way to display login text
43 ;; is to use the `eshell-script' module, and to echo the desired
44 ;; strings from the user's `eshell-login-script' file.
46 ;; There is one configuration variable, which demonstrates how to
47 ;; properly define a customization variable in an extension module.
48 ;; In this case, it allows the user to change the string which
49 ;; displays at login time.
53 (defcustom eshell-banner-message
"Welcome to the Emacs shell\n\n"
54 "*The banner message to be displayed when Eshell is loaded.
55 This can be any sexp, and should end with at least two newlines."
57 :group
'eshell-banner
)
59 (put 'eshell-banner-message
'risky-local-variable t
)
65 (defcustom eshell-banner-load-hook
'(eshell-banner-initialize)
66 "*A list of functions to run when `eshell-banner' is loaded."
68 :group
'eshell-banner
)
70 (defun eshell-banner-initialize ()
71 "Output a welcome banner on initialization."
72 ;; it's important to use `eshell-interactive-print' rather than
73 ;; `insert', because `insert' doesn't know how to interact with the
74 ;; I/O code used by Eshell
75 (unless eshell-non-interactive-p
77 (assert eshell-banner-message
)
78 (let ((msg (eval eshell-banner-message
)))
80 (eshell-interactive-print msg
))))
82 (eshell-deftest banner banner-displayed
83 "Startup banner is displayed at point-min"
84 (assert eshell-banner-message
)
85 (let ((msg (eval eshell-banner-message
)))
87 (goto-char (point-min))
90 ;;; em-banner.el ends here