Richard: New text added at the :from marker is inserted *before* the
marker. The attached change means that new text will be *after* the
marker.
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 <[EMAIL PROTECTED]>
* 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
To: [email protected]
Subject: widget-value-set for editable fields
Reply-To: [EMAIL PROTECTED]
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."
(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.
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
------- End of forwarded message -------
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug