diff options
| author | Glenn Morris | 2010-10-25 20:58:19 -0700 |
|---|---|---|
| committer | Glenn Morris | 2010-10-25 20:58:19 -0700 |
| commit | d7d8c62a57e7b4ff8625bccf4e95f8fac7763b26 (patch) | |
| tree | 48db08a0f4c8534c0706afa2044f54532f78032c /lisp/term | |
| parent | 57c17ca45a12cf325007e6ca0d8e1d1102970ff8 (diff) | |
| download | emacs-d7d8c62a57e7b4ff8625bccf4e95f8fac7763b26.tar.gz emacs-d7d8c62a57e7b4ff8625bccf4e95f8fac7763b26.zip | |
Remove ns-handle-* functions that duplicate x-handle-*.
* lisp/term/ns-win.el (ns-version-string): Remove unused declaration.
(ns-invocation-args): Change to x-invocation-args.
(ns-handle-switch, ns-handle-numeric-switch, ns-handle-iconic)
(ns-handle-name-switch, ns-ignore-2-arg): Remove.
(ns-handle-nxopen, ns-handle-nxopentemp, ns-ignore-1-arg):
Use x-invocation-args instead of ns-invocation-args.
(ns-initialize-window-system, handle-args-function-alist):
Use x-handle-args instead of ns-handle-args.
* lisp/term/common-win.el (x-handle-args): Also handle nextstep arguments.
* lisp/startup.el (command-line-ns-option-alist): Replace
ns-handle-name-switch, ns-handle-switch, ns-handle-numeric-switch,
ns-handle-iconic with the x- equivalents.
Diffstat (limited to 'lisp/term')
| -rw-r--r-- | lisp/term/common-win.el | 23 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 87 |
2 files changed, 23 insertions, 87 deletions
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el index ff69ff9404b..98baf826712 100644 --- a/lisp/term/common-win.el +++ b/lisp/term/common-win.el | |||
| @@ -316,12 +316,14 @@ On X, the display name of individual X frames is recorded in the | |||
| 316 | (setenv "DISPLAY" x-display-name)) | 316 | (setenv "DISPLAY" x-display-name)) |
| 317 | 317 | ||
| 318 | (defun x-handle-args (args) | 318 | (defun x-handle-args (args) |
| 319 | "Process the X-related command line options in ARGS. | 319 | "Process the X (or Nextstep) related command line options in ARGS. |
| 320 | This is done before the user's startup file is loaded. They are copied to | 320 | This is done before the user's startup file is loaded. |
| 321 | `x-invocation-args', from which the X-related things are extracted, first | 321 | Copies the options in ARGS to `x-invocation-args'. It then extracts |
| 322 | the switch (e.g., \"-fg\") in the following code, and possible values | 322 | the X (or Nextstep) options according to the handlers defined in |
| 323 | \(e.g., \"black\") in the option handler code (e.g., x-handle-switch). | 323 | `command-line-x-option-alist' (or `command-line-ns-option-alist'). |
| 324 | This function returns ARGS minus the arguments that have been processed." | 324 | For example, `x-handle-switch' handles a switch like \"-fg\" and its |
| 325 | value \"black\". This function returns ARGS minus the arguments that | ||
| 326 | have been processed." | ||
| 325 | ;; We use ARGS to accumulate the args that we don't handle here, to return. | 327 | ;; We use ARGS to accumulate the args that we don't handle here, to return. |
| 326 | (setq x-invocation-args args ; FIXME let-bind? | 328 | (setq x-invocation-args args ; FIXME let-bind? |
| 327 | args nil) | 329 | args nil) |
| @@ -329,6 +331,9 @@ This function returns ARGS minus the arguments that have been processed." | |||
| 329 | (not (equal (car x-invocation-args) "--"))) | 331 | (not (equal (car x-invocation-args) "--"))) |
| 330 | (let* ((this-switch (pop x-invocation-args)) | 332 | (let* ((this-switch (pop x-invocation-args)) |
| 331 | (orig-this-switch this-switch) | 333 | (orig-this-switch this-switch) |
| 334 | (option-alist (if (featurep 'ns) | ||
| 335 | command-line-ns-option-alist | ||
| 336 | command-line-x-option-alist)) | ||
| 332 | completion argval aelt handler) | 337 | completion argval aelt handler) |
| 333 | ;; Check for long options with attached arguments | 338 | ;; Check for long options with attached arguments |
| 334 | ;; and separate out the attached option argument into argval. | 339 | ;; and separate out the attached option argument into argval. |
| @@ -338,17 +343,17 @@ This function returns ARGS minus the arguments that have been processed." | |||
| 338 | ;; Complete names of long options. | 343 | ;; Complete names of long options. |
| 339 | (if (string-match "^--" this-switch) | 344 | (if (string-match "^--" this-switch) |
| 340 | (progn | 345 | (progn |
| 341 | (setq completion (try-completion this-switch command-line-x-option-alist)) | 346 | (setq completion (try-completion this-switch option-alist)) |
| 342 | (if (eq completion t) | 347 | (if (eq completion t) |
| 343 | ;; Exact match for long option. | 348 | ;; Exact match for long option. |
| 344 | nil | 349 | nil |
| 345 | (if (stringp completion) | 350 | (if (stringp completion) |
| 346 | (let ((elt (assoc completion command-line-x-option-alist))) | 351 | (let ((elt (assoc completion option-alist))) |
| 347 | ;; Check for abbreviated long option. | 352 | ;; Check for abbreviated long option. |
| 348 | (or elt | 353 | (or elt |
| 349 | (error "Option `%s' is ambiguous" this-switch)) | 354 | (error "Option `%s' is ambiguous" this-switch)) |
| 350 | (setq this-switch completion)))))) | 355 | (setq this-switch completion)))))) |
| 351 | (setq aelt (assoc this-switch command-line-x-option-alist)) | 356 | (setq aelt (assoc this-switch option-alist)) |
| 352 | (if aelt (setq handler (nth 2 aelt))) | 357 | (if aelt (setq handler (nth 2 aelt))) |
| 353 | (if handler | 358 | (if handler |
| 354 | (if argval | 359 | (if argval |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index b09dd7a01f7..6541ee4b68c 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -58,99 +58,30 @@ | |||
| 58 | :group 'environment) | 58 | :group 'environment) |
| 59 | 59 | ||
| 60 | ;; nsterm.m | 60 | ;; nsterm.m |
| 61 | (defvar ns-version-string) | ||
| 62 | (defvar ns-alternate-modifier) | 61 | (defvar ns-alternate-modifier) |
| 63 | (defvar ns-right-alternate-modifier) | 62 | (defvar ns-right-alternate-modifier) |
| 64 | 63 | ||
| 65 | ;;;; Command line argument handling. | 64 | ;;;; Command line argument handling. |
| 66 | 65 | ||
| 67 | (defvar ns-invocation-args nil) | 66 | (defvar x-invocation-args) |
| 68 | (defvar ns-command-line-resources nil) | 67 | (defvar ns-command-line-resources nil) ; FIXME unused? |
| 69 | |||
| 70 | ;; Handler for switches of the form "-switch value" or "-switch". | ||
| 71 | (defun ns-handle-switch (switch &optional numeric) | ||
| 72 | (let ((aelt (assoc switch command-line-ns-option-alist))) | ||
| 73 | (if aelt | ||
| 74 | (setq default-frame-alist | ||
| 75 | (cons (cons (nth 3 aelt) | ||
| 76 | (if numeric | ||
| 77 | (string-to-number (pop ns-invocation-args)) | ||
| 78 | (or (nth 4 aelt) (pop ns-invocation-args)))) | ||
| 79 | default-frame-alist))))) | ||
| 80 | |||
| 81 | ;; Handler for switches of the form "-switch n" | ||
| 82 | (defun ns-handle-numeric-switch (switch) | ||
| 83 | (ns-handle-switch switch t)) | ||
| 84 | |||
| 85 | (defalias 'ns-handle-iconic 'x-handle-iconic) | ||
| 86 | |||
| 87 | ;; Handle the -name option, set the name of the initial frame. | ||
| 88 | (defun ns-handle-name-switch (switch) | ||
| 89 | (or (consp ns-invocation-args) | ||
| 90 | (error "%s: missing argument to `%s' option" (invocation-name) switch)) | ||
| 91 | (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args)) | ||
| 92 | initial-frame-alist))) | ||
| 93 | 68 | ||
| 94 | ;; nsterm.m. | 69 | ;; nsterm.m. |
| 95 | (defvar ns-input-file) | 70 | (defvar ns-input-file) |
| 96 | 71 | ||
| 97 | (defun ns-handle-nxopen (switch) | 72 | (defun ns-handle-nxopen (switch) |
| 98 | (setq unread-command-events (append unread-command-events '(ns-open-file)) | 73 | (setq unread-command-events (append unread-command-events '(ns-open-file)) |
| 99 | ns-input-file (append ns-input-file (list (pop ns-invocation-args))))) | 74 | ns-input-file (append ns-input-file (list (pop x-invocation-args))))) |
| 100 | 75 | ||
| 101 | (defun ns-handle-nxopentemp (switch) | 76 | (defun ns-handle-nxopentemp (switch) |
| 102 | (setq unread-command-events (append unread-command-events | 77 | (setq unread-command-events (append unread-command-events |
| 103 | '(ns-open-temp-file)) | 78 | '(ns-open-temp-file)) |
| 104 | ns-input-file (append ns-input-file (list (pop ns-invocation-args))))) | 79 | ns-input-file (append ns-input-file (list (pop x-invocation-args))))) |
| 105 | 80 | ||
| 106 | (defun ns-ignore-1-arg (switch) | 81 | (defun ns-ignore-1-arg (switch) |
| 107 | (setq ns-invocation-args (cdr ns-invocation-args))) | 82 | (setq x-invocation-args (cdr x-invocation-args))) |
| 108 | (defun ns-ignore-2-arg (switch) | 83 | (defun ns-ignore-2-arg (switch) ; FIXME unused? |
| 109 | (setq ns-invocation-args (cddr ns-invocation-args))) | 84 | (setq x-invocation-args (cddr x-invocation-args))) |
| 110 | |||
| 111 | (defun ns-handle-args (args) | ||
| 112 | "Process Nextstep-related command line options. | ||
| 113 | This is run before the user's startup file is loaded. | ||
| 114 | The options in ARGS are copied to `ns-invocation-args'. | ||
| 115 | The Nextstep-related settings are then applied using the handlers | ||
| 116 | defined in `command-line-ns-option-alist'. | ||
| 117 | The return value is ARGS minus the number of arguments processed." | ||
| 118 | ;; We use ARGS to accumulate the args that we don't handle here, to return. | ||
| 119 | (setq ns-invocation-args args | ||
| 120 | args nil) | ||
| 121 | (while ns-invocation-args | ||
| 122 | (let* ((this-switch (pop ns-invocation-args)) | ||
| 123 | (orig-this-switch this-switch) | ||
| 124 | completion argval aelt handler) | ||
| 125 | ;; Check for long options with attached arguments | ||
| 126 | ;; and separate out the attached option argument into argval. | ||
| 127 | (if (string-match "^--[^=]*=" this-switch) | ||
| 128 | (setq argval (substring this-switch (match-end 0)) | ||
| 129 | this-switch (substring this-switch 0 (1- (match-end 0))))) | ||
| 130 | ;; Complete names of long options. | ||
| 131 | (if (string-match "^--" this-switch) | ||
| 132 | (progn | ||
| 133 | (setq completion (try-completion this-switch | ||
| 134 | command-line-ns-option-alist)) | ||
| 135 | (if (eq completion t) | ||
| 136 | ;; Exact match for long option. | ||
| 137 | nil | ||
| 138 | (if (stringp completion) | ||
| 139 | (let ((elt (assoc completion command-line-ns-option-alist))) | ||
| 140 | ;; Check for abbreviated long option. | ||
| 141 | (or elt | ||
| 142 | (error "Option `%s' is ambiguous" this-switch)) | ||
| 143 | (setq this-switch completion)))))) | ||
| 144 | (setq aelt (assoc this-switch command-line-ns-option-alist)) | ||
| 145 | (if aelt (setq handler (nth 2 aelt))) | ||
| 146 | (if handler | ||
| 147 | (if argval | ||
| 148 | (let ((ns-invocation-args | ||
| 149 | (cons argval ns-invocation-args))) | ||
| 150 | (funcall handler this-switch)) | ||
| 151 | (funcall handler this-switch)) | ||
| 152 | (setq args (cons orig-this-switch args))))) | ||
| 153 | (nreverse args)) | ||
| 154 | 85 | ||
| 155 | (defun ns-parse-geometry (geom) | 86 | (defun ns-parse-geometry (geom) |
| 156 | "Parse a Nextstep-style geometry string GEOM. | 87 | "Parse a Nextstep-style geometry string GEOM. |
| @@ -1029,7 +960,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 1029 | "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing." | 960 | "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing." |
| 1030 | 961 | ||
| 1031 | ;; PENDING: not needed? | 962 | ;; PENDING: not needed? |
| 1032 | (setq command-line-args (ns-handle-args command-line-args)) | 963 | (setq command-line-args (x-handle-args command-line-args)) |
| 1033 | 964 | ||
| 1034 | (x-open-connection (system-name) nil t) | 965 | (x-open-connection (system-name) nil t) |
| 1035 | 966 | ||
| @@ -1048,7 +979,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 1048 | 979 | ||
| 1049 | (setq ns-initialized t)) | 980 | (setq ns-initialized t)) |
| 1050 | 981 | ||
| 1051 | (add-to-list 'handle-args-function-alist '(ns . ns-handle-args)) | 982 | (add-to-list 'handle-args-function-alist '(ns . x-handle-args)) |
| 1052 | (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces)) | 983 | (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces)) |
| 1053 | (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system)) | 984 | (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system)) |
| 1054 | 985 | ||