* 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
* Re: Widgets and text-changing
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
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: MON KEY @ 2009-06-18 20:02 UTC (permalink / raw)
To: Stephen Berman; +Cc: help-gnu-emacs
Stephen Berman <stephen.berman@gmx.net> writes:
> 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"))
> {...}
> Is it possible to manipulate, e.g. sort, widgets in a buffer without
> them losing their widgetry?
I'm sure this was obvious and I don't intend any sarcasm, but what about:
(setq mylist '(sort '("delta" "alfa" "charlie" "bravo") 'string<)
> Steve Berman
s_P
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Widgets and text-changing
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>
2 siblings, 0 replies; 5+ messages in thread
From: MON KEY @ 2009-06-19 2:58 UTC (permalink / raw)
To: Stephen Berman; +Cc: help-gnu-emacs
> (setq mylist '(sort '("delta" "alfa" "charlie" "bravo") 'string<)
er... double quoted that list :(
(setq mylist (sort '("delta" "alfa" "charlie" "bravo") 'string<))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Widgets and text-changing
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>
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Berman @ 2009-06-19 7:45 UTC (permalink / raw)
To: help-gnu-emacs
On Thu, 18 Jun 2009 16:02:43 -0400 MON KEY <monkey@sandpframing.com> wrote:
> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> 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"))
>> {...}
>> Is it possible to manipulate, e.g. sort, widgets in a buffer without
>> them losing their widgetry?
>
> I'm sure this was obvious and I don't intend any sarcasm, but what about:
[...]
> (setq mylist (sort '("delta" "alfa" "charlie" "bravo") 'string<)
This is fine as far as it goes, though in my specific use case it has to
be a bit more complicated, since I need to both preserve the initial
list and do case insensitive sorting. This added complication is what
prompted my post, since if it were possible to apply text-changing
functions to widgetized buffers, I would only need to set sort-fold-case
and call sort-lines. But since this apparently is not possible, I have
indeed resorted to the pre-sorting, despite its additional slight
overhead.
Steve Berman
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Widgets and text-changing
[not found] ` <20090619.145655.258112025.devel@pollock-nageoire.net>
@ 2009-06-19 15:11 ` MON KEY
0 siblings, 0 replies; 5+ messages in thread
From: MON KEY @ 2009-06-19 15:11 UTC (permalink / raw)
To: Pierre Lorenzon; +Cc: help-gnu-emacs, stephen.berman
On Fri, Jun 19, 2009 at 8:56 AM, Pierre
Lorenzon<devel@pollock-nageoire.net> wrote:
> buffer after it has been sorted ? First bind the
> buffer-read-only variable to nil to allow sort-lines which is
> meant to rewrite the buffer for instance :
> (let ((buffer-read-only nil))
> (sort-lines)
> (widget-setup))
>
Before responding I had tried Stephen's example with a
(setq inhibit-read-only t)
this alone didn't help.
Is this because there are overlays in effect not (just/only) text-props?
I didn't go any further setting additional buffer variables, but it
may be that a larger set of inhibitions is required (and perhaps
others as well) i.e. temporarily setting:
(setq inhibit-read-only t
inhibit-point-motion-hooks t
inhibit-modification-hooks t)
This sort of approach works works with text-properties (and I have no
idea how it corelates with the widget library)
Would an alternative approach be to forgo the initial widget-insert
and assign text-properties on the buffer contents with the help of
some regexps and only widgetize according to a prop val once the
buffer's setup is finalized?
This prob. moves quite a bit further out from the OP intentions and
may well over complicate what widgets were intended to simplify :{
s_P
^ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).