# HG changeset patch # User Glenn Morris # Date 1287985161 25200 # Node ID f900266d10a09e3de1092e8be7bf813c11c02983 # Parent 7253525aadd5c16282f1c2b7dc45cf8f5b77b44b Simplifications for lisp/term/common-win.el * lisp/term/common-win.el (x-handle-switch): Simplify with pop. Optionally handle numeric switches. (x-handle-numeric-switch): Just call x-handle-switch. (x-handle-initial-switch, x-handle-xrm-switch, x-handle-geometry) (x-handle-name-switch, x-handle-display, x-handle-args): Simplify with pop. diff -r 7253525aadd5 -r f900266d10a0 lisp/ChangeLog --- a/lisp/ChangeLog Mon Oct 25 12:06:35 2010 +0900 +++ b/lisp/ChangeLog Sun Oct 24 22:39:21 2010 -0700 @@ -1,5 +1,12 @@ 2010-10-25 Glenn Morris + * term/common-win.el (x-handle-switch): Simplify with pop. + Optionally handle numeric switches. + (x-handle-numeric-switch): Just call x-handle-switch. + (x-handle-initial-switch, x-handle-xrm-switch, x-handle-geometry) + (x-handle-name-switch, x-handle-display, x-handle-args): + Simplify with pop. + * term/ns-win.el: Do not require easymenu. (menu-bar-edit-menu) : : Move adjustments to menu-bar.el. diff -r 7253525aadd5 -r f900266d10a0 lisp/term/common-win.el --- a/lisp/term/common-win.el Mon Oct 25 12:06:35 2010 +0900 +++ b/lisp/term/common-win.el Sun Oct 24 22:39:21 2010 -0700 @@ -103,48 +103,28 @@ (defvar x-command-line-resources nil) ;; Handler for switches of the form "-switch value" or "-switch". -(defun x-handle-switch (switch) +(defun x-handle-switch (switch &optional numeric) (let ((aelt (assoc switch command-line-x-option-alist))) (if aelt - (let ((param (nth 3 aelt)) - (value (nth 4 aelt))) - (if value - (setq default-frame-alist - (cons (cons param value) - default-frame-alist)) - (setq default-frame-alist - (cons (cons param - (car x-invocation-args)) - default-frame-alist) - x-invocation-args (cdr x-invocation-args))))))) + (setq default-frame-alist + (cons (cons (nth 3 aelt) + (if numeric + (string-to-number (pop x-invocation-args)) + (or (nth 4 aelt) (pop x-invocation-args)))) + default-frame-alist))))) ;; Handler for switches of the form "-switch n" (defun x-handle-numeric-switch (switch) - (let ((aelt (assoc switch command-line-x-option-alist))) - (if aelt - (let ((param (nth 3 aelt))) - (setq default-frame-alist - (cons (cons param - (string-to-number (car x-invocation-args))) - default-frame-alist) - x-invocation-args - (cdr x-invocation-args)))))) + (x-handle-switch switch t)) ;; Handle options that apply to initial frame only (defun x-handle-initial-switch (switch) (let ((aelt (assoc switch command-line-x-option-alist))) (if aelt - (let ((param (nth 3 aelt)) - (value (nth 4 aelt))) - (if value - (setq initial-frame-alist - (cons (cons param value) - initial-frame-alist)) - (setq initial-frame-alist - (cons (cons param - (car x-invocation-args)) - initial-frame-alist) - x-invocation-args (cdr x-invocation-args))))))) + (setq initial-frame-alist + (cons (cons (nth 3 aelt) + (or (nth 4 aelt) (pop x-invocation-args))) + initial-frame-alist))))) ;; Make -iconic apply only to the initial frame! (defun x-handle-iconic (switch) @@ -157,15 +137,14 @@ (error "%s: missing argument to `%s' option" (invocation-name) switch)) (setq x-command-line-resources (if (null x-command-line-resources) - (car x-invocation-args) - (concat x-command-line-resources "\n" (car x-invocation-args)))) - (setq x-invocation-args (cdr x-invocation-args))) + (pop x-invocation-args) + (concat x-command-line-resources "\n" (pop x-invocation-args))))) (declare-function x-parse-geometry "frame.c" (string)) ;; Handle the geometry option (defun x-handle-geometry (switch) - (let* ((geo (x-parse-geometry (car x-invocation-args))) + (let* ((geo (x-parse-geometry (pop x-invocation-args))) (left (assq 'left geo)) (top (assq 'top geo)) (height (assq 'height geo)) @@ -186,8 +165,7 @@ (append initial-frame-alist '((user-position . t)) (if left (list left)) - (if top (list top))))) - (setq x-invocation-args (cdr x-invocation-args)))) + (if top (list top))))))) (defvar x-resource-name) @@ -197,9 +175,8 @@ (defun x-handle-name-switch (switch) (or (consp x-invocation-args) (error "%s: missing argument to `%s' option" (invocation-name) switch)) - (setq x-resource-name (car x-invocation-args) - x-invocation-args (cdr x-invocation-args)) - (setq initial-frame-alist (cons (cons 'name x-resource-name) + (setq x-resource-name (pop x-invocation-args) + initial-frame-alist (cons (cons 'name x-resource-name) initial-frame-alist))) (defvar x-display-name nil @@ -209,8 +186,7 @@ (defun x-handle-display (switch) "Handle -display DISPLAY option." - (setq x-display-name (car x-invocation-args) - x-invocation-args (cdr x-invocation-args)) + (setq x-display-name (pop x-invocation-args)) ;; Make subshell programs see the same DISPLAY value Emacs really uses. ;; Note that this isn't completely correct, since Emacs can use ;; multiple displays. However, there is no way to tell an already @@ -229,10 +205,9 @@ args nil) (while (and x-invocation-args (not (equal (car x-invocation-args) "--"))) - (let* ((this-switch (car x-invocation-args)) + (let* ((this-switch (pop x-invocation-args)) (orig-this-switch this-switch) completion argval aelt handler) - (setq x-invocation-args (cdr x-invocation-args)) ;; Check for long options with attached arguments ;; and separate out the attached option argument into argval. (if (string-match "^--[^=]*=" this-switch)