Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I speed up emacs output from an asynchronous shell-command?

Tags:

shell

emacs

elisp

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!

like image 271
hyperlogic Avatar asked Aug 23 '12 00:08

hyperlogic


1 Answers

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

like image 130
tripleee Avatar answered Nov 08 '22 09:11

tripleee