From: kai.grossjohann@gmx.net (Kai Großjohann)
Subject: Re: multithreading in Elisp?
Date: Fri, 06 Jun 2003 14:10:10 +0200 [thread overview]
Message-ID: <848ysfz9st.fsf@lucy.is.informatik.uni-duisburg.de> (raw)
In-Reply-To: m3he77uwvb.fsf@russel.teuto37
Florian von Savigny <florian265@uboot.com> writes:
> kai.grossjohann@gmx.net (Kai Großjohann) writes:
>
>> You can do cooperative multitasking, MacOS-style, by using timers or
>> process filters or the like. (MacOS means before X.)
>
> Do you have an (arbitrary) code example at hand? My imagination does
> not reach far enough to implement commands that run in parallel by
> means of a process filter (maybe you mean "outsourcing" the task that
> is to run in the background with start-process?). I have no idea, on
> the other hand, what a timer is (it doesn't have to do with the diary,
> does it ... ?).
I think it's not necessary to use a lot of imagination.
Timers are part of Emacs. For example, the following is good for
Brits:
(defun tea-time ()
(message "It's time for tea!"))
(run-at-time "5:00pm" nil 'tea-time)
In addition to run-at-time, also see run-with-timer and
run-with-idle-timer. Also note that run-at-time allows you to run
the function repeatedly, every second, say.
Process filters are indeed used when you want to communicate with a
process. When the process creates some output, your process filter
function will be called with a string arg, the arg contains the
output from the process. You can then do whatever you like and return.
> I would not really care whether the multitasking is preemptive or
> cooperative, as long as the possibility is there at all. What I would
> like to achieve is to have emacs retrieve some text from an external
> program and write it in a different buffer, while it still allows the
> user to edit his text.
This is really easy: you can start a process with start-process.
Then, from time to time, you can call accept-process-output to read
output from that process, or you can use a process filter which just
appends the output to the end of the buffer.
Or you run the process via comint, as has been suggested before in
this thread. I think that's not a bad solution; it's a fairly
high-level facility.
--
This line is not blank.
next prev parent reply other threads:[~2003-06-06 12:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-01 18:46 multithreading in Elisp? Florian von Savigny
2003-06-02 8:19 ` Kai Großjohann
2003-06-03 13:14 ` Florian von Savigny
2003-06-03 13:19 ` David Kastrup
2003-06-06 12:10 ` Kai Großjohann [this message]
2003-06-06 23:52 ` Michael M Mason
2003-06-07 10:53 ` tea (was: multithreading in Elisp?) lawrence mitchell
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=848ysfz9st.fsf@lucy.is.informatik.uni-duisburg.de \
--to=kai.grossjohann@gmx.net \
/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).