help-gnu-emacs
[Top][All Lists]
Advanced

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

Widgets and text-changing


From: Stephen Berman
Subject: Widgets and text-changing
Date: Thu, 18 Jun 2009 01:03:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux)

Is it possible to apply text-changing commands or functions to widgets
in a buffer without dewidgetizing them?  For example, if I eval this
sexp:

    (with-current-buffer (get-buffer-create "*Widget Test*")
      (setq mylist '("delta" "alfa" "charlie" "bravo"))
      (switch-to-buffer (current-buffer))
      (erase-buffer)
      (kill-all-local-variables)
      (mapc (lambda (elt)
              (widget-create 'push-button
                             :notify (lambda (&rest ignore) (message "Test"))
                             elt)
              (widget-insert "\n"))
            mylist)
      ;; (sort-lines nil (point-min) (point-max))
      (use-local-map widget-keymap)
      (widget-setup))

then the buffer *Widget Test* contains these widgets, which are in bold
face, have mouse-face highlighting, and are active (clicking them
displays the message "Test"):

    [delta]
    [alfa]
    [charlie]
    [bravo]

If I now try to modify this buffer, e.g. with sort-lines, this fails
with the error:

widget-before-change: Text is read-only: "Attempt to change text outside
editable field"

If I uncomment the commented line in the above sexp and eval it again,
then the lines in *Widget Test* are alphabetized:

    [alfa]
    [bravo]
    [charlie]
    [delta]

but dewidgetized: no bold face, no hightlighting, not active.

Is it possible to manipulate, e.g. sort, widgets in a buffer without
them losing their widgetry?

Steve Berman





reply via email to

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