all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: help-gnu-emacs@gnu.org
Subject: Widgets and text-changing
Date: Thu, 18 Jun 2009 01:03:20 +0200	[thread overview]
Message-ID: <87ocsm79af.fsf@escher.local.home> (raw)

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	other threads:[~2009-06-17 23:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17 23:03 Stephen Berman [this message]
2009-06-18 20:02 ` Widgets and text-changing 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ocsm79af.fsf@escher.local.home \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.