1 ;;; em-banner.el --- sample module that displays a login banner -*- lexical-binding:t -*-
3 ;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
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 3 of the License, or
12 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
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.
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.
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.
50 (defgroup eshell-banner nil
51 "This sample module displays a welcome banner at login.
52 It exists so that others wishing to create their own Eshell extension
53 modules may have a simple template to begin with."
55 ;; :link '(info-link "(eshell)Login banner")
56 :group
'eshell-module
))
60 (defcustom eshell-banner-message
"Welcome to the Emacs shell\n\n"
61 "The banner message to be displayed when Eshell is loaded.
62 This can be any sexp, and should end with at least two newlines."
64 :group
'eshell-banner
)
66 (put 'eshell-banner-message
'risky-local-variable t
)
68 (defcustom eshell-banner-load-hook nil
69 "A list of functions to run when `eshell-banner' is loaded."
70 :version
"24.1" ; removed eshell-banner-initialize
72 :group
'eshell-banner
)
74 (defun eshell-banner-initialize ()
75 "Output a welcome banner on initialization."
76 ;; it's important to use `eshell-interactive-print' rather than
77 ;; `insert', because `insert' doesn't know how to interact with the
78 ;; I/O code used by Eshell
79 (unless eshell-non-interactive-p
80 (cl-assert eshell-mode
)
81 (cl-assert eshell-banner-message
)
82 (let ((msg (eval eshell-banner-message
)))
84 (eshell-interactive-print msg
))))
89 ;; generated-autoload-file: "esh-groups.el"
92 ;;; em-banner.el ends here