diff options
| author | Glenn Morris | 2011-03-20 23:42:23 -0700 |
|---|---|---|
| committer | Glenn Morris | 2011-03-20 23:42:23 -0700 |
| commit | 4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (patch) | |
| tree | ddfc048203efefeaaf8a07418748dab9ea4d260d | |
| parent | 4359915b869931b94d530d9c6e1347f260d66951 (diff) | |
| download | emacs-4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e.tar.gz emacs-4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e.zip | |
* eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): Doc fixes.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/eshell/esh-opt.el | 55 |
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 @@ | |||
| 1 | 2011-03-21 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): | ||
| 4 | Doc fixes. | ||
| 5 | |||
| 1 | 2011-03-21 Chong Yidong <cyd@stupidchicken.com> | 6 | 2011-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. |
| 41 | After doing so, settings will be stored in local symbols as declared | 40 | After doing so, stores settings in local symbols as declared by OPTIONS; |
| 42 | by OPTIONS; FORMS will then be evaluated -- assuming all was OK. | 41 | then evaluates BODY-FORMS -- assuming all was OK. |
| 43 | 42 | ||
| 44 | The syntax of OPTIONS is: | 43 | OPTIONS is a list, beginning with one or more elements of the form: |
| 44 | \(SHORT LONG VALUE SYMBOL HELP-STRING) | ||
| 45 | Each of these elements represents a particular command-line switch. | ||
| 46 | |||
| 47 | SHORT is either nil, or a character that can be used as a switch -SHORT. | ||
| 48 | LONG is either nil, or a string that can be used as a switch --LONG. | ||
| 49 | At least one of SHORT and LONG must be non-nil. | ||
| 50 | VALUE 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. | ||
| 54 | SYMBOL is either nil, or the name of the Lisp symbol that will be bound | ||
| 55 | to VALUE. A nil SYMBOL calls `eshell-show-usage', and so is appropriate | ||
| 56 | for a \"--help\" type option. | ||
| 57 | HELP-STRING is a documentation string for the option. | ||
| 58 | |||
| 59 | Any remaining elements of OPTIONS are :KEYWORD arguments. Some take | ||
| 60 | arguments, 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' | ||
| 80 | and `eshell-stringify-list'. | ||
| 81 | |||
| 82 | For 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 |
| 55 | BODY-FORMS. If instead an external command is run, the tag | 93 | BODY-FORMS. If instead an external command is run (because of |
| 56 | `eshell-external' will be thrown with the new process for its value. | 94 | an unknown option), the tag `eshell-external' will be thrown with |
| 95 | the new process for its value. | ||
| 57 | 96 | ||
| 58 | Lastly, any remaining arguments will be available in a locally | 97 | Lastly, any remaining arguments will be available in a locally |
| 59 | interned variable `args' (created using a `let' form)." | 98 | interned 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. |
| 203 | This assumes that symbols have been intern'd by `eshell-with-options'." | 242 | This 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)) |