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