]> code.delx.au - gnu-emacs/blob - lisp/eshell/em-banner.el
Merge from emacs-23; up to 2010-06-29T18:17:31Z!cyd@stupidchicken.com.
[gnu-emacs] / lisp / eshell / em-banner.el
1 ;;; em-banner.el --- sample module that displays a login banner
2
3 ;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
4
5 ;; Author: John Wiegley <johnw@gnu.org>
6
7 ;; This file is part of GNU Emacs.
8
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 3 of the License, or
12 ;; (at your option) any later version.
13
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.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; There is nothing to be done or configured in order to use this
25 ;; module, other than to select it by customizing the variable
26 ;; `eshell-modules-list'. It will then display a version information
27 ;; message whenever Eshell is loaded.
28 ;;
29 ;; This code is only an example of a how to write a well-formed
30 ;; extension module for Eshell. The better way to display login text
31 ;; is to use the `eshell-script' module, and to echo the desired
32 ;; strings from the user's `eshell-login-script' file.
33 ;;
34 ;; There is one configuration variable, which demonstrates how to
35 ;; properly define a customization variable in an extension module.
36 ;; In this case, it allows the user to change the string which
37 ;; displays at login time.
38
39 ;;; Code:
40
41 (eval-when-compile
42 (require 'cl)
43 (require 'esh-mode)
44 (require 'eshell))
45
46 (require 'esh-util)
47
48 ;;;###autoload
49 (eshell-defgroup eshell-banner nil
50 "This sample module displays a welcome banner at login.
51 It exists so that others wishing to create their own Eshell extension
52 modules may have a simple template to begin with."
53 :tag "Login banner"
54 ;; :link '(info-link "(eshell)Login banner")
55 :group 'eshell-module)
56
57 ;;; User Variables:
58
59 (defcustom eshell-banner-message "Welcome to the Emacs shell\n\n"
60 "The banner message to be displayed when Eshell is loaded.
61 This can be any sexp, and should end with at least two newlines."
62 :type 'sexp
63 :group 'eshell-banner)
64
65 (put 'eshell-banner-message 'risky-local-variable t)
66
67 (defcustom eshell-banner-load-hook nil
68 "A list of functions to run when `eshell-banner' is loaded."
69 :version "24.1" ; removed eshell-banner-initialize
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 (provide 'em-banner)
86
87 ;; Local Variables:
88 ;; generated-autoload-file: "esh-groups.el"
89 ;; End:
90
91 ;;; em-banner.el ends here