From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: How to reliably edit a file from within Emacs Lisp and return a string?
Date: Fri, 23 Aug 2019 10:49:04 +0300 [thread overview]
Message-ID: <83o90gb9u7.fsf@gnu.org> (raw)
In-Reply-To: <CAM-tV-_rrRE_SA-fQGzuJ8rm0_9Fqz4q-mDNT3_L65uujEF0ew@mail.gmail.com> (message from Noam Postavsky on Thu, 22 Aug 2019 19:22:34 -0400)
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Thu, 22 Aug 2019 19:22:34 -0400
> Cc: GNU Emacs Help <help-gnu-emacs@gnu.org>
>
> > Yes. I need to be able to run function that waits on the buffer to be
> > killed, so that I can read string from the file that related to the
> > buffer.
>
> The difficulty is the waiting part.
I think the difficulty is the very concept of "waiting". It probably
comes from the previous implementation, where Emacs was invoked as an
external program, and then the caller would "wait" for it to exit, and
take that as a signal that editing is complete.
This paradigm is problematic when everything is done from within
Emacs, because once editing is done, Emacs just returns to its main
command loop and waits for the next command. IOW, it's Emacs that
"waits" here, not the command which invoked the editing part.
One way to keep the "waiting" paradigm is to use recursive-edit (which
I still don't understand why the OP dislikes: the problems with "C-c
C-c" are minor and can be easily resolved). If that is somehow not
appropriate, then my question would be "what would the 'waiting' part
do once the wait is over?" Given the answer to that, it shouldn't be
hard to devise the solution that doesn't "wait", but instead causes
something to happen after editing is complete. Just as an example, if
after editing the application should refresh some buffer, then
triggering that buffer's revert function would be all that's needed.
My main point is that doing this from Emacs needs a certain conceptual
shift, because the command loop and the resulting "wait" are now
implicit.
> It might be possible to use threads for waiting and get more linear
> code that way
Not recommended.
next prev parent reply other threads:[~2019-08-23 7:49 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 21:31 How to reliably edit a file from within Emacs Lisp and return a string? Jean Louis
2019-08-22 22:01 ` Noam Postavsky
2019-08-22 22:46 ` Jean Louis
2019-08-22 23:10 ` Óscar Fuentes
2019-08-22 23:22 ` Noam Postavsky
2019-08-23 1:19 ` Jean Louis
2019-08-23 1:27 ` Noam Postavsky
2019-08-23 7:49 ` Eli Zaretskii [this message]
2019-08-23 14:01 ` Jean Louis
2019-08-23 14:14 ` Robert Pluim
2019-08-24 12:20 ` Jean Louis
2019-08-24 12:24 ` Jean Louis
2019-08-23 14:25 ` Eli Zaretskii
2019-08-24 12:19 ` Jean Louis
2019-08-24 12:30 ` Eli Zaretskii
2019-08-24 12:41 ` Jean Louis
2019-08-24 13:17 ` Eli Zaretskii
2019-08-24 14:14 ` Jean Louis
2019-08-24 14:55 ` Jean Louis
2019-08-24 15:10 ` Eli Zaretskii
2019-08-24 15:51 ` Jean Louis
2019-08-24 16:11 ` Eli Zaretskii
2019-08-24 16:44 ` Jean Louis
2019-08-24 16:55 ` Eli Zaretskii
2019-08-24 17:02 ` Eli Zaretskii
2019-08-24 17:17 ` Jean Louis
2019-08-24 17:23 ` Eli Zaretskii
2019-08-24 17:37 ` Jean Louis
2019-08-24 18:25 ` Eli Zaretskii
2019-08-24 18:50 ` Jean Louis
2019-08-24 19:03 ` Eli Zaretskii
2019-08-24 21:30 ` Jean Louis
2019-08-24 17:15 ` Jean Louis
2019-08-24 17:22 ` Eli Zaretskii
2019-08-24 16:18 ` Yuri Khan
2019-08-24 17:07 ` Jean Louis
2019-08-24 13:08 ` Jean Louis
2019-08-23 21:44 ` Marcin Borkowski
2019-08-24 12:15 ` Jean Louis
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83o90gb9u7.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/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.
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).