emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: widget-value-set for editable fields


From: Lennart Borgman (gmail)
Subject: Re: widget-value-set for editable fields
Date: Fri, 02 Feb 2007 00:47:51 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666

Markus Triska wrote:
Here is a simple widget example:

    (require 'widget)
    (require 'wid-edit)

    (defvar tw-value-field nil)

    (defun test-widgets ()
      "Create some widgets."
      (interactive)
      (switch-to-buffer "*Widget Example*")
      (kill-all-local-variables)
      (let ((inhibit-read-only t))
        (erase-buffer))
      (remove-overlays)
      (widget-insert "Here is some documentation.\n\Value: ")
      (setq tw-value-field
            (widget-create 'editable-field
                           :size 50
                           :format "%v "
                           ""))
      (widget-insert "\n")
      (widget-create 'push-button
                     :notify (lambda (&rest ignore)
                               (test-widgets))
                     "Reset Form")
      (widget-insert "\n")
      (use-local-map widget-keymap)
      (widget-setup))

    (defun tw-change-value ()
      (interactive)
      (widget-value-set tw-value-field "Changed value")
      (widget-setup))

M-x test-widgets creates a buffer with 2 widgets. M-x tw-change-value
sets the editable field's value to "Changed value" at any time. This
works well if the widget's current value is the empty string. In
contrast, if you enter anything in the editable field, and then do
M-x tw-change-value, its previous value still occurs in the buffer.
Tested with CVS trunk.


Testing this I found that if I tab to the field and do

  M-: (marker-insertion-type (widget-get (widget-at (point)) :from))

it returns t which I believe mean that the marker at the field beginning moves forward when inserting text there.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]