Article View: gnu.epoch.misc
Article #1906Re: GWM vs Motif
From: Dan L. Pierson
Date: Mon, 01 Jul 1991 20:38
Date: Mon, 01 Jul 1991 20:38
183 lines
6546 bytes
6546 bytes
Epoch's only dependency on Motif is that, by itself, Epoch has no
menus facility at all. The rest of Epoch's look and feel is GNU
Emacs, which seems like a good idea for an X11 based GNU Emacs...
In terms of menus, the only Epoch requirement is that something else
post the menu. The following code will use the binary "xmenu" to post
a menu:
(defun interpret-output (process output)
(command-execute (intern-soft output)))
(defun do-menu (foo)
(interactive)
(set-process-filter (start-process "xmenu"
nil
"xmenu" "-heading" "Epoch X-Emacs Menu"
"Run KEE=lanllisp"
"Run KEE and Load Rocky-2=run-rocky-2"
"Load Rocky-2=load-rocky-2"
"Compile Rocky-2=compile-rocky-2"
"Save Buffer=save-buffer"
"Buffer Menu=list-buffers"
"Dired=dired"
"Read Mail=rmail"
"Read News On Beta=beta"
"Read News on Mica=mica"
"Exit Minibuffer=exit-minibuffer"
"Exit Menu=exit-menu")
'interpret-output))
(defmouse ':global "C-Middle" 'mouse-ignore 'do-menu)
This has the following features:
1. It is slow because the xmenu executable must be started each time.
2. The menu's look and feel depends entirely on the implementation
of xmenu (which uses Athena widgets, a Motif version should be
trivial).
3. The Epoch code is easy to write because there is a simple way
to make Epoch wait until "xmenu" returns a result.
The following is the code I use to have gwm post a
menu:
;;; gwm-menus.el -*- emacs-lisp -*- Epoch support for simple GWM menus
;;; Original code by Colas 1991-02-18
;;; Heavily hacked by Dan Pierson, Encore Computer Corp, 2/28/91
;;; Explicity specify all Epoch commands in string passed to GWM
;;; Gratuitously reformat
;;;============================================================================
;;; Sane EPOCH_EXEC
;;;============================================================================
;;; here we add a handler to read code from X properties without trashing
;;; epoch in case of errors in sent code.
(defun epoch-exec::property-init ()
"private property to avoid handler lost from external error"
(push-property "EPOCH_EXEC"
(function (lambda (type prop screen)
(let ((cw (selected-window))
(action (get-property prop screen)))
(unwind-protect
(progn
(select-window (epoch::selected-window screen))
(and (stringp action)
(eval (read action))))
(select-window cw)))))))
(epoch-exec::property-init)
;;; use by sending to X property EPOCH_EXEC the code:
;;; (let ((protect epoch::event-handler))
;;; (unwind-protect
;;; (progn
;;;
;;; ... [code to excecute via the property] ...
;;;
;;; (setq epoch::event-handler protect))))
;;;
;;; General menu popper, expects a list of the form:
;;; '("Title"
;;; ("Item" epoch-code)
;;; ...)
(defun gwm-pop-menu (items)
(epoch::set-property "GWM_EXECUTE"
(concat "(progn (require 'epoch)(list-menu-make "
(prin1-to-string items)
"))"
)))
;;; Application: pop a menu with epoch buffers:
(defun gwm-choose-buffer (arg)
(let ((buflist (cons "Epoch Screens"
(mapcar (function (lambda (buf)
(let ((name (buffer-name buf)))
(list name
'switch-to-buffer
(concat "\"" name "\"")))))
(buffer-list)))))
(gwm-pop-menu buflist)))
(global-set-mouse mouse-right mouse-control-shift 'gwm-choose-buffer)
;;; end of gwm-menus.el
This has the following features:
1. It is fast, because GWM is already up and running.
2. GWM determines the look and feel.
3. The Epoch code is a little trickier because Epoch has to
receive it's result via an asynchronous X11 property change.
4. IMPORTANT: The communication with the GWM is solely via X11
property change events.
The last feature allows for a fairly simple Motif solution: write a
Motif-based menu server. The Epoch community (and much of the X11
community) would be grateful if someone would release such a tool for
public use and study. As a hint towards such a thing, here is all of
the GWM support for these menus:
;;; Code to communicate with epoch
;;; Colas 1991-02-18
;;; Heavily hacked by Dan Pierson, Encore Computer Corp, 2/28/91
;;; Explicity specify all Epoch commands in list passed to GWM (as
;;; a string)
;;; Gratuitously reformat
;;;
;;; this needs the epoch code "gwm-menus.el" loaded into epoch
;;; routine to send a string to be executed by epoch, supposed to be the
;;; current window
(defun send-epoch (code)
(set-x-property "EPOCH_EXEC"
(+ "(let ((protect epoch::event-handler)) (unwind-protect "
code
"(setq epoch::event-handler protect))))"
)))
;;; Menu package:
;;; How to make a menu of arbitrary Epoch commands
(defunq list-menu-make (args)
(pop-menu (menu-make-from-list
(+ (list (list 'pop-label-make (# 0 args)))
(mapfor s (sublist 1 (length args) args)
(list 'item-make (# 0 s)
(list 'send-epoch-command
(sublist 1 (length s) s))))))))
(defun stringify (args)
(with (t (type args))
(cond ((eq t 'string) args)
((eq t 'list)
(with (s "(")
(for i args (setq s (+ s (stringify i) " ")))
(+ s ")")))
((or (eq t 'atom)
(eq t 'number))
(+ "" args))
(t ""))))
(defunq send-epoch-command (args)
(send-epoch (stringify args)))
;;; All done
(provide 'epoch)
--
dan
In real life: Dan Pierson, Encore Computer Corporation, Research
UUCP: {talcott,linus,necis,decvax}!encore!pierson
Internet: pierson@encore.com
Technical Details
Message-ID:
<PIERSON.91Jul1163832@xenna.encore.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!encore!piersonReferences:
<9107011500.AA27407@a.cs.uiuc.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,cb25a57c6462459b X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1991-07-01 15:21:18 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!encore!pierson From: pierson@encore.com (Dan L. Pierson) Newsgroups: gnu.epoch.misc Subject: Re: GWM vs Motif Message-ID: <PIERSON.91Jul1163832@xenna.encore.com> Date: 1 Jul 91 20:38:32 GMT References: <9107011500.AA27407@a.cs.uiuc.edu> Sender: news@Encore.COM Distribution: gnu Organization: Encore Computer Corporation Lines: 183 Nntp-Posting-Host: xenna.encore.com In-reply-to: STANK%RCHVMX@ibm.com's message of 1 Jul 91 05:00:08 GMT