This is cross-post from Stack Overflow

I have a simple widget setup:

(setq gobgen-widget-name
      (widget-create 'editable-field
                     :size 25
                     :format "Name:   %v"
                     :notify (lambda (widget &rest ignore)
                               (widget-value-set gobgen-widget-prefix (get-gobject-prefix (widget-value widget))))

(widget-insert " ")

(setq gobgen-widget-prefix
      (widget-create 'editable-field
                     :size 10
                     :format "Prefix: %v\n"

I’d like to update the second widget real time with the return value of get-gobject-prefix.

However, whenever I enter a character in the Name widget, point automatically jumps to the last character of the Prefix field, and inserts my character there.

Is there a way to do what I’m trying to achieve?

(I’m using Emacs 24.3.1)


1 Answer 1


It turns out that this was easier than I expected: using save-excursion saved the day (and my point position).

(lambda (widget &rest ignore)
    (widget-value-set gobgen-widget-prefix (get-gobject-prefix (widget-value widget)))))

Not totally perfect, though, as it changes the width of the Prefix widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.