[Top][All Lists]

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

Re: address@hidden: widget-value-set for editable fields]

From: Per Abrahamsen
Subject: Re: address@hidden: widget-value-set for editable fields]
Date: Sat, 3 Feb 2007 11:03:29 +0100

Richard: New text added at the :from marker is inserted *before* the
marker.  The attached change means that new text will be *after* the

Markus: If you make a habbit of putting "stable" text before and after
the %v in :format, the widget code will tend to be much more robust.
It will also make your code work with existing Emacsen.

    (setq tw-value-field
          (widget-create 'editable-field
                         :size 50
                         :format "Value: %v\n"

-- Per

---- The patch:

2007-02-03  Per Abrahamsen  <address@hidden>

        * wid-edit.el (widget-default-create): Let `:from' marker stay
        nehind when inserting text, as in an `editable-field' widget.

*** wid-edit.el_ORIG    Wed Oct 17 20:39:47 2001
--- wid-edit.el Sat Feb  3 10:52:37 2007
*** 1361,1367 ****
        (widget-apply widget :value-create)))
    (let ((from (point-min-marker))
         (to (point-max-marker)))
!      (set-marker-insertion-type from t)
      (set-marker-insertion-type to nil)
      (widget-put widget :from from)
      (widget-put widget :to to)))
--- 1361,1367 ----
        (widget-apply widget :value-create)))
    (let ((from (point-min-marker))
         (to (point-max-marker)))
!      (set-marker-insertion-type from nil)
      (set-marker-insertion-type to nil)
      (widget-put widget :from from)
      (widget-put widget :to to)))

--- The original mail:

On 2/2/07, Richard Stallman <address@hidden> wrote:
Can you please help debug this?
I don't understand the widget code -- or the specs -- well enough to
know whether this is a bug or user error.

------- Start of forwarded message -------
Date: Thu, 01 Feb 2007 18:50:29 +0100
From: Markus Triska <address@hidden>
To: address@hidden
Subject: widget-value-set for editable fields
Reply-To: address@hidden
X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO
        autolearn=failed version=3.0.4

Here is a simple widget example:

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

    (defvar tw-value-field nil)

    (defun test-widgets ()
      "Create some widgets."
      (switch-to-buffer "*Widget Example*")
      (let ((inhibit-read-only t))
      (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)
                     "Reset Form")
      (widget-insert "\n")
      (use-local-map widget-keymap)

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

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.

emacs-pretest-bug mailing list
------- End of forwarded message -------

reply via email to

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