emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Imran Khan <imran@khan.ovh>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] Writing table to a folded drawer unfolds it. [9.7.12 (release_9.7.12 @ /home/natrys/.emacs.d/elpa/org-mode/lisp/)]
Date: Tue, 15 Oct 2024 18:09:50 +0000	[thread overview]
Message-ID: <8734kxfdap.fsf@localhost> (raw)
In-Reply-To: <285d8923e769bbaadb990286c5b966f5@khan.ovh>

Imran Khan <imran@khan.ovh> writes:

> ... Writing table to a folded drawer unfolds it
> ...
>     (insert "| " (format "%f" (time-to-seconds)) " |\n")

This is expected.
In the middle of the editing, you are breaking the drawer structure,
transiently having something like

:DRAWER:
...
| :END:

So, Org mode unfolds the drawer to avoid having a fold that cannot be
unfolded by normal means.

> Also any attempt to fold the drawer immediately afterwards (in same
> elisp thread of execution) does nothing.

This one is a bit tricky.
The above unfolding does not happen immediately after the edit - we
cannot reliably do it from inside after-change-functions.  So, the
unfolding of drawers is delayed until `post-command-hook' is evaluated.

Since your attempt to fold the drawer happens _before_
`post-command-hook', your folding is effectively undone shortly after.

To work around the problem, you can use
`org-fold-core-ignore-fragility-checks' macro around your code modifying
the drawer contents; as long as you know that you are not actually
breaking the drawer structure.

P.S. The above is all quite tricky and should be eventually simplified
by using track-changes.el library (will be a part of Emacs 30). But not
yet, and not until we drop Emacs 29 support.

Wontfix.
Canceled.

-- 
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-15 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 19:07 [BUG] Writing table to a folded drawer unfolds it. [9.7.12 (release_9.7.12 @ /home/natrys/.emacs.d/elpa/org-mode/lisp/)] Imran Khan
2024-10-15 18:09 ` Ihor Radchenko [this message]
2024-10-16 13:05   ` Imran Khan

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=8734kxfdap.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=imran@khan.ovh \
    /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).