all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Widgets and text-changing
@ 2009-06-17 23:03 Stephen Berman
  2009-06-18 20:02 ` MON KEY
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Berman @ 2009-06-17 23:03 UTC (permalink / raw)
  To: help-gnu-emacs

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-19 15:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 23:03 Widgets and text-changing Stephen Berman
2009-06-18 20:02 ` MON KEY
2009-06-19  2:58   ` MON KEY
2009-06-19  7:45   ` Stephen Berman
     [not found]   ` <20090619.145655.258112025.devel@pollock-nageoire.net>
2009-06-19 15:11     ` MON KEY

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.