[Top][All Lists]

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

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

From: Arni Magnusson
Subject: bug#6202: Async shell command, switching mode, and sleep-for
Date: Sun, 16 May 2010 15:01:55 +0000 (UTC)
User-agent: Alpine 2.00 (LFD 1167 2008-08-23)

I maintain a major mode, where some functions have broken between Emacs 23.1 and 23.2, and I believe the current Emacs behavior could be described as a bug.

What I want to do is to run a shell command asynchronously (so I can watch the output scroll by in a secondary window while continuing my work), but the output should not be syntax-highlighted. By default, the output is shown in `shell-mode', where negative numbers are highlighted in `font-lock-comment-face',

  123 -456 789

but I want these three numbers to be shown in the `default' face.

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 ()
  (shell-command "set &")
  (select-window (get-buffer-window "*Async Shell Command*"))
  ;; (sleep-for 3)
  (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.

I also stumbled upon a separate issue, where the above function (after uncommenting the `sleep-for' line) makes Emacs dutifully freeze for 3 seconds in Linux, but not in Windows. This bug/limitation is not mentioned on the help page for `sleep-for'.

Thanks in advance for looking at these issues,


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'.

reply via email to

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