home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 7932 < prev    next >
Encoding:
Text File  |  1993-01-21  |  3.5 KB  |  129 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ascent!ascent!paul
  3. From: paul@ascent.com (Paul Foley)
  4. Subject: Emacs interface to PLOD
  5. Message-ID: <PAUL.93Jan21125701@MountRushmore.ascent.com>
  6. Date: 21 Jan 93 12:57:01
  7. Organization: Ascent Technology, Inc., Cambridge Massachusetts
  8. Lines: 119
  9.  
  10. Here is an emacs-lisp interface to PLOD --- the Personal LOgging
  11. Device posted to comp.lang.perl a few days ago.
  12.  
  13. Simplest way to use is M-x plod.
  14.  
  15. There is also an "alarm" interface that will switch you to a PLOD
  16. buffer every so often, in case you forget to invoke it yourself.
  17.  
  18. Enjoy.
  19.  
  20. ------------------------------------------------------------------
  21.  
  22. ;;;;
  23. ;;;; plod.el
  24. ;;;;
  25. ;;;; Emacs interface to PLOD --- A (Perl) tool to keep track of the work you do
  26. ;;;; PLOD was written by pomeranz@irving.nas.nasa.gov (Hal R. Pomeranz).
  27. ;;;;
  28. ;;;; This software is FREE to all and may be used for any purpose as long as this 
  29. ;;;; notice remains intact.  The author does not assume responsibility for anything.
  30. ;;;; 
  31. ;;;; Suggested addition to .emacs:
  32. ;;;;     (load-library "plod")
  33. ;;;;     (plod-alarm-on 60) ; once an hour
  34. ;;;;
  35. ;;;; When you are tired of PLODding use "M-x plod-alarm-off"
  36. ;;;; 
  37. ;;;; Alternately, use "M-x plod" whenever you want to log something.
  38. ;;;; 
  39. ;;;; paul@ascent.com (Paul Foley)    Wednesday January 20, 1993
  40.  
  41. (require 'shell)
  42.  
  43. ;;;
  44. ;;; Variables
  45. ;;;
  46.  
  47. ;; Name of executable --- should be in your $PATH
  48. (defvar plod-program-name "plod")
  49. (defvar plod-buffer-name "*PLOD*")
  50.  
  51. ;;;
  52. ;;; Manual Interface
  53. ;;;
  54.  
  55. (defvar plod-buffer-process nil)
  56.  
  57. ;; Interactive command to invoke PLOD in a shell-mode buffer.
  58. ;;
  59.  
  60. (defun plod ()
  61.   "Invoke PLOD."
  62.   (interactive)
  63.   ; restart PLOD if necessary
  64.   (if (not (get-buffer-process plod-buffer-name))
  65.       (setq plod-buffer-process (start-process "plod-process" plod-buffer-name plod-program-name)))
  66.   (switch-to-buffer plod-buffer-name t)
  67.   (if (not (eq major-mode 'shell-mode)) (shell-mode)))
  68.  
  69.  
  70. ;;;
  71. ;;; Alarm interface
  72. ;;;
  73.  
  74. (defvar plod-alarm-on-p nil)        ; t if alarm is on
  75. (defvar plod-alarm-process nil)
  76.  
  77. ;; run when plod-alarm-process is killed
  78. (defun plod-alarm-sentinel (proc reason)
  79.   (or (eq (process-status proc) 'run)
  80.       (setq plod-alarm-on-p nil)
  81.       (ding) 
  82.       (message "PLOD alarm off")))
  83.  
  84. ;; run every interval & at initial call to plod-alarm-on
  85. (defun plod-alarm-filter (proc string)
  86.   (if plod-alarm-on-p
  87.       (plod)
  88.     (setq plod-alarm-on-p t)))
  89.  
  90. ;; Set alarm to call PLOD every so often
  91. ;;
  92. (defun plod-alarm-on (interval)
  93.   "Turn the Emacs PLOD alarm on.  The alarm goes off every INTERVAL minutes
  94. and you will be switched to the PLOD buffer automatically.  
  95. Use plod-alarm-off to stop this behaviour."
  96.   (interactive "nEnter PLOD alarm interval (in minutes): ")
  97.   (let ((live (and plod-alarm-process
  98.            (eq (process-status plod-alarm-process) 'run))))
  99.     (if (not live)
  100.     (progn
  101.       (setq plod-alarm-on-p nil)
  102.       (if plod-alarm-process
  103.           (delete-process plod-alarm-process))
  104.       (let ((process-connection-type nil))
  105.         (setq plod-alarm-process
  106.           (start-process "plod-alarm" nil 
  107.                  (concat exec-directory "wakeup")
  108.                  ; convert minutes -> seconds for wakeup
  109.                  (int-to-string (* 60 interval)))))
  110.       (process-kill-without-query plod-alarm-process)
  111.       (set-process-sentinel plod-alarm-process 'plod-alarm-sentinel)
  112.       (set-process-filter plod-alarm-process 'plod-alarm-filter)))))
  113.  
  114. ;; Turn PLOD alarm off
  115. ;;
  116. (defun plod-alarm-off ()
  117.   "Turn the Emacs PLOD alarm off."
  118.   (interactive)
  119.   (if plod-alarm-on-p (kill-process plod-alarm-process)))
  120.  
  121. ;;; End
  122. --
  123. paul@ascent.com
  124. ...!uunet!ascent!paul
  125.  
  126.  
  127.  
  128.  
  129.