emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Charles Choi <kickingvegas@gmail.com>
Cc: Emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <875xpk11gz.fsf@localhost> (raw)
In-Reply-To: <FE824DDA-C981-411C-9BC9-3AAEABC1485C@gmail.com>

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	other threads:[~2024-10-22 17:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=875xpk11gz.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=Emacs-orgmode@gnu.org \
    --cc=kickingvegas@gmail.com \
    /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 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).