Mercurial > emacs
annotate lisp/eshell/em-banner.el @ 92329:1e0c26c0d529
*** empty log message ***
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 29 Feb 2008 03:03:57 +0000 |
parents | 107ccd98fa12 |
children | 606f2d163a64 1e3a407766b9 |
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, |
79707 | 4 ;; 2005, 2006, 2007, 2008 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 ;;; Commentary: | |
26 | |
27 ;; There is nothing to be done or configured in order to use this | |
28 ;; module, other than to select it by customizing the variable | |
29 ;; `eshell-modules-list'. It will then display a version information | |
30 ;; message whenever Eshell is loaded. | |
31 ;; | |
32 ;; This code is only an example of a how to write a well-formed | |
33 ;; extension module for Eshell. The better way to display login text | |
34 ;; is to use the `eshell-script' module, and to echo the desired | |
35 ;; strings from the user's `eshell-login-script' file. | |
36 ;; | |
37 ;; There is one configuration variable, which demonstrates how to | |
38 ;; properly define a customization variable in an extension module. | |
39 ;; In this case, it allows the user to change the string which | |
40 ;; displays at login time. | |
41 | |
87063
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
42 ;;; Code: |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
43 |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
44 (eval-when-compile |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
45 (require 'cl) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
46 (require 'esh-mode) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
47 (require 'eshell)) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
48 |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
49 (require 'esh-util) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
50 |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
51 (defgroup eshell-banner nil |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
52 "This sample module displays a welcome banner at login. |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
53 It exists so that others wishing to create their own Eshell extension |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
54 modules may have a simple template to begin with." |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
55 :tag "Login banner" |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
56 ;; :link '(info-link "(eshell)Login banner") |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
57 :group 'eshell-module) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
58 |
29876 | 59 ;;; User Variables: |
60 | |
61 (defcustom eshell-banner-message "Welcome to the Emacs shell\n\n" | |
62 "*The banner message to be displayed when Eshell is loaded. | |
63 This can be any sexp, and should end with at least two newlines." | |
64 :type 'sexp | |
65 :group 'eshell-banner) | |
66 | |
67 (put 'eshell-banner-message 'risky-local-variable t) | |
68 | |
69 (defcustom eshell-banner-load-hook '(eshell-banner-initialize) | |
70 "*A list of functions to run when `eshell-banner' is loaded." | |
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 | |
80 (assert eshell-mode) | |
81 (assert eshell-banner-message) | |
82 (let ((msg (eval eshell-banner-message))) | |
83 (assert msg) | |
84 (eshell-interactive-print msg)))) | |
85 | |
86 (eshell-deftest banner banner-displayed | |
87 "Startup banner is displayed at point-min" | |
88 (assert eshell-banner-message) | |
89 (let ((msg (eval eshell-banner-message))) | |
90 (assert msg) | |
91 (goto-char (point-min)) | |
92 (looking-at msg))) | |
93 | |
87063
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
94 (provide 'em-banner) |
fbd20b5beb80
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
95 |
52401 | 96 ;;; arch-tag: e738b4ef-8671-42ae-a757-291779b92491 |
29876 | 97 ;;; em-banner.el ends here |