Initial Commit
[packages] / xemacs-packages / ilisp / ilisp-cl-easy-menu.el
1 ;;; Ilisp-easy-menu.el --- (easy)menu's on Emacs for Ilisp
2
3 ;;; Copyright (C) 1996 Holger Schauer
4 ;;;
5 ;;; This file is part of ILISP.
6 ;;; Please refer to the file COPYING for copyrights and licensing
7 ;;; information.
8 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
9 ;;; of present and past contributors.
10 ;;;
11 ;;; $Id: ilisp-cl-easy-menu.el,v 1.3 2002-06-03 23:36:59 wbd Exp $
12
13 ;; Author: Holger Schauer <Holger.Schauer@gmd.de>
14 ;; Maintainer: Holger.Schauer@gmd.de
15 ;; Keywords: lisp ilisp extensions menu easymenu
16 ;; Version 0.2
17 ;; Status: Should work with any Emacs and easymenu.el (as by Per Abrahamsen)
18 ;; Created: 1996-10-08
19 ;; Last modified: 1996-10-15 (that's 15th October 1996, folks)
20
21 ;; Where to get it: http://www.uni-koblenz.de/~schauer/uniemacs.html
22
23 ;; This program is free software; you can redistribute it and/or modify
24 ;; it under the terms of the GNU General Public License as published by
25 ;; the Free Software Foundation; either version 2, or (at your option)
26 ;; any later version.
27 ;;
28 ;; This program is distributed in the hope that it will be useful,
29 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31 ;; GNU General Public License for more details.
32 ;;
33 ;; You should have received a copy of the GNU General Public License
34 ;; along with this program; if not, you can either send email to this
35 ;; program's maintainer or write to: The Free Software Foundation,
36 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
37
38 ;;; Commentary:
39
40 ;; This file and it's extensions have been named ilisp-xemacs-menu before. 
41 ;; As it is ensured now to work with any Emacs with easymenu the file
42 ;; itself and all relevant names (of commands and variables) are renamed. 
43
44 ;; Use this file as an extension to Ilisp 5.7/5.8 
45 ;; (seee http://www.cs.cmu.edu/~campbell/ilisp/index.html)
46 ;; Put it in a place where (X)Emacs can find it and augment your
47 ;; .emacs like the following to use it.
48 ;; (load-library "ilisp-easy-menu")
49 ;; This needs to be loaded prior to Ilisp !
50 ;; This should give you the menu in any source code buffer and any inferior 
51 ;; ilisp buffer. Be careful: the menu is initialized with add-hook
52 ;; on ilisp-mode-hook and lisp-mode-hook, so if you setq these two
53 ;; hooks afterwards you won't get the menu.
54 ;;
55 ;; If you want to use it with Emacs (not XEmacs) you will want to get rid
56 ;; of the old menu. You can do so by applying the following patches (to
57 ;; Ilisp 5.8 - for 5.7 check for ilisp-update-menu and the loading of the
58 ;; menu, i.e. ilisp-menu and ilisp-mnb)
59 ;; For ilisp.el:
60 ;; 185c185,187
61 ;< (if (not (member +ilisp-emacs-version-id+ '(xemacs lucid-19 lucid-19-new)))
62 ;---
63 ;> (if (and
64 ;>      (not (member +ilisp-emacs-version-id+ '(xemacs lucid-19 lucid-19-new)))
65 ;>      (not (featurep 'ilisp-easy-menu)))
66 ;; For ilisp-utl.el:
67 ;127c127,129
68 ;<   (if (not (member +ilisp-emacs-version-id+ '(xemacs lucid-19 lucid-19-new)))
69 ;---
70 ;>   (if (and (not 
71 ;>          (member +ilisp-emacs-version-id+ '(xemacs lucid-19 lucid-19-new)))
72 ;>         (not (featurep 'ilisp-easy-menu)))
73
74 (require 'easymenu)
75
76 (eval-when (load compile eval)
77   (when (and ilisp-*use-hyperspec-interface-p*
78              (not (featurep 'hyperspec)))
79     (load-library "extra/hyperspec")))
80
81 (defvar ilisp-cl-easy-menu
82   `("Ilisp"
83     [ "Load File" load-file-lisp t ]
84     [ "Run Ilisp" run-ilisp t ]
85     "--"
86     ("Evaluate"
87      [ "Eval region" eval-region-lisp t ]
88      [ "Eval defun" eval-defun-lisp t ]
89      [ "Eval next sexp" eval-next-sexp-lisp t ]
90      ;; [ "Eval last sexp" eval-last-sexp-lisp t ]
91      [ "Eval changes" eval-changes-lisp t ]
92      )
93     ("Evaluate and Go"
94      [ "Eval region" eval-region-and-go-lisp t ]
95      [ "Eval defun" eval-defun-and-go-lisp t ]
96      [ "Eval next sexp" eval-next-sexp-and-go-lisp t ]
97      ;; [ "Eval last sexp" eval-last-sexp-and-go-lisp t ]
98      )
99     ("Compile"
100      [ "File" compile-file-lisp t ]
101      [ "Defun" compile-defun-lisp t ]
102      [ "Defun and go" compile-defun-and-go-lisp t ]
103      [ "Region" compile-region-lisp t ]
104      [ "Region and go" compile-region-and-go-lisp t ]
105      [ "Compile changes" compile-changes-lisp t ]
106      )
107     "--"
108     ("Editing"
109      [ "Edit definitions" edit-definitions-lisp t ]
110      [ "Edit next def." next-definition-lisp t ]
111      [ "Edit callers" edit-callers-lisp t ]
112      [ "Edit next caller" next-caller-lisp t ]
113      [ "Insert arguments" arglist-lisp t ]
114      "--"
115      [ "Find unbalanced paren" find-unbalanced-lisp t ]
116      [ "Close all parens" close-all-lisp t ]
117      [ "Close and send lisp" close-and-send-lisp t ]
118      "--"
119      [ "Reindent" reindent-lisp t ]
120      [ "Indent sexp" indent-sexp-ilisp t ]
121      [ "Indent for comment" lisp-indent-for-comment t ]
122      [ "Comment region" comment-region-lisp t ]
123      "--"
124      [ "Search in Files" search-lisp t ] 
125      "--"
126      [ "Kill sexp" kill-sexp t ] 
127      [ "Kill last sexp" backward-kill-sexp t ]
128      "--"
129      [ "Macroexpand" macroexpand-lisp t ]
130      [ "Macroexpand-1" macroexpand-1-lisp t ]
131      "--"
132      [ "Begin of def" beginning-of-defun-lisp t ]
133      [ "End of defun" end-of-defun-lisp t ]
134      )
135     ("Documentation"
136      [ "Documentation" documentation-lisp t ]
137      [ "Describe" describe-lisp t ]
138      [ "Inspect" inspect-lisp t ]
139      [ "Argument List" arglist-lisp t ] ; Just a test.
140      "--"
141      ;; With which var can I test if 'fi' is really loaded? Can I just
142      ;; use FEATUREP?
143      [ "Clman-apropos" fi:clman-apropos nil ] 
144      [ "Hyperspec - apropos"
145        hyperspec-lookup
146        ,ilisp-*use-hyperspec-interface-p* ]
147      )
148     "--"
149     ("Package"
150      "--"
151      [ "Package" package-lisp t ]
152      [ "Set Lisp Package" set-package-lisp t ]
153      [ "Set Buffer Package" set-buffer-package-lisp t ]
154      )
155     "--"
156     ("Misc"
157      ;; [ "Reset Ilisp" reset-ilisp t ]
158      [ "Select Ilisp" select-ilisp t ]
159      [ "Switch to lisp" switch-to-lisp t ]
160      [ "Abort commands" abort-commands-lisp t ]
161      [ "Status of Lisp" status-lisp t ]  
162      "--"
163      [ "Mark change" mark-change-lisp t ]
164      [ "List changes" list-changes-lisp t ]
165      [ "Clear changes" clear-changes-lisp t ]
166      "--"
167      [ "Trace defun" trace-defun-lisp t ]
168      )
169     "--"
170     [ "Reset Ilisp Connection" reset-ilisp t ]
171     [ "Repair Ilisp Connection" repair-ilisp t ]
172     )
173   )
174
175 ;;; insert "Debug" Menu if ilisp-*enable-ild-support-p*
176 ;;; enable the commands only if inside the debugging loop
177 ;;;
178 ;;; 2000-10-10 17:34:05 rurban
179 (defconst ilisp-ild-easy-menu
180     `("Debug"
181      [ "Abort"    ild-abort     (ilisp-ild-p) ]
182      [ "Continue" ild-continue  (ilisp-ild-p) ]
183      [ "Next"     ild-next      (ilisp-ild-p) ]
184      [ "Previous" ild-previous  (ilisp-ild-p) ]
185      [ "Top"      ild-top       (ilisp-ild-p) ]
186      [ "Bottom"   ild-bottom    (ilisp-ild-p) ]
187      [ "Backtrace" ild-backtrace (ilisp-ild-p) ]
188      [ "Locals"   ild-locals    (ilisp-ild-p) ]
189      [ "Local"    ild-local     (ilisp-ild-p) ]
190      [ "Return"   ild-return    (ilisp-ild-p) ]
191      [ "Retry"    ild-retry     (ilisp-ild-p) ]
192      [ "Trap on exit" ild-trap-on-exit (ilisp-ild-p) ]
193      "--"
194      [ "Fast lisp" fast-lisp t ]
195      [ "Slow lisp" slow-lisp t ]
196      )
197     )
198
199 (defun ilisp-ild-p ()
200   t)
201
202 (defun ilisp-insert-menu (menu where what)
203   "Insert WHAT into MENU after WHERE"
204   (if (position what menu)
205       menu
206     (let ((i (position (assoc where menu) menu)))
207       (setq i    (1+ i)
208             menu (append (butlast menu (- (length menu) i))
209                          (list what)
210                          (nthcdr i menu))))))
211   
212 (if ilisp-*enable-ild-support-p*
213   (setq ilisp-cl-easy-menu 
214         (ilisp-insert-menu ilisp-cl-easy-menu "Misc" ilisp-ild-easy-menu)))
215
216 ;;; ilisp-update-menu
217 ;;;
218 ;;; 19990818 Marco Antoniotti
219
220 (defun ilisp-update-menu (status)
221   ;; Backward compatibility with old keymap based menus.
222   ;; A no-op for the time being.
223   )
224
225 (defun ilisp-redefine-menu ()
226   (easy-menu-remove ilisp-cl-easy-menu)
227   (easy-menu-define menubar-ilisp ilisp-mode-map 
228                     "Ilisp commands"
229                     ilisp-cl-easy-menu)
230   (easy-menu-add ilisp-cl-easy-menu 'ilisp-mode-map)
231   )
232
233 (provide 'ilisp-cl-easy-menu)
234
235 ;;; Hooks to add the menu.
236 ;;;
237 ;;; Notes:
238 ;;; 19990818 Marco Antoniotti
239 ;;; Since I could have installed a Scheme menu before a CL one, I
240 ;;; could be forced to remove the previous menu.  Now the code does not do
241 ;;; this, but it should.
242
243 (add-hook 'ilisp-mode-hook
244           (lambda () 
245             (when (featurep 'easymenu)       
246               (easy-menu-define menubar-ilisp
247                                 ilisp-mode-map 
248                                 "Ilisp commands"
249                                 ilisp-cl-easy-menu) 
250               (easy-menu-add ilisp-cl-easy-menu 'ilisp-mode-map)
251               )))
252          
253
254 (add-hook 'lisp-mode-hook
255           (lambda () 
256             (when (featurep 'easymenu)       
257               (easy-menu-define menubar-lisp-ilisp
258                                 lisp-mode-map 
259                                 "lisp commands"
260                                 ilisp-cl-easy-menu) 
261               (when (boundp 'lisp-menu)
262                 (easy-menu-remove lisp-menu))
263               (easy-menu-add ilisp-cl-easy-menu 'lisp-mode-map)
264               )))
265
266 ;;; end of file-- ilisp-cl-easy-menu.el --