home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / contrib / gwm-buffer / gwm-buffer.el
Lisp/Scheme  |  1995-07-03  |  3KB  |  90 lines

  1. ;; -*-Emacs-Lisp-*-
  2. ;; WOOL Interactive mode
  3. ;; Copyright (C) 1992 Mike Fletcher 
  4. ;;            gt0293b@prism.gatech.edu, fletch@cad.gatech.edu,
  5. ;;            ccastmf@prism.gatech.edu
  6.  
  7. ;;; File:        wool-mode.el
  8. ;;; Description:    WOOL interactive editing mode for Epoch & GWM
  9. ;;; Author:        Mike Fletcher <gt0293b@prism.gatech.edu>
  10. ;;; Idea taken from:    Lisp interaction mode from std. distribution
  11. ;;; First created:    May 26, 1992
  12. ;;; Last Modified:    May 26, 1992
  13. ;;; Version:        1.0
  14.  
  15. ;;   This program is free software; you can redistribute it and/or modify
  16. ;;   it under the terms of the GNU General Public License as published by
  17. ;;   the Free Software Foundation; either version 1, or (at your option)
  18. ;;   any later version.
  19.  
  20. ;;   This program is distributed in the hope that it will be useful,
  21. ;;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. ;;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. ;;   GNU General Public License for more details.
  24.  
  25. ;; You should have received a copy of the GNU General Public License
  26. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  27. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  28.  
  29. ;; WOOL interaction mode is for use with Epoch and the GWM window
  30. ;; manager.  It provides functionallity similar to the builtin
  31. ;; lisp-interaction-mode of Emacs for GWM WOOL code.  Basically the
  32. ;; only change was making a new function (gwm-eval-last-sexp) to grab
  33. ;; the last sexp and send it to GWM by way of the 'GWM_EXECUTE' X
  34. ;; property.  See the GWM manual for more details on GWM and WOOL.
  35.  
  36. (if (not (boundp 'emacs-lisp-mode-map))    ; Need to make sure standard
  37.     (load-library "lisp-mode"))        ; lisp mode stuff has been loaded
  38.  
  39. (defvar wool-interaction-mode-map ()
  40.   "Keymap for WOOL interaction mode.")
  41.  
  42. (if wool-interaction-mode-map        ; If need to bind keys
  43.     ()
  44.   (setq wool-interaction-mode-map (make-sparse-keymap))
  45.   (lisp-mode-commands wool-interaction-mode-map)
  46.   (define-key wool-interaction-mode-map "\n" 'gwm-eval-last-sexp))
  47.  
  48. (defun gwm-eval-last-sexp (arg)
  49.   "Sends sexp before point to GWM via the GWM_EXECUTE property of the
  50. window.  Output is sent to stderr of the GWM process." 
  51.   (interactive "P")
  52.   (copy-to-register 24
  53.     (let ((stab (syntax-table)))
  54.       (unwind-protect 
  55.       (save-excursion
  56.         (set-syntax-table emacs-lisp-mode-syntax-table)
  57.         (forward-sexp -1)
  58.         (point))
  59.     (set-syntax-table stab)))
  60.     (point) ())
  61.   (epoch::set-property "GWM_EXECUTE" (get-register 24)))
  62.  
  63. (defun wool-interaction-mode ()
  64.   "Major mode for typing and evaluating WOOL code for the GWM window
  65. manager.  Mostly a direct rip off of Lisp-interaction mode from the
  66. Emacs distribution.  Only works under Epoch.
  67.  
  68. Commands:
  69. Same as Lisp-interaction mode, except LFD sends the current sexp to
  70. GWM to be executed (by means of the GWM_EXECUTE property).
  71. \\{wool-interaction-mode-map}"
  72.  
  73.   (interactive)
  74.   (if (boundp 'epoch::version)        ; See if running under epoch
  75.       (progn
  76.     (kill-all-local-variables)
  77.     (use-local-map wool-interaction-mode-map)
  78.     (set-syntax-table emacs-lisp-mode-syntax-table)
  79.     (setq major-mode 'wool-interaction-mode)
  80.     (setq mode-name "WOOL Interaction")
  81.     (lisp-mode-variables ())
  82.     (run-hooks 'wool-interaction-mode-hook))
  83.     (message "Sorry, need to be running Epoch to work.")))
  84.  
  85. (defun gwm-buffer ()
  86.   "Opens up a new buffer named *GWM* in WOOL interaction mode."
  87.   (interactive)
  88.   (switch-to-buffer (get-buffer-create "*GWM*"))
  89.   (wool-interaction-mode))
  90.