emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [RFC] Insert reference to Org table cell or cell range from region s


From: Ihor Radchenko
Subject: Re: [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse)
Date: Tue, 22 Oct 2024 17:39:24 +0000

Charles Choi <kickingvegas@gmail.com> writes:

> In trying to understand better what mouse support means, I’ve tried to
> formalize this with a state machine as described below. Is this
> proposed behavior along the lines of what you were thinking?
>
> *** s2: point in ✳︎Edit Formulas✳︎ buffer
> After calling ~org-table-edit-formulas~, point is moved into a new buffer 
> named ✳︎Edit Formulas✳︎.
>
> Dev note: this is existing behavior.

Here, you may add an overlay with custom keymap to the original table -
just while *Edit formulas* buffer is active.

> *** s3: dynamically calculate reference
> Upon transition *t2* (a down-mouse event) an Org table field reference is 
> generated and inserted into the ✳︎Edit Formulas✳︎ buffer.
>
> As the mouse is dragged (transition *t3*), the Org table reference is 
> dynamically regenerated and inserted into the ✳︎Edit Formulas✳︎ buffer.
>
> Note that the current point is in the buffer where the text region (or 
> rectangle) is defined.
>
> Dev note: this is new behavior. I do not know enough about Emacs event 
> handling to implement the above.

> *** s4: move point back
> Upon completion of a defined text region or rectangle, the point is moved 
> back to the end of the inserted table reference in ✳︎Edit Formulas✳︎.
>
> Dev note: this is new behavior. I do not know enough about Emacs event 
> handling to implement the above.

I think that you can do it simpler.
Instead of trying to handle partial evens like "mouse down", you can use
the usual mouse click event (22.7.4 Click Events in Elisp manual). Then,
you (1) record cell reference; (2) switch to table edit buffer upon
clicking.

Evens in Emacs are the same as key sequences. So, just as you can bind a
command to C-c C-x C-c, you can also bind it to [mouse-click] or [mouse-drag].

You can access the information about mouse click/drag boundaries using
interactive specification:

‘e’
     The first or next non-keyboard event in the key sequence that
     invoked the command.  More precisely, ‘e’ gets events that are
     lists, so you can look at the data in the lists.  *Note Input
     Events::.  No I/O.

     You use ‘e’ for mouse events and for special system events (*note
     Misc Events::).  The event list that the command receives depends
     on the event.  *Note Input Events::, which describes the forms of
     the list for each event in the corresponding subsections.

     You can use ‘e’ more than once in a single command's interactive
     specification.  If the key sequence that invoked the command has N
     events that are lists, the Nth ‘e’ provides the Nth such event.
     Events that are not lists, such as function keys and ASCII
     characters, do not count where ‘e’ is concerned.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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