changeset 59704:a53730244ba3

Simplify code.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 23 Jan 2005 16:56:11 +0000
parents 51a8532d9066
children 366109711118
files lisp/ChangeLog lisp/term/w32-win.el
diffstat 2 files changed, 31 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Jan 23 13:31:53 2005 +0000
+++ b/lisp/ChangeLog	Sun Jan 23 16:56:11 2005 +0000
@@ -1,3 +1,7 @@
+2005-01-23  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* term/w32-win.el: Simplify code.
+
 2005-01-23  Kim F. Storm  <storm@cua.dk>
 
 	* simple.el (line-move): Adapt to new return value from
--- a/lisp/term/w32-win.el	Sun Jan 23 13:31:53 2005 +0000
+++ b/lisp/term/w32-win.el	Sun Jan 23 16:56:11 2005 +0000
@@ -1,6 +1,6 @@
 ;;; w32-win.el --- parse switches controlling interface with W32 window system
 
-;; Copyright (C) 1993, 1994, 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 ;; Author: Kevin Gallo
 ;; Keywords: terminals
@@ -139,50 +139,26 @@
   "Handle SWITCH of the form \"-switch value\" or \"-switch\"."
   (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)))))))
+	(push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args)))
+	      default-frame-alist))))
 
 (defun x-handle-numeric-switch (switch)
   "Handle SWITCH of the form \"-switch n\"."
   (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-int (car x-invocation-args)))
-		    default-frame-alist)
-	      x-invocation-args
-	      (cdr x-invocation-args))))))
+	(push (cons (nth 3 aelt) (string-to-int (pop x-invocation-args)))
+	      default-frame-alist))))
 
 ;; 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)))))))
+	(push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args)))
+	      initial-frame-alist))))
 
 (defun x-handle-iconic (switch)
   "Make \"-iconic\" SWITCH apply only to the initial frame."
-  (setq initial-frame-alist
-	(cons '(visibility . icon) initial-frame-alist)))
+  (push '(visibility . icon) initial-frame-alist))
 
 (defun x-handle-xrm-switch (switch)
   "Handle the \"-xrm\" SWITCH."
@@ -226,18 +202,15 @@
 ;; to the option's operand; set the name of the initial frame, too.
   (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)
-				  initial-frame-alist)))
+  (setq x-resource-name (pop x-invocation-args))
+  (push (cons 'name x-resource-name) initial-frame-alist))
 
 (defvar x-display-name nil
   "The display name specifying server and frame.")
 
 (defun x-handle-display (switch)
   "Handle the \"-display\" SWITCH."
-  (setq x-display-name (car x-invocation-args)
-	x-invocation-args (cdr x-invocation-args)))
+  (setq x-display-name (pop x-invocation-args)))
 
 (defun x-handle-args (args)
   "Process the X-related command line options in ARGS.
@@ -281,7 +254,7 @@
 		     (cons argval x-invocation-args)))
 		(funcall handler this-switch))
 	    (funcall handler this-switch))
-	(setq args (cons orig-this-switch args)))))
+	(push orig-this-switch args))))
   (nconc (nreverse args) x-invocation-args))
 
 ;;
@@ -1046,15 +1019,10 @@
 (defun xw-defined-colors (&optional frame)
   "Internal function called by `defined-colors', which see."
   (or frame (setq frame (selected-frame)))
-  (let* ((color-map-colors (mapcar (lambda (clr) (car clr)) w32-color-map))
-	 (all-colors (or color-map-colors x-colors))
-	 (this-color nil)
-	 (defined-colors nil))
-    (while all-colors
-      (setq this-color (car all-colors)
-	    all-colors (cdr all-colors))
+  (let ((defined-colors nil))
+    (dolist (this-color (or (mapcar 'car w32-color-map) x-colors))
       (and (color-supported-p this-color frame t)
-	   (setq defined-colors (cons this-color defined-colors))))
+	   (push this-color defined-colors)))
     defined-colors))
 
 
@@ -1076,13 +1044,10 @@
 
 ;;; Make sure we have a valid resource name.
 (or (stringp x-resource-name)
-    (let (i)
-      (setq x-resource-name (invocation-name))
-
-      ;; Change any . or * characters in x-resource-name to hyphens,
-      ;; so as not to choke when we use it in X resource queries.
-      (while (setq i (string-match "[.*]" x-resource-name))
-	(aset x-resource-name i ?-))))
+    (setq x-resource-name
+	  ;; Change any . or * characters in x-resource-name to hyphens,
+	  ;; so as not to choke when we use it in X resource queries.
+	  (replace-regexp-in-string "[.*]" "-" (invocation-name))))
 
 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing
 ;; the same lisp directory, don't pass the third argument unless we seem
@@ -1166,21 +1131,17 @@
 	(setq initial-frame-alist (append initial-frame-alist parsed))
 	;; The size parms apply to all frames.
 	(if (assq 'height parsed)
-	    (setq default-frame-alist
-		  (cons (cons 'height (cdr (assq 'height parsed)))
-			default-frame-alist)))
+	    (push (cons 'height (cdr (assq 'height parsed)))
+		  default-frame-alist))
 	(if (assq 'width parsed)
-	    (setq default-frame-alist
-		  (cons (cons 'width (cdr (assq 'width parsed)))
-			default-frame-alist))))))
+	    (push (cons 'width (cdr (assq 'width parsed)))
+		  default-frame-alist)))))
 
 ;; Check the reverseVideo resource.
 (let ((case-fold-search t))
   (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
-    (if (and rv
-	     (string-match "^\\(true\\|yes\\|on\\)$" rv))
-	(setq default-frame-alist
-	      (cons '(reverse . t) default-frame-alist)))))
+    (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
+	(push '(reverse . t) default-frame-alist))))
 
 (defun x-win-suspend-error ()
   "Report an error when a suspend is attempted."
@@ -1244,7 +1205,7 @@
 	 (and chosen-font (list chosen-font)))
      (x-popup-menu
       last-nonmenu-event
-    ;; Append list of fontsets currently defined.
+      ;; Append list of fontsets currently defined.
       ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
       (if (fboundp 'new-fontset)
       (append w32-fixed-font-alist (list (generate-fontset-menu)))))))
@@ -1268,5 +1229,5 @@
         (tiff "libtiff3.dll" "libtiff.dll")
         (gif "libungif.dll")))
 
-;;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
+;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
 ;;; w32-win.el ends here