* Automatic formatting of the table as you type
@ 2020-03-27 16:27 ndame
2020-03-27 18:55 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: ndame @ 2020-03-27 16:27 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
The other day a code was posted on Reddit which automatically formats
the table as you type:
https://i.imgur.com/lorIDhY.gif
The code looks pretty simple, the actual formatting code is only a few lines
and it might even be possible to rewrite it to simplify it even more:
https://reddit.com/r/emacs/comments/fosdi2/orgtableautoalignmode_minor_mode_for_auto/
Org should provide this feature out of the box as an optional minor
mode like org-indent-mode. It provides a much nicer user experience
than the current behavior where the table falls apart when you type in
it until you press TAB or such.
[-- Attachment #2: Type: text/html, Size: 704 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic formatting of the table as you type
2020-03-27 16:27 ndame
@ 2020-03-27 18:55 ` Nicolas Goaziou
2020-03-27 20:49 ` ndame
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2020-03-27 18:55 UTC (permalink / raw)
To: ndame; +Cc: emacs-orgmode@gnu.org
Hello,
ndame <emacsuser@freemail.hu> writes:
> The other day a code was posted on Reddit which automatically formats
> the table as you type:
>
> https://i.imgur.com/lorIDhY.gif
>
>
> The code looks pretty simple, the actual formatting code is only a few lines
> and it might even be possible to rewrite it to simplify it even more:
>
> https://reddit.com/r/emacs/comments/fosdi2/orgtableautoalignmode_minor_mode_for_auto/
>
>
> Org should provide this feature out of the box as an optional minor
> mode like org-indent-mode. It provides a much nicer user experience
> than the current behavior where the table falls apart when you type in
> it until you press TAB or such.
The idea is nice, and probably a step in the right direction, but
`org-at-table-p' and `org-table-align' are not lightweight functions. In
some common situations, e.g., when the table is a bit large, or when it
is located away from the start of a section, typing in the table may
feel sluggish.
Therefore, I wonder if Org should include it unless it is optimized in
most situations.
As a side note, the table doesn't realign when you add a space in
a cell.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic formatting of the table as you type
2020-03-27 18:55 ` Nicolas Goaziou
@ 2020-03-27 20:49 ` ndame
2020-03-29 6:18 ` Adam Porter
0 siblings, 1 reply; 6+ messages in thread
From: ndame @ 2020-03-27 20:49 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]
> The idea is nice, and probably a step in the right direction, but
> `org-at-table-p' and `org-table-align' are not lightweight functions. In
> some common situations, e.g., when the table is a bit large, or when it
> is located away from the start of a section, typing in the table may
> feel sluggish.
>
> Therefore, I wonder if Org should include it unless it is optimized in
> most situations.
Apparently, the code is more like a proof of concept, not a fully
optimized solution. I didn't mean it should be included as is, rather
the concept itself is very promising and provides a better user
experience. As some of the commenters put it on reddit this is how
they expected Org tables to work in the first place and I feel the
same way.
As for org-at-table-p being slow storing the start and end position of
the table could be a solution, so if point is between them then there
is no need to check org-at-table-p again.
org-table-align seemed fast enough for me when I tried the posted
code, but if it's slower for large tables then the code could measure
the time it takes to perform the alignment for the current table and
if it's above a certain threshold then it could introduce a bit of
idle delay for the update, so it doesn't hold back the user from
typing, and if the alignment is fast then it could perform the update
without delay.
Anyway, I think if implemented properly then this feature could be a
worthy addition to org, even as default if it works well, because it's
a much better user experience and a much better first impression for
new users, instead of the current default fragile table which falls
apart during typing and fixed only when TAB is pressed.
[-- Attachment #2: Type: text/html, Size: 1956 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic formatting of the table as you type
2020-03-27 20:49 ` ndame
@ 2020-03-29 6:18 ` Adam Porter
2020-03-30 8:26 ` Eric S Fraga
0 siblings, 1 reply; 6+ messages in thread
From: Adam Porter @ 2020-03-29 6:18 UTC (permalink / raw)
To: emacs-orgmode
ndame <emacsuser@freemail.hu> writes:
> As for org-at-table-p being slow storing the start and end position of
> the table could be a solution, so if point is between them then there
> is no need to check org-at-table-p again.
>
> org-table-align seemed fast enough for me when I tried the posted
> code, but if it's slower for large tables then the code could measure
> the time it takes to perform the alignment for the current table and
> if it's above a certain threshold then it could introduce a bit of
> idle delay for the update, so it doesn't hold back the user from
> typing, and if the alignment is fast then it could perform the update
> without delay.
>
> Anyway, I think if implemented properly then this feature could be a
> worthy addition to org, even as default if it works well, because it's
> a much better user experience and a much better first impression for
> new users, instead of the current default fragile table which falls
> apart during typing and fixed only when TAB is pressed.
I suggest being very careful with this. While it's a very nice feature,
it's bound to be slow with large tables. And it is very frustrating for
users when typing becomes laggy. Most users who encounter it would
probably not know if there's a way to fix the problem, e.g. by disabling
a feature, because they probably wouldn't even know what to look for.
Most would probably think it a bug, and it could harm Org's and Emacs's
reputation, making people think they're inherently slow or laggy when
typing.
Pressing TAB (or any other key that moves to the next field) to realign
a table is not a significant burden. A feature like this should
probably remain an add-on package, or at least disabled by default.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic formatting of the table as you type
@ 2020-03-29 7:09 ndame
0 siblings, 0 replies; 6+ messages in thread
From: ndame @ 2020-03-29 7:09 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 702 bytes --]
> I suggest being very careful with this. While it's a very nice feature,
> it's bound to be slow with large tables. And it is very frustrating for
> users when typing becomes laggy.
The feature could be an optional minor mode first and then later made
default if it proves to work well in every situation.
With the techniques I suggested there should be no lag at all, because
for smaller tables emacs can handle automatic formatting instantly and
with bigger tables the code can introduce an automatic idle delay
(sit-for), so the automatic reformat will happen only when the user is
idle for a short while. The idle period length can depend on the size
and complexity of the table.
[-- Attachment #2: Type: text/html, Size: 790 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic formatting of the table as you type
2020-03-29 6:18 ` Adam Porter
@ 2020-03-30 8:26 ` Eric S Fraga
0 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2020-03-30 8:26 UTC (permalink / raw)
To: Adam Porter; +Cc: emacs-orgmode
On Sunday, 29 Mar 2020 at 01:18, Adam Porter wrote:
> Pressing TAB (or any other key that moves to the next field) to realign
> a table is not a significant burden. A feature like this should
> probably remain an add-on package, or at least disabled by default.
I tend to work with large tables and performance is already slow so I
agree completely with this.
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-438-g5b9698
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-03-30 8:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-29 7:09 Automatic formatting of the table as you type ndame
-- strict thread matches above, loose matches on Subject: below --
2020-03-27 16:27 ndame
2020-03-27 18:55 ` Nicolas Goaziou
2020-03-27 20:49 ` ndame
2020-03-29 6:18 ` Adam Porter
2020-03-30 8:26 ` Eric S Fraga
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).