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