home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2575 / ebuttons.el < prev    next >
Encoding:
Text File  |  1992-11-18  |  3.2 KB  |  83 lines

  1. ;; Ebuttons - an X interface to Emacs.
  2. ;; Copyright (C) 1992  Terry Jones (terry@santafe.edu)
  3. ;; (Based (heavily) on the taglist facility written by Brad Mears)
  4.  
  5. ;; This file is part of ebuttons
  6.  
  7. ;; Ebuttons is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 1, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; The GNU General Public License can be obtained via anonymous ftp from
  13. ;; prep.ai.mit.edu as pub/gnu/COPYING or pub/gnu/COPYING-2.
  14.  
  15. ;; Ebuttons is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; This program provides an X interface to issue commands to an emacs
  21. ;; session.  It allows you to specify (in an X resource file) labels for
  22. ;; a set of buttons and a command for each that will be executed when the
  23. ;; corresponding button is clicked on with the mouse. For instance you
  24. ;; can define buttons to compile, to find the next error, to save
  25. ;; buffers, to move to the top/bottom of the buffer, to exit emacs etc.
  26. ;; etc.
  27.  
  28. (defvar ebuttons-program "ebuttons"
  29.   "*The ebuttons processor")
  30.  
  31. (defvar ebuttons-running nil
  32.   "Is the program running?")
  33.  
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35. ;;;  ebuttons
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. (defun ebuttons ()
  38.   "Start the ebuttons processor.  This starts an X subprocess that can be
  39. used to issue commands to the current emacs session."
  40.   (interactive)
  41.   (if (not ebuttons-running)
  42.     (progn
  43.       (message "Starting ebuttons...")
  44.       (setq ebuttons-process
  45.         (start-process "ebuttons" nil ebuttons-program))
  46.       (setq ebuttons-running t)
  47.       (set-process-filter ebuttons-process 'eb-process-filter)
  48.       (set-process-sentinel ebuttons-process 'eb-process-sentinel)
  49.       (process-kill-without-query ebuttons-process))
  50.     (process-send-string ebuttons-process "\n")))
  51.  
  52. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  53. ;;;  eb-process-filter    - input process filter
  54. ;;;  eb-process-sentinel  - exit process filter
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56.  
  57. (defun eb-process-filter (proc str)
  58.   "Process filter for the ebuttons"
  59.   (let ((first-char (string-to-char str)))
  60.      (if (= first-char ?()     
  61.         (eval (read str))       ; evaluate the elisp code sent from ebuttons
  62.         (progn                  ; Dump the string to the ebuttons buffer 
  63.            (get-buffer-create "*ebuttons*")
  64.            (switch-to-buffer-other-window "*ebuttons*")
  65.            (insert-string str)
  66.            (end-of-buffer)
  67.            (other-window 1)))))
  68.  
  69.  
  70. (defun eb-process-sentinel (proc msg)
  71.   (setq ebuttons-running nil)        ; it's not running any more
  72.   (cond ((eq (process-status proc) 'exit)
  73.      (message "ebuttons-proc subprocess exited"))
  74.      ((eq (process-status proc) 'signal)
  75.      (message "ebuttons-proc subprocess killed")
  76.      ))) 
  77.  
  78. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  79. ;;;  End of ebuttons.el
  80. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  81.  
  82.  
  83.