Commit | Line | Data |
---|---|---|
60370d40 | 1 | ;;; em-banner.el --- sample module that displays a login banner |
affbf647 | 2 | |
73b0cd50 | 3 | ;; Copyright (C) 1999-2011 Free Software Foundation, Inc. |
affbf647 | 4 | |
7de5b421 GM |
5 | ;; Author: John Wiegley <johnw@gnu.org> |
6 | ||
affbf647 GM |
7 | ;; This file is part of GNU Emacs. |
8 | ||
4ee57b2a | 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
affbf647 | 10 | ;; it under the terms of the GNU General Public License as published by |
4ee57b2a GM |
11 | ;; the Free Software Foundation, either version 3 of the License, or |
12 | ;; (at your option) any later version. | |
affbf647 GM |
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 | |
4ee57b2a | 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
affbf647 | 21 | |
affbf647 GM |
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 | ||
784aa376 GM |
39 | ;;; Code: |
40 | ||
41 | (eval-when-compile | |
42 | (require 'cl) | |
43 | (require 'esh-mode) | |
44 | (require 'eshell)) | |
45 | ||
46 | (require 'esh-util) | |
47 | ||
3146b070 GM |
48 | ;;;###autoload |
49 | (eshell-defgroup eshell-banner nil | |
784aa376 GM |
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 | ||
affbf647 GM |
57 | ;;; User Variables: |
58 | ||
59 | (defcustom eshell-banner-message "Welcome to the Emacs shell\n\n" | |
ec60da52 | 60 | "The banner message to be displayed when Eshell is loaded. |
affbf647 GM |
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 | ||
d783d303 | 67 | (defcustom eshell-banner-load-hook nil |
ec60da52 | 68 | "A list of functions to run when `eshell-banner' is loaded." |
d783d303 | 69 | :version "24.1" ; removed eshell-banner-initialize |
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 | ||
784aa376 GM |
85 | (provide 'em-banner) |
86 | ||
3146b070 GM |
87 | ;; Local Variables: |
88 | ;; generated-autoload-file: "esh-groups.el" | |
89 | ;; End: | |
90 | ||
affbf647 | 91 | ;;; em-banner.el ends here |