LINUX.ORG.RU

История изменений

Исправление saufesma, (текущая версия) :

Этот не хочет работать.

Debugger entered--Lisp error: (wrong-number-of-arguments (2 . 2) 3) widget-value-set((editable-field :size 6 :value «0» :format «Result: %v» :field-overlay #<overlay from 55 to 61 in *Widget Summation*> :from #<marker (moves after insertion) at 47 in *Widget Summation*> :to #<marker at 61 in *Widget Summation*>) «4» nil) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b))))) (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b))))))((push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) (push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) (mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266992 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) widget-apply((push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) :notify (push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) (mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266992 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) widget-item-action((push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) (mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266992 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) widget-apply((push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) :action (mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266992 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) widget-apply-action((push-button :args nil :value «Run» :notify (lambda (&rest ignore) (if (= (+ a b) 4) (progn (widget-value-set X «True») (widget-value-set Z (number-to-string (+ a b)) (next))) (progn (widget-value-set X «False») (widget-value-set Z (number-to-string (+ a b)))))) :button-overlay #<overlay from 73 to 78 in *Widget Summation*> :from #<marker (moves after insertion) at 73 in *Widget Summation*> :to #<marker at 78 in *Widget Summation*>) (mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266992 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) widget-button-click((down-mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266905 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) funcall-interactively(widget-button-click (down-mouse-1 (#<window 3 on *Widget Summation*> 76 (445 . 42) 10266905 nil 76 (55 . 2) nil (5 . 8) (8 . 17)))) call-interactively(widget-button-click nil nil) command-execute(widget-button-click)

(require 'widget)
     
;;     (eval-when-compile
;;       (require 'wid-edit))
     

(defvar Z)
(defvar X)
(defvar a)
(defvar b)

(defun next ()
  ())


(defun widget-sum ()
  (interactive)
  (switch-to-buffer "*Widget Summation*")
  (kill-all-local-variables)
  (make-local-variable 'widget-example-repeat)
  (let ((inhibit-read-only t))
    (erase-buffer))
  (remove-overlays)
  (widget-insert "Here is summation.\n\n")
  
  (widget-create 'editable-field
		 :size 6
		 :value "0"
		 :format "Name: %v " ; Text after the field!
		 :notify (lambda (widget &rest ignore);(widget - это наш текущий виджет) здесь передаем текущий виджет в lambda
			   (setq a (string-to-number (widget-value widget)))))       
  
  (widget-create 'editable-field
		 :size 6
		 :value "0"
		 :format "Name: %v " ; Text after the field!
					;пишу здесь widget а, что это не знаю
		 :notify (lambda (widget &rest ignore) ;(widget - это наш текущий виджет) здесь передаем текущий виджет в lambda
			   (setq b (string-to-number (widget-value widget)))))      

       


(setq Z (widget-create 'editable-field
	       :size 6
	       :value "0"
	       :format "Result: %v"
	       ))

(setq X (widget-create 'editable-field
	       :size 6
	       :value "0"
	       :format "Test: %v"
	       )) 

    (widget-create 'push-button
		   :notify (lambda (&rest ignore)
			     (if (= (+ a b) 4)
				 (progn
				 (widget-value-set X "True") 
				 (widget-value-set Z (number-to-string (+ a b))
						   (next)))
			       (progn
                                 (widget-value-set X "False")
				 (widget-value-set Z (number-to-string (+ a b)))
			     )))
                      "Run") 

       (widget-insert "\n")
       (use-local-map widget-keymap)
       (widget-setup))

(next)

(message "I am here!")

progn: Wrong number of arguments: (2 . 2), 3

Исходная версия saufesma, :

Этот не хочет работать.

(require 'widget)
     
;;     (eval-when-compile
;;       (require 'wid-edit))
     

(defvar Z)
(defvar X)
(defvar a)
(defvar b)

(defun next ()
  ())


(defun widget-sum ()
  (interactive)
  (switch-to-buffer "*Widget Summation*")
  (kill-all-local-variables)
  (make-local-variable 'widget-example-repeat)
  (let ((inhibit-read-only t))
    (erase-buffer))
  (remove-overlays)
  (widget-insert "Here is summation.\n\n")
  
  (widget-create 'editable-field
		 :size 6
		 :value "0"
		 :format "Name: %v " ; Text after the field!
		 :notify (lambda (widget &rest ignore);(widget - это наш текущий виджет) здесь передаем текущий виджет в lambda
			   (setq a (string-to-number (widget-value widget)))))       
  
  (widget-create 'editable-field
		 :size 6
		 :value "0"
		 :format "Name: %v " ; Text after the field!
					;пишу здесь widget а, что это не знаю
		 :notify (lambda (widget &rest ignore) ;(widget - это наш текущий виджет) здесь передаем текущий виджет в lambda
			   (setq b (string-to-number (widget-value widget)))))      

       


(setq Z (widget-create 'editable-field
	       :size 6
	       :value "0"
	       :format "Result: %v"
	       ))

(setq X (widget-create 'editable-field
	       :size 6
	       :value "0"
	       :format "Test: %v"
	       )) 

    (widget-create 'push-button
		   :notify (lambda (&rest ignore)
			     (if (= (+ a b) 4)
				 (progn
				 (widget-value-set X "True") 
				 (widget-value-set Z (number-to-string (+ a b))
						   (next)))
			       (progn
                                 (widget-value-set X "False")
				 (widget-value-set Z (number-to-string (+ a b)))
			     )))
                      "Run") 

       (widget-insert "\n")
       (use-local-map widget-keymap)
       (widget-setup))

(next)

(message "I am here!")

progn: Wrong number of arguments: (2 . 2), 3