Function: x-handle-args
x-handle-args is a byte-compiled function defined in common-win.el.gz.
Signature
(x-handle-args ARGS)
Documentation
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.
Source Code
;; Defined in /usr/src/emacs/lisp/term/common-win.el.gz
(defun x-handle-args (args)
"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)
(while (and x-invocation-args
(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.
(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 option-alist))
(if (eq completion t)
;; Exact match for long option.
nil
(if (stringp completion)
(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 option-alist))
(if aelt (setq handler (nth 2 aelt)))
(if handler
(if argval
(let ((x-invocation-args
(cons argval x-invocation-args)))
(funcall handler this-switch))
(funcall handler this-switch))
(setq args (cons orig-this-switch args)))))
(nconc (nreverse args) x-invocation-args))