Mercurial > emacs
annotate lisp/eshell/em-script.el @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
| author | Jay Belanger <jay.p.belanger@gmail.com> |
|---|---|
| date | Sun, 23 Jan 2011 23:08:04 -0600 |
| parents | ef719132ddfa |
| children |
| rev | line source |
|---|---|
|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37661
diff
changeset
|
1 ;;; em-script.el --- Eshell script files |
| 29876 | 2 |
|
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
|
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2008, 2009, 2010, 2011 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 | |
|
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 29876 | 11 ;; it under the terms of the GNU General Public License as published by |
|
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
|
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
| 29876 | 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 | |
|
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 29876 | 22 |
|
87073
1577bd98c621
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
23 ;;; Commentary: |
| 29876 | 24 |
|
87073
1577bd98c621
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
25 ;;; Code: |
| 29876 | 26 |
| 48578 | 27 (require 'eshell) |
| 28 | |
|
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
29 ;;;###autoload |
|
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
30 (eshell-defgroup eshell-script nil |
| 29876 | 31 "This module allows for the execution of files containing Eshell |
| 32 commands, as a script file." | |
| 33 :tag "Running script files." | |
| 34 :group 'eshell-module) | |
| 35 | |
| 36 ;;; User Variables: | |
| 37 | |
| 38 (defcustom eshell-script-load-hook '(eshell-script-initialize) | |
|
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
39 "A list of functions to call when loading `eshell-script'." |
| 29876 | 40 :type 'hook |
| 41 :group 'eshell-script) | |
| 42 | |
|
104994
48428e99bf83
* eshell/em-hist.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
43 (defcustom eshell-login-script (expand-file-name "login" eshell-directory-name) |
|
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
44 "If non-nil, a file to invoke when starting up Eshell interactively. |
| 29876 | 45 This file should be a file containing Eshell commands, where comment |
| 46 lines begin with '#'." | |
| 47 :type 'file | |
| 48 :group 'eshell-script) | |
| 49 | |
|
104994
48428e99bf83
* eshell/em-hist.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
50 (defcustom eshell-rc-script (expand-file-name "profile" eshell-directory-name) |
|
110580
f57f72bb4757
Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
51 "If non-nil, a file to invoke whenever Eshell is started. |
| 29876 | 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)) | |
|
111686
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
93 (inhibit-point-motion-hooks t)) |
| 29876 | 94 (goto-char (point-max)) |
|
111686
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
95 (with-silent-modifications |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
96 ;; FIXME: Why not use a temporary buffer and avoid this |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
97 ;; "insert&delete" business? --Stef |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
98 (insert-file-contents file) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
99 (goto-char (point-max)) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
100 (throw 'eshell-replace-command |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
101 (prog1 |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
102 (list 'let |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
103 (list (list 'eshell-command-name (list 'quote file)) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
104 (list 'eshell-command-arguments |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
105 (list 'quote args))) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
106 (let ((cmd (eshell-parse-command (cons here (point))))) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
107 (if subcommand-p |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
108 (setq cmd (list 'eshell-as-subcommand cmd))) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
109 cmd)) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
110 (delete-region here (point)) |
|
e8049570c647
* lisp/eshell/: Use with-silent-modifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110580
diff
changeset
|
111 (goto-char orig)))))) |
| 29876 | 112 |
| 113 (defun eshell/source (&rest args) | |
| 114 "Source a file in a subshell environment." | |
| 115 (eshell-eval-using-options | |
| 116 "source" args | |
| 117 '((?h "help" nil nil "show this usage screen") | |
| 118 :show-usage | |
| 119 :usage "FILE [ARGS] | |
| 120 Invoke the Eshell commands in FILE in a subshell, binding ARGS to $1, | |
| 121 $2, etc.") | |
| 122 (eshell-source-file (car args) (cdr args) t))) | |
| 123 | |
|
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
33020
diff
changeset
|
124 (put 'eshell/source 'eshell-no-numeric-conversions t) |
|
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
33020
diff
changeset
|
125 |
| 29876 | 126 (defun eshell/. (&rest args) |
| 127 "Source a file in the current environment." | |
| 128 (eshell-eval-using-options | |
| 129 "." args | |
| 130 '((?h "help" nil nil "show this usage screen") | |
| 131 :show-usage | |
| 132 :usage "FILE [ARGS] | |
| 133 Invoke the Eshell commands in FILE within the current shell | |
| 134 environment, binding ARGS to $1, $2, etc.") | |
| 135 (eshell-source-file (car args) (cdr args)))) | |
| 136 | |
|
37661
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
33020
diff
changeset
|
137 (put 'eshell/. 'eshell-no-numeric-conversions t) |
|
6d7c89c79996
Set the property `eshell-no-numeric-conversions' on the following
John Wiegley <johnw@newartisans.com>
parents:
33020
diff
changeset
|
138 |
|
87073
1577bd98c621
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
139 (provide 'em-script) |
| 29876 | 140 |
|
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
141 ;; Local Variables: |
|
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
142 ;; generated-autoload-file: "esh-groups.el" |
|
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
143 ;; End: |
|
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
144 |
| 29876 | 145 ;;; em-script.el ends here |
