* Request for comment: Adding feature to calculate Org table reference from selected text region
@ 2024-10-20 0:28 Charles Choi
2024-10-20 9:51 ` [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse) Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Charles Choi @ 2024-10-20 0:28 UTC (permalink / raw)
To: Emacs-orgmode
Hello folks!
I recently made a blog post describing a means of calculating an Org table reference from a selected text region or rectangle. I think this feature is compelling enough to put into Org itself and as such I am raising this idea with this group to gauge interest.
This idea and its implementation are detailed in http://yummymelon.com/devnull/referencing-org-table-cells-with-text-regions.html
I'm happy to respond to any feedback on this idea here. Also to clarify, I'm much more interested in feedback for the idea and less so on its current implementation. It is my hope that if the idea of it is appealing enough, an optimal implementation can be made by this group.
Thanks and best regards -
Charles
—
Charles Y. Choi, Ph.D.
kickingvegas@gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse)
2024-10-20 0:28 Request for comment: Adding feature to calculate Org table reference from selected text region Charles Choi
@ 2024-10-20 9:51 ` Ihor Radchenko
2024-10-21 16:24 ` Charles Choi
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-10-20 9:51 UTC (permalink / raw)
To: Charles Choi; +Cc: Emacs-orgmode
[ Changing subject line, so that the thread is registered as a proper request for comments ]
Charles Choi <kickingvegas@gmail.com> writes:
> I recently made a blog post describing a means of calculating an Org table reference from a selected text region or rectangle. I think this feature is compelling enough to put into Org itself and as such I am raising this idea with this group to gauge interest.
>
> This idea and its implementation are detailed in http://yummymelon.com/devnull/referencing-org-table-cells-with-text-regions.html
It would be nice if you summarized the feature request in a few
sentences in the email. The link may or may not be available for future
readers in 10+ years from now.
AFAIR, the idea is roughly the following:
1. Currently, users need to type table cell references manually in table
formulas:
#+tblfm: @1$2+@5$4
2. Manually counting cells is not fun
3. We do have M-x org-table-edit-formulas where you can use S-<arrow> to
change the existing cell reference, but it still requires having a
reference to start with
4. The proposed feature is inserting a cell/range reference from mouse
click/drag, as it is done in GUI spreadsheet apps (like Libreoffice calc)
> I'm happy to respond to any feedback on this idea here. Also to
> clarify, I'm much more interested in feedback for the idea and less so
> on its current implementation. It is my hope that if the idea of it is
> appealing enough, an optimal implementation can be made by this group.
As we briefly discussed during the meetup, I believe that we can
integrate mouse support into M-x org-table-edit-formulas:
- when in fedit buffer, clicking/dragging on the original table should
insert reference into the formula buffer
Your idea about a command to copy reference to cell/region at point also
makes sense (be it a context menu entry to a simple key binding/M-x command)
> ... an optimal implementation can be made by this group
I was hoping that you will be the person sending patches ;)
At the end, you were interested enough in the feature to write the blog
post. So, you are probably the most motivated as well.
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse)
2024-10-20 9:51 ` [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse) Ihor Radchenko
@ 2024-10-21 16:24 ` Charles Choi
2024-10-22 17:39 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Charles Choi @ 2024-10-21 16:24 UTC (permalink / raw)
To: Ihor Radchenko, Emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]
Ihor -
Thanks for replying. Some initial reply thoughts.
> On Oct 20, 2024, at 2:51 AM, Ihor Radchenko <yantar92@posteo.net> wrote:
>
> It would be nice if you summarized the feature request in a few
> sentences in the email. The link may or may not be available for future
> readers in 10+ years from now.
Understood. I’ll prepare a more formal RFC in a forthcoming email.
> As we briefly discussed during the meetup, I believe that we can
> integrate mouse support into M-x org-table-edit-formulas:
> - when in fedit buffer, clicking/dragging on the original table should
> insert reference into the formula buffer
>
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?
* Proposed Mouse Region to Org Table Reference Behavior
Described below is a proposed state machine description of mapping a region or rectangle defined by a mouse to an Org table reference.
[-- Attachment #2: org-table-reference-table-mouse-sm.svg --]
[-- Type: image/svg+xml, Size: 4632 bytes --]
[-- Attachment #3: Type: text/plain, Size: 1589 bytes --]
* States
*** s1: point in org table
Initial state where the point in inside an Org table.
Dev note: this is existing behavior.
*** 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.
*** 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.
** Transitions
*** t1: org-table-edit-formulas
The command ~org-table-edit-formulas~ is called.
*** t2: down-mouse-1 on table cell
Either the ~down-mouse-1~ or ~C-M down-mouse-1~ event is made.
*** t3: drag-mouse-1 to define region
The mouse is dragged immediately after a *t2* event.
*** t4: move point back
An up mouse event immediately after a *t3* event.
Thanks and best regards -
Charles
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse)
2024-10-21 16:24 ` Charles Choi
@ 2024-10-22 17:39 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-10-22 17:39 UTC (permalink / raw)
To: Charles Choi; +Cc: Emacs-orgmode
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-22 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-20 0:28 Request for comment: Adding feature to calculate Org table reference from selected text region Charles Choi
2024-10-20 9:51 ` [RFC] Insert reference to Org table cell or cell range from region selection (w/without mouse) Ihor Radchenko
2024-10-21 16:24 ` Charles Choi
2024-10-22 17:39 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).