[code] Textadept: how to event-handle multiple subsequent select_word operations? UPDATE_UI isn't triggered

From: Phil S. <accountz.att.mailbox.org>
Date: Sun, 4 Nov 2018 13:39:13 +0100

To summarize: I'm subscribing to `events.UPDATE_UI` branching on
`buffer.UPDATE_SELECTION` --- this works great for manually-performed
multiple-range-selections but not those performed programmatically in
`textadept.editing.select_word` except when no prior selections:

When there is no range-selection currently present in the buffer and I
do an initial `textadept.editing.select_word` op (via keybord shortcut),
the expected event fires. But, subsequent repeats of the op (each
selecting the next occurrence) won't trigger the event again!

(Manually doing multiple selections with the mouse and Alt or Ctrl DO
trigger the event handler each time another selection is added, as
expected).

The handler:

     events.connect(events.UPDATE_UI, function(upd)
         if upd == buffer.UPDATE_SELECTION then
             ui.statusbar_text = "sel:"..tostring(buffer.selections)
         end
     end

On subsequent `select_word` ops: not even another value for upd is
given, the handler simply isn't entered. (The ui.statusbar_text is also
being cleared by something other than my own scripts.)

How does one reliably subscribe to ANY and ALL sorts of (multiple /
subsequent) selection changes in the buffer, regardless of its reason or
originator?

(NB I took a quick look at `textadept/modules/textadept/editing.lua`s
`function M.select_word` and it seems the module is not to blame, rather
the internal implementations of `buffer:multiple_select_add_next` and/or
`buffer:multiple_select_add_each` might be the culprit here. Sure one
could hotpatch the `editing.lua` module for a quick&dirty but I'd guess
that any random custom module ever calling
`buffer:multiple_select_add_*` shouldn't have to go through the same
issue =)

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 04 Nov 2018 - 07:39:13 EST

This archive was generated by hypermail 2.2.0 : Mon 05 Nov 2018 - 06:46:51 EST