Mercurial > emacs
changeset 12849:ce41e6df8986
(command-line-1): Add option --eval to evalute an
expression on the command line and print the result.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 14 Aug 1995 16:05:12 +0000 |
parents | 84beb7f8321f |
children | 0948f5af4680 |
files | lisp/startup.el |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/startup.el Mon Aug 14 16:04:48 1995 +0000 +++ b/lisp/startup.el Mon Aug 14 16:05:12 1995 +0000 @@ -101,6 +101,9 @@ ;; --funcall FUNC and should not be used. (It's a typo ;; -e FUNC promoted to a feature.) ;; +;; -eval FORM Execute Emacs lisp form FORM, and print +;; --eval FORM the value it returns. +;; ;; -insert FILE Insert the contents of FILE into buffer. ;; --insert FILE ;; ------------------------- @@ -674,7 +677,7 @@ ;; and long versions of what's on command-switch-alist. (longopts (append '(("--funcall") ("--load") ("--insert") ("--kill") - ("--directory")) + ("--directory") ("--eval")) (mapcar '(lambda (elt) (list (concat "-" (car elt)))) command-switch-alist))) @@ -717,6 +720,12 @@ (if (arrayp (symbol-function tem)) (command-execute tem) (funcall tem))) + ((string-equal argi "-eval") + (if argval + (setq tem argval) + (setq tem (car command-line-args-left)) + (setq command-line-args-left (cdr command-line-args-left))) + (print (eval (read tem)))) ;; Set the default directory as specified in -L. ((or (string-equal argi "-L") (string-equal argi "-directory"))