home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / contrib / emacs-mode / emacs-mode.readme
Encoding:
Internet Message Format  |  1995-07-03  |  3.0 KB

  1. Date: Wed, 26 Jan 1994 12:25:34 +0100
  2. Return-Path: owner-gwmtalk@sophia.inria.fr
  3. From: Sven Wischnowsky <oberon@cs.tu-berlin.de>
  4. Message-Id: <199401261125.AA00332@mail.cs.tu-berlin.de>
  5. To: geroahde@w250zrz.zrz.TU-Berlin.DE
  6. Cc: gwm-talk@mirsa.inria.fr
  7. In-Reply-To: <9401241755.AA22923@w250zrz.zrz.TU-Berlin.DE> (message from Gero Guenther on Mon, 24 Jan 94 18:55:29 +0100)
  8. Subject: Re: gwm support for emacs-19.22
  9. No-Reply-To: oberon@cs.tu-berlin.de
  10. Content-Length: 6754
  11.  
  12.  
  13. Gero Guenther wrote:
  14.  
  15. > Hello folks,
  16. > are there patches available for emacs-19.22
  17. > to support the wool-interaction-mode and the other comunication with
  18. > gwm I know from epoch?
  19. > I lost the account with my addr on the mailinglist for gwm so please
  20. > respond with email or put me on the mailinglist again before
  21. > responding.
  22.  
  23. Well, not exactly...
  24.  
  25. My solution to this problem was to patch gwm. Below is a patch for the
  26. gwm.c file (version 1.7o) which adds two new options: 
  27.  
  28. -I: this one makes gwm read its stdin (and, of course, evaluate it)
  29. -P: together with -I makes gwm print a simple prompt showing the
  30.     number of currently open parentheses
  31.  
  32. COLAS NOTE: these patches has been added in the current version...
  33. The rest is simple, something like this (in emacs):
  34.  
  35. (defvar gwm-proc nil)
  36. (defvar gwm-buf nil)
  37.  
  38. (if (not gwm-proc)
  39.     (let ((b (generate-new-buffer "*gwm*"))
  40.       (ob (current-buffer))
  41.       (m (copy-keymap lisp-mode-map)))
  42.       (set-buffer b)
  43.       (use-local-map m)
  44.       (local-set-key "\C-j" 'gwm-send)
  45.       (set-buffer ob)
  46.       (setq gwm-buf b)
  47.       (setq gwm-proc (start-process "gwm" 
  48.                    b
  49.                    (if (string-equal system-type
  50.                              "usg-unix-v")
  51.                        "/home/pub/bin/sol2/gwm"
  52.                      "/home/pub/bin/sun4/gwm")
  53.                    "-I"))
  54.       (process-kill-without-query gwm-proc)
  55.       (set-process-filter gwm-proc 'gwm-filter)
  56.       (set-process-sentinel gwm-proc 'gwm-sentinel)))
  57.  
  58. (defun gwm-filter (p s)
  59.   (let ((ob (current-buffer)))
  60.     (unwind-protect
  61.     (let ((i 0) (l (length s)) (p (point)))
  62.       (set-buffer zg-buf)
  63.       (insert s)
  64.       (if (string-match "\012--emacs-exec:\012\\(.*\\)\012--end" s)
  65.           (eval-region (+ p (match-beginning 1))
  66.                (+ p (match-end 1))))))
  67.     (set-buffer ob)))
  68.     
  69. (defun gwm-sentinel (process message)
  70.   (setq gwm-proc (start-process "gwm" 
  71.                    gwm-buf
  72.                    (if (string-equal system-type
  73.                          "usg-unix-v")
  74.                    "/home/pub/bin/sol2/gwm"
  75.                  "/home/pub/bin/sun4/gwm")
  76.                    "-I"))
  77.   (process-kill-without-query gwm-proc)
  78.   (set-process-filter gwm-proc 'gwm-filter)
  79.   (set-process-sentinel gwm-proc 'gwm-sentinel))
  80.     
  81. (defun gwm-exec (s)
  82.   (interactive "Sgwm: ")
  83.   (send-string gwm-proc (concat s "\n")))
  84.  
  85. (defun gwm-send ()
  86.   (interactive)
  87.   (let ((op (point))
  88.     (stab (syntax-table)))
  89.     (set-syntax-table emacs-lisp-mode-syntax-table)
  90.     (forward-sexp -1)
  91.     (gwm-exec (buffer-substring (point) op))
  92.     (goto-char op)
  93.     (insert "\n")
  94.     (set-syntax-table stab)))
  95.  
  96.  
  97. The filter function allows you to execute emacs code from gwm:
  98.  
  99. (defun eval-emacs (s)
  100.   (print "\n--emacs-exec:\n" s "\n--end\n"))
  101.  
  102. Hope this helps...
  103.  
  104. Bye
  105.  Sven
  106.  
  107.