Mercurial > emacs
annotate lisp/eshell/em-script.el @ 37569:44748506225d
(cperl-font-lock-keywords)
(cperl-font-lock-keywords-1, cperl-font-lock-keywords-2):
Renamed from perl-font-lock-keywords to avoid clashes.
(cperl-mode, cperl-load-font-lock-keywords, cperl-init-faces)
(cperl-load-font-lock-keywords-1, cperl-load-font-lock-keywords-2):
Updated correspondingly.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 04 May 2001 20:16:47 +0000 |
parents | e21feeab77fb |
children | 6d7c89c79996 |
rev | line source |
---|---|
29876 | 1 ;;; em-script --- Eshell script files |
2 | |
29934
34b1ab9d583d
Change spelling of the Free Software Foundation.
Gerd Moellmann <gerd@gnu.org>
parents:
29876
diff
changeset
|
3 ;; Copyright (C) 1999, 2000 Free Software Foundation |
29876 | 4 |
32526 | 5 ;; Author: John Wiegley <johnw@gnu.org> |
6 | |
29876 | 7 ;; This file is part of GNU Emacs. |
8 | |
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 2, or (at your option) | |
12 ;; any later version. | |
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 | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 (provide 'em-script) | |
25 | |
26 (eval-when-compile (require 'esh-maint)) | |
27 | |
28 (defgroup eshell-script nil | |
29 "This module allows for the execution of files containing Eshell | |
30 commands, as a script file." | |
31 :tag "Running script files." | |
32 :group 'eshell-module) | |
33 | |
34 ;;; Commentary: | |
35 | |
36 ;;; User Variables: | |
37 | |
38 (defcustom eshell-script-load-hook '(eshell-script-initialize) | |
39 "*A list of functions to call when loading `eshell-script'." | |
40 :type 'hook | |
41 :group 'eshell-script) | |
42 | |
43 (defcustom eshell-login-script (concat eshell-directory-name "login") | |
44 "*If non-nil, a file to invoke when starting up Eshell interactively. | |
45 This file should be a file containing Eshell commands, where comment | |
46 lines begin with '#'." | |
47 :type 'file | |
48 :group 'eshell-script) | |
49 | |
50 (defcustom eshell-rc-script (concat eshell-directory-name "profile") | |
51 "*If non-nil, a file to invoke whenever Eshell is started. | |
52 This includes when running `eshell-command'." | |
53 :type 'file | |
54 :group 'eshell-script) | |
55 | |
56 ;;; Functions: | |
57 | |
58 (defun eshell-script-initialize () | |
59 "Initialize the script parsing code." | |
60 (make-local-variable 'eshell-interpreter-alist) | |
61 (setq eshell-interpreter-alist | |
62 (cons '((lambda (file) | |
63 (string= (file-name-nondirectory file) | |
64 "eshell")) . eshell/source) | |
65 eshell-interpreter-alist)) | |
33020 | 66 (make-local-variable 'eshell-complex-commands) |
67 (setq eshell-complex-commands | |
68 (append '("source" ".") eshell-complex-commands)) | |
29876 | 69 ;; these two variables are changed through usage, but we don't want |
70 ;; to ruin it for other modules | |
71 (let (eshell-inside-quote-regexp | |
72 eshell-outside-quote-regexp) | |
73 (and (not eshell-non-interactive-p) | |
74 eshell-login-script | |
75 (file-readable-p eshell-login-script) | |
76 (eshell-do-eval | |
77 (list 'eshell-commands | |
78 (catch 'eshell-replace-command | |
79 (eshell-source-file eshell-login-script))) t)) | |
80 (and eshell-rc-script | |
81 (file-readable-p eshell-rc-script) | |
82 (eshell-do-eval | |
83 (list 'eshell-commands | |
84 (catch 'eshell-replace-command | |
85 (eshell-source-file eshell-rc-script))) t)))) | |
86 | |
87 (defun eshell-source-file (file &optional args subcommand-p) | |
88 "Execute a series of Eshell commands in FILE, passing ARGS. | |
89 Comments begin with '#'." | |
90 (interactive "f") | |
91 (let ((orig (point)) | |
92 (here (point-max)) | |
93 (inhibit-point-motion-hooks t) | |
94 after-change-functions) | |
95 (goto-char (point-max)) | |
96 (insert-file-contents file) | |
97 (goto-char (point-max)) | |
98 (throw 'eshell-replace-command | |
99 (prog1 | |
100 (list 'let | |
101 (list (list 'eshell-command-name (list 'quote file)) | |
102 (list 'eshell-command-arguments | |
103 (list 'quote args))) | |
104 (let ((cmd (eshell-parse-command (cons here (point))))) | |
105 (if subcommand-p | |
106 (setq cmd (list 'eshell-as-subcommand cmd))) | |
107 cmd)) | |
108 (delete-region here (point)) | |
109 (goto-char orig))))) | |
110 | |
111 (defun eshell/source (&rest args) | |
112 "Source a file in a subshell environment." | |
113 (eshell-eval-using-options | |
114 "source" args | |
115 '((?h "help" nil nil "show this usage screen") | |
116 :show-usage | |
117 :usage "FILE [ARGS] | |
118 Invoke the Eshell commands in FILE in a subshell, binding ARGS to $1, | |
119 $2, etc.") | |
120 (eshell-source-file (car args) (cdr args) t))) | |
121 | |
122 (defun eshell/. (&rest args) | |
123 "Source a file in the current environment." | |
124 (eshell-eval-using-options | |
125 "." args | |
126 '((?h "help" nil nil "show this usage screen") | |
127 :show-usage | |
128 :usage "FILE [ARGS] | |
129 Invoke the Eshell commands in FILE within the current shell | |
130 environment, binding ARGS to $1, $2, etc.") | |
131 (eshell-source-file (car args) (cdr args)))) | |
132 | |
133 ;;; Code: | |
134 | |
135 ;;; em-script.el ends here |