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

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

watch.el


From: Thien-Thi Nguyen
Subject: watch.el
Date: Sat, 06 Dec 2003 18:31:40 +0100

hmm, does emacs have something like this already?

example usage: M-x watch RET pstree RET 2 RET

thi


_____________________________________________________________
;;; ID: $Id: watch.el,v 1.1 2003/11/12 15:47:52 ttn Exp $
;;;
;;; Copyright (C) 2003 Thien-Thi Nguyen
;;; This file is part of ttn's personal elisp library, released under GNU
;;; GPL with ABSOLUTELY NO WARRANTY.  See the file COPYING for details.
;;;
;;; Description: Run a shell command periodically, displaying output.

;;;###autoload
(defun watch (command slackfulness)
  "Execute shell COMMAND every SLACKFULNESS seconds, displaying output.
Type any key to stop command execution (the key is passed to Emacs)."
  (interactive "sShell Command: \nnSeconds between redisplay: ")
  (switch-to-buffer
   (get-buffer-create
    (format "watch (%d sec): %s" slackfulness command)))
  (let (stop)
    (while (not stop)
      (erase-buffer)
      (shell-command (concat "date;" command) (current-buffer))
      (goto-char (point-min))
      (setq stop (not (eq t (sit-for slackfulness))))))
  (rename-buffer (format "(watch stopped): %s" command)))

(provide 'watch)

;;; $RCSfile: watch.el,v $$Revision: 1.1 $ ends here




reply via email to

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