changeset 51363:2d011e9999e9

(widget-specify-insert): Simplify. (widget-editable-list-entry-create): Don't assume that %d and %i are in the format string. (widget-map-buttons): Remove unused var `parent'. (widget-move): Remove unused shadowed var `new'. (widget-color-action): Remove unused var `pos'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 31 May 2003 15:33:09 +0000
parents 0b5cb555fd17
children b160887e424c
files lisp/wid-edit.el
diffstat 1 files changed, 16 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/wid-edit.el	Sat May 31 15:23:00 2003 +0000
+++ b/lisp/wid-edit.el	Sat May 31 15:33:09 2003 +0000
@@ -1,6 +1,6 @@
 ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t;-*-
 ;;
-;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1996,97,1999,2000,01,02,2003  Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Maintainer: FSF
@@ -414,16 +414,10 @@
   "Execute FORM without inheriting any text properties."
   `(save-restriction
     (let ((inhibit-read-only t)
-	  (inhibit-modification-hooks t)
-	  result)
-      (insert "<>")
-      (narrow-to-region (- (point) 2) (point))
-      (goto-char (1+ (point-min)))
-      (setq result (progn ,@form))
-      (delete-region (point-min) (1+ (point-min)))
-      (delete-region (1- (point-max)) (point-max))
-      (goto-char (point-max))
-      result)))
+	  (inhibit-modification-hooks t))
+      (narrow-to-region (point) (point))
+      (prog1 (progn ,@form)
+	(goto-char (point-max))))))
 
 (defface widget-inactive-face '((((class grayscale color)
 				  (background dark))
@@ -565,7 +559,6 @@
 respectively."
   (let ((cur (point-min))
 	(widget nil)
-	(parent nil)
 	(overlays (if buffer
 		      (with-current-buffer buffer (overlay-lists))
 		    (overlay-lists))))
@@ -1001,8 +994,7 @@
   (or (bobp) (> arg 0) (backward-char))
   (let ((wrapped 0)
 	(number arg)
-	(old (widget-tabable-at))
-	new)
+	(old (widget-tabable-at)))
     ;; Forward.
     (while (> arg 0)
       (cond ((eobp)
@@ -2483,7 +2475,7 @@
 
 (defun widget-editable-list-format-handler (widget escape)
   ;; We recognize the insert button.
-;;;   (let ((widget-push-button-gui widget-editable-list-gui))
+    ;; (let ((widget-push-button-gui widget-editable-list-gui))
     (cond ((eq escape ?i)
 	   (and (widget-get widget :indent)
 		(insert-char ?\  (widget-get widget :indent)))
@@ -2492,7 +2484,7 @@
 		  (widget-get widget :append-button-args)))
 	  (t
 	   (widget-default-format-handler widget escape)))
-;;;     )
+    ;; )
   )
 
 (defun widget-editable-list-value-create (widget)
@@ -2593,7 +2585,7 @@
 (defun widget-editable-list-entry-create (widget value conv)
   ;; Create a new entry to the list.
   (let ((type (nth 0 (widget-get widget :args)))
-;;; 	(widget-push-button-gui widget-editable-list-gui)
+	;; (widget-push-button-gui widget-editable-list-gui)
 	child delete insert)
     (widget-specify-insert
      (save-excursion
@@ -2622,18 +2614,18 @@
 			       widget type (widget-default-get type)))))
 	       (t
 		(error "Unknown escape `%c'" escape)))))
-     (widget-put widget
-		 :buttons (cons delete
-				(cons insert
-				      (widget-get widget :buttons))))
+     (let ((buttons (widget-get widget :buttons)))
+       (if insert (push insert buttons))
+       (if delete (push delete buttons))
+       (widget-put widget :buttons buttons))
      (let ((entry-from (point-min-marker))
 	   (entry-to (point-max-marker)))
        (set-marker-insertion-type entry-from t)
        (set-marker-insertion-type entry-to nil)
        (widget-put child :entry-from entry-from)
        (widget-put child :entry-to entry-to)))
-    (widget-put insert :widget child)
-    (widget-put delete :widget child)
+    (if insert (widget-put insert :widget child))
+    (if delete (widget-put delete :widget child))
     child))
 
 ;;; The `group' Widget.
@@ -3250,7 +3242,7 @@
   :value-to-internal (lambda (widget value)
 		       (list (car value) (cdr value)))
   :value-to-external (lambda (widget value)
-		       (cons (nth 0 value) (nth 1 value))))
+		       (apply 'cons value)))
 
 (defun widget-cons-match (widget value)
   (and (consp value)
@@ -3473,12 +3465,6 @@
 	 (prompt (concat tag ": "))
 	 (value (widget-value widget))
 	 (start (widget-field-start widget))
-	 (pos (cond ((< (point) start)
-		     0)
-		    ((> (point) (+ start (length value)))
-		     (length value))
-		    (t
-		     (- (point) start))))
 	 (answer (facemenu-read-color prompt)))
     (unless (zerop (length answer))
       (widget-value-set widget answer)