home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume40 / plod / part01 / plod.el.v1 < prev    next >
Lisp/Scheme  |  1993-11-02  |  4KB  |  130 lines

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