* src/fns.c (Fcompare_strings): Use FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE.
[bpt/emacs.git] / lisp / eshell / em-banner.el
CommitLineData
ae5e4c48 1;;; em-banner.el --- sample module that displays a login banner -*- lexical-binding:t -*-
affbf647 2
ba318903 3;; Copyright (C) 1999-2014 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
f87b1284 42 (require 'cl-lib))
784aa376
GM
43
44(require 'esh-util)
f87b1284
GM
45(require 'esh-mode)
46(require 'eshell)
784aa376 47
3146b070 48;;;###autoload
35ff222c
GM
49(progn
50(defgroup eshell-banner nil
784aa376
GM
51 "This sample module displays a welcome banner at login.
52It exists so that others wishing to create their own Eshell extension
53modules may have a simple template to begin with."
54 :tag "Login banner"
55 ;; :link '(info-link "(eshell)Login banner")
35ff222c 56 :group 'eshell-module))
784aa376 57
affbf647
GM
58;;; User Variables:
59
60(defcustom eshell-banner-message "Welcome to the Emacs shell\n\n"
ec60da52 61 "The banner message to be displayed when Eshell is loaded.
affbf647
GM
62This can be any sexp, and should end with at least two newlines."
63 :type 'sexp
64 :group 'eshell-banner)
65
66(put 'eshell-banner-message 'risky-local-variable t)
67
d783d303 68(defcustom eshell-banner-load-hook nil
ec60da52 69 "A list of functions to run when `eshell-banner' is loaded."
d783d303 70 :version "24.1" ; removed eshell-banner-initialize
affbf647
GM
71 :type 'hook
72 :group 'eshell-banner)
73
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
a464a6c7
SM
80 (cl-assert eshell-mode)
81 (cl-assert eshell-banner-message)
affbf647 82 (let ((msg (eval eshell-banner-message)))
a464a6c7 83 (cl-assert msg)
affbf647
GM
84 (eshell-interactive-print msg))))
85
784aa376
GM
86(provide 'em-banner)
87
3146b070
GM
88;; Local Variables:
89;; generated-autoload-file: "esh-groups.el"
90;; End:
91
affbf647 92;;; em-banner.el ends here