Mercurial > emacs
annotate lisp/eshell/em-banner.el @ 85310:22c169d62199
*** empty log message ***
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 15 Oct 2007 00:23:32 +0000 |
parents | a1e8300d3c55 |
children | 48c4bb2b7d11 fbd20b5beb80 f55f9811f5d7 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32526
diff
changeset
|
1 ;;; em-banner.el --- sample module that displays a login banner |
29876 | 2 |
74509 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
75346 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
29876 | 5 |
32526 | 6 ;; Author: John Wiegley <johnw@gnu.org> |
7 | |
29876 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
78220
a1e8300d3c55
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
12 ;; the Free Software Foundation; either version 3, or (at your option) |
29876 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
29876 | 24 |
25 (provide 'em-banner) | |
26 | |
27 (eval-when-compile (require 'esh-maint)) | |
28 | |
29 (defgroup eshell-banner nil | |
30 "This sample module displays a welcome banner at login. | |
31 It exists so that others wishing to create their own Eshell extension | |
32 modules may have a simple template to begin with." | |
33 :tag "Login banner" | |
54566
b73ba8cc2d91
* eshell/em-banner.el (eshell-banner):
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
34 ;; :link '(info-link "(eshell)Login banner") |
29876 | 35 :group 'eshell-module) |
36 | |
37 ;;; Commentary: | |
38 | |
39 ;; There is nothing to be done or configured in order to use this | |
40 ;; module, other than to select it by customizing the variable | |
41 ;; `eshell-modules-list'. It will then display a version information | |
42 ;; message whenever Eshell is loaded. | |
43 ;; | |
44 ;; This code is only an example of a how to write a well-formed | |
45 ;; extension module for Eshell. The better way to display login text | |
46 ;; is to use the `eshell-script' module, and to echo the desired | |
47 ;; strings from the user's `eshell-login-script' file. | |
48 ;; | |
49 ;; There is one configuration variable, which demonstrates how to | |
50 ;; properly define a customization variable in an extension module. | |
51 ;; In this case, it allows the user to change the string which | |
52 ;; displays at login time. | |
53 | |
54 ;;; User Variables: | |
55 | |
56 (defcustom eshell-banner-message "Welcome to the Emacs shell\n\n" | |
57 "*The banner message to be displayed when Eshell is loaded. | |
58 This can be any sexp, and should end with at least two newlines." | |
59 :type 'sexp | |
60 :group 'eshell-banner) | |
61 | |
62 (put 'eshell-banner-message 'risky-local-variable t) | |
63 | |
64 ;;; Code: | |
65 | |
66 (require 'esh-util) | |
67 | |
68 (defcustom eshell-banner-load-hook '(eshell-banner-initialize) | |
69 "*A list of functions to run when `eshell-banner' is loaded." | |
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 (eshell-deftest banner banner-displayed | |
86 "Startup banner is displayed at point-min" | |
87 (assert eshell-banner-message) | |
88 (let ((msg (eval eshell-banner-message))) | |
89 (assert msg) | |
90 (goto-char (point-min)) | |
91 (looking-at msg))) | |
92 | |
52401 | 93 ;;; arch-tag: e738b4ef-8671-42ae-a757-291779b92491 |
29876 | 94 ;;; em-banner.el ends here |