19

I'm running the output of an application in an emacs buffer using shell-command.

(shell-command "verbose-app &" "*verbose-app*")

The problem is this command is extremely verbose. So much so, that it sometimes takes several seconds for the emacs buffer to catch up. It lags by several seconds with the actual output.

Is there any way I can speed up the output scrolling by disabling something? Like regex-matching or syntax highlighting?

For future reference:

The verbose app is adb logcat. I changed my existing function:

(defun adb-logcat ()
  (interactive)
  (shell-command "adb logcat -v threadtime&" "*adb-logcat*")
  (pop-to-buffer "*adb-logcat*")
  (buffer-disable-undo))

To the following:

(defun adb-logcat ()
  (interactive)
  (start-process "*adb-logcat*" "*adb-logcat*" "/bin/sh" "-c" "adb logcat -v threadtime")
  (pop-to-buffer "*adb-logcat*")
  (buffer-disable-undo))

It scrolls way faster now. Yay!

hyperlogic
  • 7,525
  • 7
  • 39
  • 32
  • You can try unbuffering the verbose app's output: http://stackoverflow.com/a/3466024/265069 – Tom Aug 23 '12 at 15:19
  • I'm running MacOSX, so unbuffer is not available. – hyperlogic Aug 23 '12 at 17:41
  • I don't know Os X, but google says this: http://jubianchi.fr/help/3.Tweaks/unbuffered-processes If it does not work then you may want to look for alternatives with google – Tom Aug 23 '12 at 17:55

2 Answers2

10

Like the documentation says, shell-command runs the command in an inferior shell, implying shell-mode. If you just want the output and none of the features, running the command with start-process may be closer to what you want.

(start-process "*verbose-app*" "*verbose-app*"
 "/bin/sh" "-c" "verbose-app")

Wrapping this into a function should not be too hard. You might want to look at how shell-command implements async commands; for example, it will ask whether it should terminate an existing process if you attempt to create one when another already exists. http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/simple.el#n2447 might be a good starting point. (In case the link goes bad, this is a link to inside defun shell-command, pointing to a a comment about handling the ampersand. If it's there, the command will be run asynchronously.)

tripleee
  • 175,061
  • 34
  • 275
  • 318
0

If the command is that verbose, is there any use in capturing the full output in real time? Maybe you could run verbose-app > app.log in the background and then run something like while true; do tail -n50 app.log; sleep 1; done within emacs to keep updating the buffer to view the last few lines of the log file. Later when you want the full output you can open the log file in emacs.

Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159