Remove ns-handle-* functions that duplicate x-handle-*.
authorGlenn Morris <rgm@gnu.org>
Tue, 26 Oct 2010 03:58:19 +0000 (20:58 -0700)
committerGlenn Morris <rgm@gnu.org>
Tue, 26 Oct 2010 03:58:19 +0000 (20:58 -0700)
* 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.

lisp/ChangeLog
lisp/startup.el
lisp/term/common-win.el
lisp/term/ns-win.el

index 5e5de12..1293e4c 100644 (file)
@@ -1,5 +1,18 @@
 2010-10-26  Glenn Morris  <rgm@gnu.org>
 
+       * 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.
+       * term/common-win.el (x-handle-args): Also handle nextstep arguments.
+       * 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.
+
        * term/common-win.el (x-select-enable-clipboard):
        * term/pc-win.el (x-select-enable-clipboard): Doc fix.
 
index a6ba865..7626dcf 100644 (file)
@@ -200,47 +200,47 @@ and VALUE is the value which is given to that frame parameter
     ;;("-bw" .              x-handle-numeric-switch)
     ;;("-d" .               x-handle-display)
     ;;("-display" .         x-handle-display)
-    ("-name" 1 ns-handle-name-switch)
-    ("-title" 1 ns-handle-switch title)
-    ("-T" 1 ns-handle-switch title)
-    ("-r" 0 ns-handle-switch reverse t)
-    ("-rv" 0 ns-handle-switch reverse t)
-    ("-reverse" 0 ns-handle-switch reverse t)
-    ("-fn" 1 ns-handle-switch font)
-    ("-font" 1 ns-handle-switch font)
-    ("-ib" 1 ns-handle-numeric-switch internal-border-width)
+    ("-name" 1 x-handle-name-switch)
+    ("-title" 1 x-handle-switch title)
+    ("-T" 1 x-handle-switch title)
+    ("-r" 0 x-handle-switch reverse t)
+    ("-rv" 0 x-handle-switch reverse t)
+    ("-reverse" 0 x-handle-switch reverse t)
+    ("-fn" 1 x-handle-switch font)
+    ("-font" 1 x-handle-switch font)
+    ("-ib" 1 x-handle-numeric-switch internal-border-width)
     ;;("-g" .               x-handle-geometry)
     ;;("-geometry" .        x-handle-geometry)
-    ("-fg" 1 ns-handle-switch foreground-color)
-    ("-foreground" 1 ns-handle-switch foreground-color)
-    ("-bg" 1 ns-handle-switch background-color)
-    ("-background" 1 ns-handle-switch background-color)
-;    ("-ms" 1 ns-handle-switch mouse-color)
-    ("-itype" 0 ns-handle-switch icon-type t)
-    ("-i" 0 ns-handle-switch icon-type t)
-    ("-iconic" 0 ns-handle-iconic icon-type t)
+    ("-fg" 1 x-handle-switch foreground-color)
+    ("-foreground" 1 x-handle-switch foreground-color)
+    ("-bg" 1 x-handle-switch background-color)
+    ("-background" 1 x-handle-switch background-color)
+;    ("-ms" 1 x-handle-switch mouse-color)
+    ("-itype" 0 x-handle-switch icon-type t)
+    ("-i" 0 x-handle-switch icon-type t)
+    ("-iconic" 0 x-handle-iconic icon-type t)
     ;;("-xrm" .             x-handle-xrm-switch)
-    ("-cr" 1 ns-handle-switch cursor-color)
-    ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
-    ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
-    ("-bd" 1 ns-handle-switch)
-    ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
+    ("-cr" 1 x-handle-switch cursor-color)
+    ("-vb" 0 x-handle-switch vertical-scroll-bars t)
+    ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
+    ("-bd" 1 x-handle-switch)
+    ;; ("--border-width" 1 x-handle-numeric-switch border-width)
     ;; ("--display" 1 ns-handle-display)
-    ("--name" 1 ns-handle-name-switch)
-    ("--title" 1 ns-handle-switch title)
-    ("--reverse-video" 0 ns-handle-switch reverse t)
-    ("--font" 1 ns-handle-switch font)
-    ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
+    ("--name" 1 x-handle-name-switch)
+    ("--title" 1 x-handle-switch title)
+    ("--reverse-video" 0 x-handle-switch reverse t)
+    ("--font" 1 x-handle-switch font)
+    ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
     ;; ("--geometry" 1 ns-handle-geometry)
-    ("--foreground-color" 1 ns-handle-switch foreground-color)
-    ("--background-color" 1 ns-handle-switch background-color)
-    ("--mouse-color" 1 ns-handle-switch mouse-color)
-    ("--icon-type" 0 ns-handle-switch icon-type t)
-    ("--iconic" 0 ns-handle-iconic)
+    ("--foreground-color" 1 x-handle-switch foreground-color)
+    ("--background-color" 1 x-handle-switch background-color)
+    ("--mouse-color" 1 x-handle-switch mouse-color)
+    ("--icon-type" 0 x-handle-switch icon-type t)
+    ("--iconic" 0 x-handle-iconic)
     ;; ("--xrm" 1 ns-handle-xrm-switch)
-    ("--cursor-color" 1 ns-handle-switch cursor-color)
-    ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
-    ("--border-color" 1 ns-handle-switch border-width))
+    ("--cursor-color" 1 x-handle-switch cursor-color)
+    ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
+    ("--border-color" 1 x-handle-switch border-width))
   "Alist of NS options.
 Each element has the form
   (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
index ff69ff9..98baf82 100644 (file)
@@ -316,12 +316,14 @@ On X, the display name of individual X frames is recorded in the
   (setenv "DISPLAY" x-display-name))
 
 (defun x-handle-args (args)
-  "Process the X-related command line options in ARGS.
-This is done before the user's startup file is loaded.  They are copied to
-`x-invocation-args', from which the X-related things are extracted, first
-the switch (e.g., \"-fg\") in the following code, and possible values
-\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
-This function returns ARGS minus the arguments that have been processed."
+  "Process the X (or Nextstep) related command line options in ARGS.
+This is done before the user's startup file is loaded.
+Copies the options in ARGS to `x-invocation-args'.  It then extracts
+the X (or Nextstep) options according to the handlers defined in
+`command-line-x-option-alist' (or `command-line-ns-option-alist').
+For example, `x-handle-switch' handles a switch like \"-fg\" and its
+value \"black\".  This function returns ARGS minus the arguments that
+have been processed."
   ;; We use ARGS to accumulate the args that we don't handle here, to return.
   (setq x-invocation-args args         ; FIXME let-bind?
        args nil)
@@ -329,6 +331,9 @@ This function returns ARGS minus the arguments that have been processed."
              (not (equal (car x-invocation-args) "--")))
     (let* ((this-switch (pop x-invocation-args))
           (orig-this-switch this-switch)
+          (option-alist (if (featurep 'ns)
+                            command-line-ns-option-alist
+                          command-line-x-option-alist))
           completion argval aelt handler)
       ;; Check for long options with attached arguments
       ;; and separate out the attached option argument into argval.
@@ -338,17 +343,17 @@ This function returns ARGS minus the arguments that have been processed."
       ;; Complete names of long options.
       (if (string-match "^--" this-switch)
          (progn
-           (setq completion (try-completion this-switch command-line-x-option-alist))
+           (setq completion (try-completion this-switch option-alist))
            (if (eq completion t)
                ;; Exact match for long option.
                nil
              (if (stringp completion)
-                 (let ((elt (assoc completion command-line-x-option-alist)))
+                 (let ((elt (assoc completion option-alist)))
                    ;; Check for abbreviated long option.
                    (or elt
                        (error "Option `%s' is ambiguous" this-switch))
                    (setq this-switch completion))))))
-      (setq aelt (assoc this-switch command-line-x-option-alist))
+      (setq aelt (assoc this-switch option-alist))
       (if aelt (setq handler (nth 2 aelt)))
       (if handler
          (if argval
index b09dd7a..6541ee4 100644 (file)
   :group 'environment)
 
 ;; nsterm.m
-(defvar ns-version-string)
 (defvar ns-alternate-modifier)
 (defvar ns-right-alternate-modifier)
 
 ;;;; Command line argument handling.
 
-(defvar ns-invocation-args nil)
-(defvar ns-command-line-resources nil)
-
-;; Handler for switches of the form "-switch value" or "-switch".
-(defun ns-handle-switch (switch &optional numeric)
-  (let ((aelt (assoc switch command-line-ns-option-alist)))
-    (if aelt
-       (setq default-frame-alist
-             (cons (cons (nth 3 aelt)
-                         (if numeric
-                             (string-to-number (pop ns-invocation-args))
-                           (or (nth 4 aelt) (pop ns-invocation-args))))
-                   default-frame-alist)))))
-
-;; Handler for switches of the form "-switch n"
-(defun ns-handle-numeric-switch (switch)
-  (ns-handle-switch switch t))
-
-(defalias 'ns-handle-iconic 'x-handle-iconic)
-
-;; Handle the -name option, set the name of the initial frame.
-(defun ns-handle-name-switch (switch)
-  (or (consp ns-invocation-args)
-      (error "%s: missing argument to `%s' option" (invocation-name) switch))
-  (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args))
-                                  initial-frame-alist)))
+(defvar x-invocation-args)
+(defvar ns-command-line-resources nil)  ; FIXME unused?
 
 ;; nsterm.m.
 (defvar ns-input-file)
 
 (defun ns-handle-nxopen (switch)
   (setq unread-command-events (append unread-command-events '(ns-open-file))
-        ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
+        ns-input-file (append ns-input-file (list (pop x-invocation-args)))))
 
 (defun ns-handle-nxopentemp (switch)
   (setq unread-command-events (append unread-command-events
                                      '(ns-open-temp-file))
-        ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
+        ns-input-file (append ns-input-file (list (pop x-invocation-args)))))
 
 (defun ns-ignore-1-arg (switch)
-  (setq ns-invocation-args (cdr ns-invocation-args)))
-(defun ns-ignore-2-arg (switch)
-  (setq ns-invocation-args (cddr ns-invocation-args)))
-
-(defun ns-handle-args (args)
-  "Process Nextstep-related command line options.
-This is run before the user's startup file is loaded.
-The options in ARGS are copied to `ns-invocation-args'.
-The Nextstep-related settings are then applied using the handlers
-defined in `command-line-ns-option-alist'.
-The return value is ARGS minus the number of arguments processed."
-  ;; We use ARGS to accumulate the args that we don't handle here, to return.
-  (setq ns-invocation-args args
-        args nil)
-  (while ns-invocation-args
-    (let* ((this-switch (pop ns-invocation-args))
-          (orig-this-switch this-switch)
-          completion argval aelt handler)
-      ;; Check for long options with attached arguments
-      ;; and separate out the attached option argument into argval.
-      (if (string-match "^--[^=]*=" this-switch)
-         (setq argval (substring this-switch (match-end 0))
-               this-switch (substring this-switch 0 (1- (match-end 0)))))
-      ;; Complete names of long options.
-      (if (string-match "^--" this-switch)
-         (progn
-           (setq completion (try-completion this-switch
-                                             command-line-ns-option-alist))
-           (if (eq completion t)
-               ;; Exact match for long option.
-               nil
-             (if (stringp completion)
-                 (let ((elt (assoc completion command-line-ns-option-alist)))
-                   ;; Check for abbreviated long option.
-                   (or elt
-                       (error "Option `%s' is ambiguous" this-switch))
-                   (setq this-switch completion))))))
-      (setq aelt (assoc this-switch command-line-ns-option-alist))
-      (if aelt (setq handler (nth 2 aelt)))
-      (if handler
-         (if argval
-             (let ((ns-invocation-args
-                    (cons argval ns-invocation-args)))
-               (funcall handler this-switch))
-           (funcall handler this-switch))
-       (setq args (cons orig-this-switch args)))))
-  (nreverse args))
+  (setq x-invocation-args (cdr x-invocation-args)))
+(defun ns-ignore-2-arg (switch)         ; FIXME unused?
+  (setq x-invocation-args (cddr x-invocation-args)))
 
 (defun ns-parse-geometry (geom)
   "Parse a Nextstep-style geometry string GEOM.
@@ -1029,7 +960,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
   "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
 
   ;; PENDING: not needed?
-  (setq command-line-args (ns-handle-args command-line-args))
+  (setq command-line-args (x-handle-args command-line-args))
 
   (x-open-connection (system-name) nil t)
 
@@ -1048,7 +979,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
 
   (setq ns-initialized t))
 
-(add-to-list 'handle-args-function-alist '(ns . ns-handle-args))
+(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
 (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))