diff options
| author | Richard M. Stallman | 1994-11-19 20:33:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-11-19 20:33:22 +0000 |
| commit | e491912f6b4d7d80d7d40ab941bb59c0edb88eac (patch) | |
| tree | 49446b4aadbc68defa2db4c743de2aeaf72d109c | |
| parent | 65091471be2bf598c3719a828ddf61e57b5b1b45 (diff) | |
| download | emacs-e491912f6b4d7d80d7d40ab941bb59c0edb88eac.tar.gz emacs-e491912f6b4d7d80d7d40ab941bb59c0edb88eac.zip | |
(x-option-alist): New variable now holds
list of short options. Don't set command-switch-alist.
(x-long-option-alist): New variable.
(x-handle-args): Detect long options and convert to short.
| -rw-r--r-- | lisp/term/x-win.el | 104 |
1 files changed, 73 insertions, 31 deletions
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index 9752dc16364..4bc8abfdf9b 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el | |||
| @@ -78,35 +78,53 @@ | |||
| 78 | 78 | ||
| 79 | (defvar x-command-line-resources nil) | 79 | (defvar x-command-line-resources nil) |
| 80 | 80 | ||
| 81 | (setq command-switch-alist | 81 | (defconst x-option-alist |
| 82 | (append '(("-bw" . x-handle-numeric-switch) | 82 | '(("-bw" . x-handle-numeric-switch) |
| 83 | ("-d" . x-handle-display) | 83 | ("-d" . x-handle-display) |
| 84 | ("-display" . x-handle-display) | 84 | ("-display" . x-handle-display) |
| 85 | ("-name" . x-handle-name-rn-switch) | 85 | ("-name" . x-handle-name-rn-switch) |
| 86 | ("-rn" . x-handle-name-rn-switch) | 86 | ("-rn" . x-handle-name-rn-switch) |
| 87 | ("-T" . x-handle-switch) | 87 | ("-T" . x-handle-switch) |
| 88 | ("-r" . x-handle-switch) | 88 | ("-r" . x-handle-switch) |
| 89 | ("-rv" . x-handle-switch) | 89 | ("-rv" . x-handle-switch) |
| 90 | ("-reverse" . x-handle-switch) | 90 | ("-reverse" . x-handle-switch) |
| 91 | ("-fn" . x-handle-switch) | 91 | ("-fn" . x-handle-switch) |
| 92 | ("-font" . x-handle-switch) | 92 | ("-font" . x-handle-switch) |
| 93 | ("-ib" . x-handle-numeric-switch) | 93 | ("-ib" . x-handle-numeric-switch) |
| 94 | ("-g" . x-handle-geometry) | 94 | ("-g" . x-handle-geometry) |
| 95 | ("-geometry" . x-handle-geometry) | 95 | ("-geometry" . x-handle-geometry) |
| 96 | ("-fg" . x-handle-switch) | 96 | ("-fg" . x-handle-switch) |
| 97 | ("-foreground". x-handle-switch) | 97 | ("-foreground". x-handle-switch) |
| 98 | ("-bg" . x-handle-switch) | 98 | ("-bg" . x-handle-switch) |
| 99 | ("-background". x-handle-switch) | 99 | ("-background". x-handle-switch) |
| 100 | ("-ms" . x-handle-switch) | 100 | ("-ms" . x-handle-switch) |
| 101 | ("-itype" . x-handle-switch) | 101 | ("-itype" . x-handle-switch) |
| 102 | ("-i" . x-handle-switch) | 102 | ("-i" . x-handle-switch) |
| 103 | ("-iconic" . x-handle-iconic) | 103 | ("-iconic" . x-handle-iconic) |
| 104 | ("-xrm" . x-handle-xrm-switch) | 104 | ("-xrm" . x-handle-xrm-switch) |
| 105 | ("-cr" . x-handle-switch) | 105 | ("-cr" . x-handle-switch) |
| 106 | ("-vb" . x-handle-switch) | 106 | ("-vb" . x-handle-switch) |
| 107 | ("-hb" . x-handle-switch) | 107 | ("-hb" . x-handle-switch) |
| 108 | ("-bd" . x-handle-switch)) | 108 | ("-bd" . x-handle-switch))) |
| 109 | command-switch-alist)) | 109 | |
| 110 | (defconst x-long-option-alist | ||
| 111 | '(("--border-width" . "-bw") | ||
| 112 | ("--display" . "-d") | ||
| 113 | ("--name" . "-name") | ||
| 114 | ("--title" . "-T") | ||
| 115 | ("--reverse-video" . "-reverse") | ||
| 116 | ("--font" . "-font") | ||
| 117 | ("--internal-border" . "-ib") | ||
| 118 | ("--geometry" . "-geometry") | ||
| 119 | ("--foreground-color" . "-fg") | ||
| 120 | ("--background-color" . "-bg") | ||
| 121 | ("--mouse-color" . "-ms") | ||
| 122 | ("--icon-type" . "-itype") | ||
| 123 | ("--iconic" . "-iconic") | ||
| 124 | ("--xrm" . "-xrm") | ||
| 125 | ("--cursor-color" . "-cr") | ||
| 126 | ("--vertical-scroll-bars" . "-vb") | ||
| 127 | ("--border-color" . "-bd"))) | ||
| 110 | 128 | ||
| 111 | (defconst x-switch-definitions | 129 | (defconst x-switch-definitions |
| 112 | '(("-name" name) | 130 | '(("-name" name) |
| @@ -207,14 +225,38 @@ x-invocation args from which the X-related things are extracted, first | |||
| 207 | the switch (e.g., \"-fg\") in the following code, and possible values | 225 | the switch (e.g., \"-fg\") in the following code, and possible values |
| 208 | \(e.g., \"black\") in the option handler code (e.g., x-handle-switch). | 226 | \(e.g., \"black\") in the option handler code (e.g., x-handle-switch). |
| 209 | This returns ARGS with the arguments that have been processed removed." | 227 | This returns ARGS with the arguments that have been processed removed." |
| 228 | (message "%s" args) | ||
| 210 | (setq x-invocation-args args | 229 | (setq x-invocation-args args |
| 211 | args nil) | 230 | args nil) |
| 212 | (while x-invocation-args | 231 | (while x-invocation-args |
| 213 | (let* ((this-switch (car x-invocation-args)) | 232 | (let* ((this-switch (car x-invocation-args)) |
| 214 | (aelt (assoc this-switch command-switch-alist))) | 233 | (orig-this-switch this-switch) |
| 234 | completion argval aelt) | ||
| 215 | (setq x-invocation-args (cdr x-invocation-args)) | 235 | (setq x-invocation-args (cdr x-invocation-args)) |
| 236 | ;; Check for long options with attached arguments | ||
| 237 | ;; and separate out the attached option argument into argval. | ||
| 238 | (if (string-match "^--[^=]*=" this-switch) | ||
| 239 | (setq argval (substring this-switch (match-end 0)) | ||
| 240 | this-switch (substring this-switch 0 (1- (match-end 0))))) | ||
| 241 | (setq completion (try-completion this-switch x-long-option-alist)) | ||
| 242 | (if (eq completion t) | ||
| 243 | ;; Exact match for long option. | ||
| 244 | (setq this-switch (cdr (assoc this-switch x-long-option-alist))) | ||
| 245 | (if (stringp completion) | ||
| 246 | (let ((elt (assoc completion x-long-option-alist))) | ||
| 247 | ;; Check for abbreviated long option. | ||
| 248 | (or elt | ||
| 249 | (error "Option `%s' is ambiguous" this-switch)) | ||
| 250 | (setq this-switch (cdr elt))) | ||
| 251 | ;; Check for a short option. | ||
| 252 | (setq argval nil this-switch orig-this-switch))) | ||
| 253 | (setq aelt (assoc this-switch x-option-alist)) | ||
| 216 | (if aelt | 254 | (if aelt |
| 217 | (funcall (cdr aelt) this-switch) | 255 | (if argval |
| 256 | (let ((x-invocation-args | ||
| 257 | (cons argval x-invocation-args))) | ||
| 258 | (funcall (cdr aelt) this-switch)) | ||
| 259 | (funcall (cdr aelt) this-switch)) | ||
| 218 | (setq args (cons this-switch args))))) | 260 | (setq args (cons this-switch args))))) |
| 219 | (setq args (nreverse args))) | 261 | (setq args (nreverse args))) |
| 220 | 262 | ||