From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Arni Magnusson <arnima@hafro.is>
Cc: 6202@debbugs.gnu.org
Subject: bug#6202: Async shell command, switching mode, and sleep-for
Date: Sun, 16 May 2010 16:48:14 -0400 [thread overview]
Message-ID: <jwv39xrvalr.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1005161346310.10157@hafstormur.hafro.is> (Arni Magnusson's message of "Sun, 16 May 2010 15:01:55 +0000 (UTC)")
> My approach is to switch the secondary window to `fundamental-mode' to
> ensure that nothing is syntax-highlighted. The following example uses the
> shell command "set", because it produces some output Linux and Windows,
> although it does not demonstrate negative numbers:
> (defun foo ()
> (interactive)
> (shell-command "set &")
> (select-window (get-buffer-window "*Async Shell Command*"))
> ;; (sleep-for 3)
> (fundamental-mode)
> (other-window 1))
> My window and buffer control is slightly more sophisticated, but the
> function above focuses on the problem. This function works in Emacs 23.1,
> but in Emacs 23.2 the secondary window is empty, and the shell command
> output is not found in any buffer. The same problem occurs when switching to
> some other mode than `fundamental-mode'. The same problem also occurs when
> replacing the ampersand `shell-command' with the new `async-shell-command'.
> While debugging the problem, I found that the function does work in Emacs
> 23.2 if `sleep-for' is called before switching to `fundamental-mode', so the
> foo function above can be "fixed" by uncommenting that line. Sleeping for
> 0.001 seconds is not enough, though.
This does look like a bug, indeed, and I can't begin to imagine what the
problem might be (and don't have time to investigate now).
> P.S. It would of course be nice if the `*-shell-command' functions would
> have an optional argument to specify a mode other than the currently
> hardwired `shell-mode'.
I strongly recommend to stay away from shell-command and friends in Lisp
code (they're mostly used and meant for interactive use), and use
start-process instead.
Stefan
next prev parent reply other threads:[~2010-05-16 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-16 15:01 bug#6202: Async shell command, switching mode, and sleep-for Arni Magnusson
2010-05-16 20:48 ` Stefan Monnier [this message]
2010-05-17 9:55 ` Štěpán Němec
2010-05-17 13:30 ` Stefan Monnier
2016-07-07 0:01 ` npostavs
2016-07-07 15:37 ` Eli Zaretskii
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=jwv39xrvalr.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=6202@debbugs.gnu.org \
--cc=arnima@hafro.is \
/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.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).