bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6202: Async shell command, switching mode, and sleep-for


From: Stefan Monnier
Subject: bug#6202: Async shell command, switching mode, and sleep-for
Date: Sun, 16 May 2010 16:48:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]