aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2011-03-20 23:42:23 -0700
committerGlenn Morris2011-03-20 23:42:23 -0700
commit4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (patch)
treeddfc048203efefeaaf8a07418748dab9ea4d260d
parent4359915b869931b94d530d9c6e1347f260d66951 (diff)
downloademacs-4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e.tar.gz
emacs-4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e.zip
* eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): Doc fixes.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/eshell/esh-opt.el55
2 files changed, 52 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d568b07bb15..d087982edee 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-03-21 Glenn Morris <rgm@gnu.org>
2
3 * eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args):
4 Doc fixes.
5
12011-03-21 Chong Yidong <cyd@stupidchicken.com> 62011-03-21 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * cus-theme.el: Add missing provide statement. 8 * cus-theme.el: Add missing provide statement.
diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el
index d7162406879..a9e8f11c39a 100644
--- a/lisp/eshell/esh-opt.el
+++ b/lisp/eshell/esh-opt.el
@@ -35,13 +35,51 @@ Eshell commands implemented in Lisp."
35 35
36;;; User Functions: 36;;; User Functions:
37 37
38(defmacro eshell-eval-using-options (name macro-args 38(defmacro eshell-eval-using-options (name macro-args options &rest body-forms)
39 options &rest body-forms)
40 "Process NAME's MACRO-ARGS using a set of command line OPTIONS. 39 "Process NAME's MACRO-ARGS using a set of command line OPTIONS.
41After doing so, settings will be stored in local symbols as declared 40After doing so, stores settings in local symbols as declared by OPTIONS;
42by OPTIONS; FORMS will then be evaluated -- assuming all was OK. 41then evaluates BODY-FORMS -- assuming all was OK.
43 42
44The syntax of OPTIONS is: 43OPTIONS is a list, beginning with one or more elements of the form:
44\(SHORT LONG VALUE SYMBOL HELP-STRING)
45Each of these elements represents a particular command-line switch.
46
47SHORT is either nil, or a character that can be used as a switch -SHORT.
48LONG is either nil, or a string that can be used as a switch --LONG.
49At least one of SHORT and LONG must be non-nil.
50VALUE is the value associated with the option. It can be either:
51 t - the option needs a value to be specified after the switch;
52 nil - the option is given the value t;
53 anything else - specifies the actual value for the option.
54SYMBOL is either nil, or the name of the Lisp symbol that will be bound
55to VALUE. A nil SYMBOL calls `eshell-show-usage', and so is appropriate
56for a \"--help\" type option.
57HELP-STRING is a documentation string for the option.
58
59Any remaining elements of OPTIONS are :KEYWORD arguments. Some take
60arguments, some do not. The recognized :KEYWORDS are:
61
62:external STRING
63 STRING is an external command to run if there are unknown switches.
64
65:usage STRING
66 STRING is the initial part of the command's documentation string.
67 It appears before the options are listed.
68
69:post-usage STRING
70 STRING is an optional trailing part of the command's documentation string.
71 It appears after the options, but before the final part of the
72 documentation about the associated external command (if there is one).
73
74:show-usage
75 If present, then show the usage message if the command is called with no
76 arguments.
77
78:preserve-args
79 If present, do not pass MACRO-ARGS through `eshell-flatten-list'
80and `eshell-stringify-list'.
81
82For example, OPTIONS might look like:
45 83
46 '((?C nil nil multi-column \"multi-column display\") 84 '((?C nil nil multi-column \"multi-column display\")
47 (nil \"help\" nil nil \"show this usage display\") 85 (nil \"help\" nil nil \"show this usage display\")
@@ -52,8 +90,9 @@ The syntax of OPTIONS is:
52 Sort entries alphabetically across.\") 90 Sort entries alphabetically across.\")
53 91
54`eshell-eval-using-options' returns the value of the last form in 92`eshell-eval-using-options' returns the value of the last form in
55BODY-FORMS. If instead an external command is run, the tag 93BODY-FORMS. If instead an external command is run (because of
56`eshell-external' will be thrown with the new process for its value. 94an unknown option), the tag `eshell-external' will be thrown with
95the new process for its value.
57 96
58Lastly, any remaining arguments will be available in a locally 97Lastly, any remaining arguments will be available in a locally
59interned variable `args' (created using a `let' form)." 98interned variable `args' (created using a `let' form)."
@@ -200,7 +239,7 @@ switch is unrecognized."
200 239
201(defun eshell-process-args (name args options) 240(defun eshell-process-args (name args options)
202 "Process the given ARGS using OPTIONS. 241 "Process the given ARGS using OPTIONS.
203This assumes that symbols have been intern'd by `eshell-with-options'." 242This assumes that symbols have been intern'd by `eshell-eval-using-options'."
204 (let ((ai 0) arg) 243 (let ((ai 0) arg)
205 (while (< ai (length args)) 244 (while (< ai (length args))
206 (setq arg (nth ai args)) 245 (setq arg (nth ai args))