aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-10-24 22:39:21 -0700
committerGlenn Morris2010-10-24 22:39:21 -0700
commit59ba9d59dcd8d086b51926d7ce652ad4fc6c22fe (patch)
tree55f2f865aceae4a9442f6777079190a56b9db40e
parentd85d3b3ab87474cabbe0a813dd825d56abd028bc (diff)
downloademacs-59ba9d59dcd8d086b51926d7ce652ad4fc6c22fe.tar.gz
emacs-59ba9d59dcd8d086b51926d7ce652ad4fc6c22fe.zip
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.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/term/common-win.el65
2 files changed, 27 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 96c8df73ee7..e62729555c2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12010-10-25 Glenn Morris <rgm@gnu.org> 12010-10-25 Glenn Morris <rgm@gnu.org>
2 2
3 * term/common-win.el (x-handle-switch): Simplify with pop.
4 Optionally handle numeric switches.
5 (x-handle-numeric-switch): Just call x-handle-switch.
6 (x-handle-initial-switch, x-handle-xrm-switch, x-handle-geometry)
7 (x-handle-name-switch, x-handle-display, x-handle-args):
8 Simplify with pop.
9
3 * term/ns-win.el: Do not require easymenu. 10 * term/ns-win.el: Do not require easymenu.
4 (menu-bar-edit-menu) <copy, paste, paste-from-menu, separator-undo>: 11 (menu-bar-edit-menu) <copy, paste, paste-from-menu, separator-undo>:
5 <spell>: Move adjustments to menu-bar.el. 12 <spell>: Move adjustments to menu-bar.el.
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 1c53f09abad..331f20fe3ff 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -103,48 +103,28 @@ On Nextstep, put TEXT in the pasteboard."
103(defvar x-command-line-resources nil) 103(defvar x-command-line-resources nil)
104 104
105;; Handler for switches of the form "-switch value" or "-switch". 105;; Handler for switches of the form "-switch value" or "-switch".
106(defun x-handle-switch (switch) 106(defun x-handle-switch (switch &optional numeric)
107 (let ((aelt (assoc switch command-line-x-option-alist))) 107 (let ((aelt (assoc switch command-line-x-option-alist)))
108 (if aelt 108 (if aelt
109 (let ((param (nth 3 aelt)) 109 (setq default-frame-alist
110 (value (nth 4 aelt))) 110 (cons (cons (nth 3 aelt)
111 (if value 111 (if numeric
112 (setq default-frame-alist 112 (string-to-number (pop x-invocation-args))
113 (cons (cons param value) 113 (or (nth 4 aelt) (pop x-invocation-args))))
114 default-frame-alist)) 114 default-frame-alist)))))
115 (setq default-frame-alist
116 (cons (cons param
117 (car x-invocation-args))
118 default-frame-alist)
119 x-invocation-args (cdr x-invocation-args)))))))
120 115
121;; Handler for switches of the form "-switch n" 116;; Handler for switches of the form "-switch n"
122(defun x-handle-numeric-switch (switch) 117(defun x-handle-numeric-switch (switch)
123 (let ((aelt (assoc switch command-line-x-option-alist))) 118 (x-handle-switch switch t))
124 (if aelt
125 (let ((param (nth 3 aelt)))
126 (setq default-frame-alist
127 (cons (cons param
128 (string-to-number (car x-invocation-args)))
129 default-frame-alist)
130 x-invocation-args
131 (cdr x-invocation-args))))))
132 119
133;; Handle options that apply to initial frame only 120;; Handle options that apply to initial frame only
134(defun x-handle-initial-switch (switch) 121(defun x-handle-initial-switch (switch)
135 (let ((aelt (assoc switch command-line-x-option-alist))) 122 (let ((aelt (assoc switch command-line-x-option-alist)))
136 (if aelt 123 (if aelt
137 (let ((param (nth 3 aelt)) 124 (setq initial-frame-alist
138 (value (nth 4 aelt))) 125 (cons (cons (nth 3 aelt)
139 (if value 126 (or (nth 4 aelt) (pop x-invocation-args)))
140 (setq initial-frame-alist 127 initial-frame-alist)))))
141 (cons (cons param value)
142 initial-frame-alist))
143 (setq initial-frame-alist
144 (cons (cons param
145 (car x-invocation-args))
146 initial-frame-alist)
147 x-invocation-args (cdr x-invocation-args)))))))
148 128
149;; Make -iconic apply only to the initial frame! 129;; Make -iconic apply only to the initial frame!
150(defun x-handle-iconic (switch) 130(defun x-handle-iconic (switch)
@@ -157,15 +137,14 @@ On Nextstep, put TEXT in the pasteboard."
157 (error "%s: missing argument to `%s' option" (invocation-name) switch)) 137 (error "%s: missing argument to `%s' option" (invocation-name) switch))
158 (setq x-command-line-resources 138 (setq x-command-line-resources
159 (if (null x-command-line-resources) 139 (if (null x-command-line-resources)
160 (car x-invocation-args) 140 (pop x-invocation-args)
161 (concat x-command-line-resources "\n" (car x-invocation-args)))) 141 (concat x-command-line-resources "\n" (pop x-invocation-args)))))
162 (setq x-invocation-args (cdr x-invocation-args)))
163 142
164(declare-function x-parse-geometry "frame.c" (string)) 143(declare-function x-parse-geometry "frame.c" (string))
165 144
166;; Handle the geometry option 145;; Handle the geometry option
167(defun x-handle-geometry (switch) 146(defun x-handle-geometry (switch)
168 (let* ((geo (x-parse-geometry (car x-invocation-args))) 147 (let* ((geo (x-parse-geometry (pop x-invocation-args)))
169 (left (assq 'left geo)) 148 (left (assq 'left geo))
170 (top (assq 'top geo)) 149 (top (assq 'top geo))
171 (height (assq 'height geo)) 150 (height (assq 'height geo))
@@ -186,8 +165,7 @@ On Nextstep, put TEXT in the pasteboard."
186 (append initial-frame-alist 165 (append initial-frame-alist
187 '((user-position . t)) 166 '((user-position . t))
188 (if left (list left)) 167 (if left (list left))
189 (if top (list top))))) 168 (if top (list top)))))))
190 (setq x-invocation-args (cdr x-invocation-args))))
191 169
192(defvar x-resource-name) 170(defvar x-resource-name)
193 171
@@ -197,9 +175,8 @@ On Nextstep, put TEXT in the pasteboard."
197(defun x-handle-name-switch (switch) 175(defun x-handle-name-switch (switch)
198 (or (consp x-invocation-args) 176 (or (consp x-invocation-args)
199 (error "%s: missing argument to `%s' option" (invocation-name) switch)) 177 (error "%s: missing argument to `%s' option" (invocation-name) switch))
200 (setq x-resource-name (car x-invocation-args) 178 (setq x-resource-name (pop x-invocation-args)
201 x-invocation-args (cdr x-invocation-args)) 179 initial-frame-alist (cons (cons 'name x-resource-name)
202 (setq initial-frame-alist (cons (cons 'name x-resource-name)
203 initial-frame-alist))) 180 initial-frame-alist)))
204 181
205(defvar x-display-name nil 182(defvar x-display-name nil
@@ -209,8 +186,7 @@ On X, the display name of individual X frames is recorded in the
209 186
210(defun x-handle-display (switch) 187(defun x-handle-display (switch)
211 "Handle -display DISPLAY option." 188 "Handle -display DISPLAY option."
212 (setq x-display-name (car x-invocation-args) 189 (setq x-display-name (pop x-invocation-args))
213 x-invocation-args (cdr x-invocation-args))
214 ;; Make subshell programs see the same DISPLAY value Emacs really uses. 190 ;; Make subshell programs see the same DISPLAY value Emacs really uses.
215 ;; Note that this isn't completely correct, since Emacs can use 191 ;; Note that this isn't completely correct, since Emacs can use
216 ;; multiple displays. However, there is no way to tell an already 192 ;; multiple displays. However, there is no way to tell an already
@@ -229,10 +205,9 @@ This function returns ARGS minus the arguments that have been processed."
229 args nil) 205 args nil)
230 (while (and x-invocation-args 206 (while (and x-invocation-args
231 (not (equal (car x-invocation-args) "--"))) 207 (not (equal (car x-invocation-args) "--")))
232 (let* ((this-switch (car x-invocation-args)) 208 (let* ((this-switch (pop x-invocation-args))
233 (orig-this-switch this-switch) 209 (orig-this-switch this-switch)
234 completion argval aelt handler) 210 completion argval aelt handler)
235 (setq x-invocation-args (cdr x-invocation-args))
236 ;; Check for long options with attached arguments 211 ;; Check for long options with attached arguments
237 ;; and separate out the attached option argument into argval. 212 ;; and separate out the attached option argument into argval.
238 (if (string-match "^--[^=]*=" this-switch) 213 (if (string-match "^--[^=]*=" this-switch)