Initial Commit
[packages] / xemacs-packages / jde / lisp / beanshell.el
1 ;;; beanshell.el
2 ;; $Revision: 1.76 $ 
3
4 ;; Author: Paul Kinnucan <paulk@mathworks.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
7
8 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004 Paul Kinnucan.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; This package is intended to serve as an interface between Emacs and
28 ;; Pat Neimeyer's BeanShell, a Java source code interpreter (see
29 ;; http://www.beanshell.org/).
30
31 ;; This package is intended to serve both interactive users and Emacs
32 ;; applications that want to use Java as an extension language for
33 ;; Emacs. To facilitate this dual usage, this package implements the
34 ;; BeanShell interface as an eieio class named bsh. This class is
35 ;; intended to serve as a base class for classes tailored to specific
36 ;; applications. This class defines the following methods:
37 ;;
38 ;; bsh               Constructs an instance of the bsh class.
39 ;; bsh-launch        Launches the BeanShell and creates an Emacs buffer
40 ;;                   for interacting with the BeanShell.
41 ;; bsh-eval          Sends a Java expression to the BeanShell for evaluation and
42 ;;                   waits for a response.
43 ;; bsh-eval-r        Sends a Java expression to the BeanShell for evaluation 
44 ;;                   and then evaluates the resulting BeanShell output
45 ;;                   as a Lisp expression.
46 ;; bsh-async-eval    Sends a Java expression to the BeanShell for evaluation
47 ;;                   and sets a listener to evaluate the response as a Lisp
48 ;;                   expression
49 ;;
50 ;; bsh-eval and bsh-eval-r synchronous functions. After sending a Java
51 ;; expression to the BeanShell, they suspend Emacs until the BeanShell
52 ;; responds. bsh-async-eval does not suspend Emacs. It does, however,
53 ;; set a listener that evaluates any responses from the BeanShell as
54 ;; Lisp expressions.
55 ;;
56 ;; See bsh-demo-eval for an example of how to use bsh-async-eval to evaluate a
57 ;; Java expression.
58
59 ;;
60 ;; The bsh class also defines fields that specify the path of the
61 ;; BeanShell jar file, the Java vm used to run the BeanShell, a
62 ;; startup classpath and directory, vm arguments, etc. Emacs package
63 ;; developers can easily extend this base class to tailor the BeanShell
64 ;; to specific applications. 
65 ;; This package provides one such derived class named
66 ;; bsh-standalone-bsh.  This is a BeanShell implementation intended
67 ;; for use by interactive users. 
68
69 ;; To use the standalone BeanShell, download the BeanShell jar file
70 ;; from http://www.beanshell.org/ and install it on your system.
71 ;; Set bsh-jar to the path of the BeanShell jar. Set bsh-vm to
72 ;; the path of a Java vm on your system (this is necessary only
73 ;; if the java vm is not on your system's command path). Execute
74 ;; M-x bsh to start the BeanShell. To terminate the BeanShell,
75 ;; execute M-x bsh-exit.
76 ;;
77
78 (require 'eieio)
79 (require 'comint)
80
81 (defgroup bsh nil
82   "Customizations for the Emacs inteface to Pat Neimeyer's Java
83 interpreter, the Beanshell."
84   :group 'tools
85   :prefix "bsh-")
86
87 (defcustom bsh-jar "bsh.jar"
88   "Path to the jar file containing the BeanShell classes."
89   :group 'bsh
90   :type 'file)
91
92 ;; (makunbound 'bsh-vm)
93 (defcustom bsh-vm nil
94   "Java vm to be used to run the standalone BeanShell. By default,
95 bsh uses the first vm that it finds on the Emacs
96 `exec-path' (usually the same as your system's command
97 path). To specify a vm, select Path and enter the
98 path to the vm. "
99   :group 'bsh
100   :type '(choice 
101           (const :tag "Default" :value nil)
102           (file :tag "Path")))
103
104 (defcustom bsh-classpath nil
105   "Startup classpath for the BeanShell."
106   :group 'bsh
107   :type '(repeat (file :tag "Path")))
108
109 ;; (makunbound 'bsh-startup-timeout)
110 (defcustom bsh-startup-timeout 10
111   "*Length of time Emacs waits for the Beanshell to startup.
112 Increase the value of this variable if you get Lisp errors on
113 BeanShell startup on Unix. Setting this value on some versions of
114 XEmacs, e.g., Windows, seems to cause premature timeouts.  If you keep
115 getting timeout errors no matter how large a value you set, try
116 setting this variable to no timeout (nil)."
117   :group 'bsh
118   :type '(choice (const :tag "No timeout" :value nil)
119                  (number :tag "Length")))
120
121 ;; (makunbound 'bsh-eval-timeout)
122 (defcustom bsh-eval-timeout 30
123   "*Length of time in seconds Emacs waits for the Beanshell to
124 evaluate a Java expression before giving up and signaling an
125 error. Setting this value on some versions of XEmacs, e.g., Windows,
126 seems to cause premature timeouts. If you keep getting timeout errors
127 no matter how large a value you set, try setting this variable to no
128 timeout (nil)."
129   :group 'bsh
130   :type '(choice (const :tag "No timeout" :value nil)
131                  (number :tag "Length")))
132
133 (defcustom bsh-vm-args nil
134   "*Specify arguments to be passed to the Java vm.
135 This option allows you to specify one or more arguments to be passed
136 to the Java vm that runs the BeanShell. Note that the value of this
137 variable should be a list of strings, each of which represents an
138 argument. When customizing this variable, use a separate text field
139 for each argument."
140   :group 'bsh
141   :type '(repeat (string :tag "Argument")))
142
143 (defcustom bsh-startup-directory ""
144   "Path of directory in which to start the beanshell.
145 The path may start with a tilde (~) indication your
146 home directory and may include environment variables.
147 If this variable is the null string (the default), 
148 the beanshell starts in the directory of the current
149 buffer."
150   :group 'bsh
151   :type 'directory)
152
153
154 (defclass bsh-buffer ()
155   ((buffer-name   :initarg :buffer-name
156                   :initform "*bsh*"
157                   :type string
158                   :documentation
159                   "Name of buffer used to interact with BeanShell process.")
160    (buffer        :initarg :buffer
161                   :type buffer
162                   :documentation
163                   "Buffer used to interact with BeanShell process.")
164
165    (process       :initarg :process
166                   :documentation 
167                   "Beanshell process.")
168   
169    (filter        :initarg :filter
170                   :type function
171                   :documentation
172                   "Function used to propcess buffer output."))
173   "Buffer that displays BeanShell output.")
174
175
176 (defmethod initialize-instance ((this bsh-buffer) &rest fields)
177   "Constructor for BeanShell buffer instance."
178   (call-next-method)
179
180   (oset this buffer (get-buffer-create (oref this buffer-name))))
181
182 (defmethod bsh-buffer-live-p ((this bsh-buffer))
183   "Return t if this buffer has not been killed."
184   (buffer-live-p (oref this buffer)))
185
186 (defmethod bsh-buffer-display ((this bsh-buffer))
187   "Display this buffer."
188   (pop-to-buffer (oref this buffer-name)))
189
190
191 (defclass bsh-comint-buffer (bsh-buffer)
192   ()
193   "BeanShell buffer that runs in `comint-mode'.")
194
195 (defmethod initialize-instance ((this bsh-comint-buffer) &rest fields)
196   "Constructor for BeanShell buffer instance."
197   (call-next-method)
198   (with-current-buffer (oref this buffer)
199     (comint-mode)
200     (setq comint-prompt-regexp "bsh % ")))
201
202 (defmethod bsh-comint-buffer-exec ((this bsh-comint-buffer) vm vm-args)
203   (let ((win32-start-process-show-window t)
204         (w32-start-process-show-window t)
205         (w32-quote-process-args ?\") ;; Emacs
206         (win32-quote-process-args ?\") ;; XEmacs
207         (windowed-process-io t)
208         (process-connection-type nil)
209         ;; XEmacs addition
210         (coding-system-for-read
211          (if (or (member system-type '(cygwin32 cygwin))
212                  (eq system-type 'windows-nt))
213              'raw-text-dos)))
214     (comint-exec (oref this buffer) "bsh"  vm  nil vm-args))
215
216   (oset this process (get-buffer-process (oref this buffer)))
217   (oset this filter (process-filter (oref this process)))
218   (process-kill-without-query (oref this process))
219
220   (if (eq system-type 'windows-nt)
221       (accept-process-output (oref this process) bsh-startup-timeout 0)
222     (while (accept-process-output (oref this process) bsh-startup-timeout 0))))
223
224
225 (defclass bsh-compilation-buffer (bsh-buffer)
226   ()
227   "Implements a `compilation-mode' buffer for BeanShell output.")
228
229 (defmethod initialize-instance ((this bsh-compilation-buffer) &rest fields)
230   "Constructor for BeanShell compilation buffer instance."
231
232   (bsh-compilation-buffer-create-native-buffer this)
233
234   (oset 
235    this 
236    filter
237    (lexical-let ((this-buf this))
238      (lambda (process output)
239        (bsh-compilation-buffer-filter this-buf process output))))
240     
241   ;; This buffer does not have its own process.
242   (oset this process nil)
243   (bsh-compilation-buffer-set-mode this))
244
245 (defmethod bsh-compilation-buffer-create-native-buffer ((this bsh-compilation-buffer))
246   "Creates the native Emacs buffer encapsulated by this eieio object."
247   (oset this buffer-name "*bsh compilation*")
248   (oset this buffer (get-buffer-create (oref this buffer-name))))
249
250 (defmethod bsh-compilation-buffer-set-mode ((this bsh-compilation-buffer))
251   "Define buffer mode."
252    (let ((thisdir default-directory))
253     (with-current-buffer (oref this buffer)
254       (let ((buf (oref this buffer))
255             ;; Some or all of these variables may not be defined by
256             ;; the various versions of compile.el shipped with Emacs
257             ;; and XEmacs.
258             (error-regexp-alist 
259              (if (boundp  'compilation-error-regexp-alist)
260                   compilation-error-regexp-alist))
261             (enter-regexp-alist 
262              (if (boundp 'compilation-enter-directory-regexp-alist) 
263                  compilation-enter-directory-regexp-alist))
264             (leave-regexp-alist 
265              (if (boundp 'compilation-leave-directory-regexp-alist) 
266                  compilation-leave-directory-regexp-alist))
267             (file-regexp-alist 
268              (if (boundp 'compilation-file-regexp-alist)
269                  compilation-file-regexp-alist))
270             (nomessage-regexp-alist 
271              (if (boundp 'compilation-nomessage-regexp-alist)
272                  compilation-nomessage-regexp-alist))
273             (parser 
274              (if (boundp 'compilation-parse-errors-function)
275                  compilation-parse-errors-function))
276             (error-message "No further errors"))
277
278         ;; In case the compilation buffer is current, make sure we get the global
279         ;; values of compilation-error-regexp-alist, etc.
280         (kill-all-local-variables)
281
282         ;; Clear out the compilation buffer and make it writable.
283         (setq buffer-read-only nil)
284         (buffer-disable-undo (current-buffer))
285         (erase-buffer)
286         (buffer-enable-undo (current-buffer))
287
288         (compilation-mode)
289         (setq buffer-read-only nil)
290
291         (set (make-local-variable 'compilation-parse-errors-function) parser)
292         (set (make-local-variable 'compilation-error-message) error-message)
293         (set (make-local-variable 'compilation-error-regexp-alist)
294              error-regexp-alist)
295
296         (if (not (featurep 'xemacs))
297             (progn
298               (set (make-local-variable 'compilation-enter-directory-regexp-alist)
299                    enter-regexp-alist)
300               (set (make-local-variable 'compilation-leave-directory-regexp-alist)
301                    leave-regexp-alist)
302               (set (make-local-variable 'compilation-file-regexp-alist)
303                    file-regexp-alist)
304               (set (make-local-variable 'compilation-nomessage-regexp-alist)
305                    nomessage-regexp-alist)))
306
307         (setq default-directory thisdir)
308         (setq compilation-directory-stack (list default-directory))))))
309
310 (defmethod bsh-compilation-buffer-filter ((this bsh-compilation-buffer) proc string) 
311   "This filter prints out the result of the process without buffering.
312 The result is inserted as it comes in the compilation buffer."
313   (with-current-buffer (oref this buffer)
314     (let ((end-of-result (string-match ".*bsh % " string))
315           (win (get-buffer-window (oref this buffer)))
316           output len (status " "))
317       (save-excursion
318         ;;Insert the text, advancing the process marker
319         (goto-char (point-max))
320         (if end-of-result
321             (progn 
322               (setq output (substring string 0 end-of-result))
323               (set-buffer-modified-p nil)
324               
325               ;;Searching backwards for the status code
326               (while (member status '(" " "\r" "\n"))
327                 (setq len (length output))
328                 (if (not (= len 0))
329                     (progn
330                       (setq status (substring output (- len 1))) 
331                       (setq output (substring output 0 (- len 1))))
332                   (progn
333                     (setq status (buffer-substring (- (point-max) 1) 
334                                                    (point-max)))
335                     (delete-region (- (point-max) 1) (point-max)))))
336
337               (insert output)
338               (compilation-handle-exit 
339                'exit status
340                (if (string= "0" status)
341                    "finished\n"
342                  (format "exited abnormally with code %s\n"
343                          status))))
344           (insert string)))
345       (if (not (featurep 'xemacs))
346           (if compilation-scroll-output
347               (save-selected-window
348                 (if win
349                     (progn 
350                       (select-window win)
351                       (goto-char (point-max))))
352                 (sit-for 0)))))))
353
354
355
356 (defclass bsh ()
357   ((buffer        :initarg :buffer
358                   :type bsh-comint-buffer
359                   :documentation
360                   "Buffer used to interact with BeanShell process.")
361
362    
363    (eval-buffer   :initarg :eval-buffer
364                   :type (or null bsh-buffer)
365                   :initform nil
366                   :documentation
367                   "Buffer used to display evaluation result.")
368
369    (eval-filter   :initarg :eval-filter
370                   :type function
371                   :documentation
372                   "Function used to capture Lisp output from the BeanShell.")
373
374    (async-filter  :initarg :async-filter
375                   :type function
376                   :documentation
377                   "Function used to capture and evaluate BeanShell Lisp output.")
378
379    (redir-filter  :initarg :redir-filter
380                   :type function
381                   :documentation
382                   "Redirects BeanShell output to eval-buffer.")
383
384    (java-expr     :initarg :java-expr
385                   :initform ""
386                   :type string
387                   :documentation
388                   "Last Java expression evaluated in the BeanShell.")
389
390    (lisp-output   :initarg :lisp-output
391                   :initform ""
392                   :type string
393                   :documentation
394                   "Lisp output from the BeanShell.")
395
396
397    (vm            :initarg :vm
398                   :initform "java"
399                   :type string
400                   :documentation
401                   "Path of Java vm used to run the BeanShell.")
402
403    (vm-args       :initarg :vm-args
404                   :initform nil
405                   :type list
406                   :documentation
407                   "List of arguments to be passed to the Beanshell vm.")
408
409    (startup-dir   :initarg :startup-dir
410                   :initform ""
411                   :type string
412                   :documentation
413                   "Directory in which to start the BeanShell")
414
415    (cp            :initarg :cp
416                   :type list
417                   :documentation
418                   "Startup classpath for BeanShell")
419
420    (jar           :initarg :jar
421                   :initform "bsh.jar"
422                   :type string
423                   :documentation
424                   "Path of the BeanShell jar file.")
425
426    (class-name    :initarg :class-name
427                   :initform "bsh.Interpreter"
428                   :type string
429                   :documentation
430                   "Name of BeanShell class."))
431 "Defines an instance of a BeanShell process.")
432
433 (defmethod initialize-instance ((this bsh) &rest fields)
434   "Constructor for BeanShell instance."
435   
436   (call-next-method)
437
438   (bsh-create-buffer this)
439
440   (lexical-let ((this-bsh this))
441     ;; Filter for synchronous evaluations.
442     (oset
443      this eval-filter
444      (lambda (process output)
445        (with-current-buffer (process-buffer process)
446          (bsh-snag-lisp-output this-bsh process output))))
447
448     ;; Filter for asynchronous Java statement evaluations.
449     (oset
450      this async-filter
451      (lambda (process output)
452        (with-current-buffer (process-buffer process)
453          (bsh-snag-and-eval-lisp-output this-bsh process output))))
454
455     ;; Filter for redirecting result of evaluating an expression to the
456     ;; buffer specified by eval-buffer. This is typically used to
457     ;; redirect compiler like output to a compilation-mode buffer.
458     (oset
459      this redir-filter
460      (lambda (process output)
461        (with-current-buffer (process-buffer process)
462          (bsh-redirect-eval-output this-bsh process output))))))
463
464 (defmethod bsh-create-buffer ((this bsh))
465   "Creates the buffer used by this beanshell instance."
466     (oset this buffer (bsh-comint-buffer "bsh main buffer")))
467
468
469 (defmethod bsh-build-classpath-argument ((this bsh))
470   "Convert the list of classes specified by the cp slot
471 to the string form required by the vm."
472   (mapconcat 
473    'identity 
474    (append
475     (and (slot-boundp this 'cp) (oref this cp))
476     (list (oref this jar)))
477    path-separator))
478
479 (defmethod bsh-running-p ((this bsh))
480   "Return t if this instance of a BeanShell is running; otherwise nil"
481   (let* ((buffer (oref this buffer))
482          (process
483           (if (slot-boundp buffer  'process)
484               (oref buffer process))))      
485     (and
486      process
487      (processp process)
488      (eq (process-status process) 'run))))
489
490 (defmethod bsh-get-process ((this bsh))
491   "Return the Lisp object representing the Beanshell process."
492   (if (bsh-running-p this)
493       (oref (oref this buffer) process)))
494
495
496 (defmethod bsh-launch ((this bsh) &optional display-buffer)
497
498   (assert 
499    (or (file-exists-p (oref this vm))
500        (executable-find (oref this vm)))
501    nil "Specified vm does not exist: %s" (oref this vm))
502
503   (assert 
504    (file-exists-p (oref this jar))
505    nil 
506    "Specified BeanShell jar filed does not exist: %s" (oref this jar))
507
508
509   (if (not (bsh-running-p this))
510       (let*  ((dir
511                  (cond
512                   ((not (string= (oref this startup-dir) ""))
513                    (expand-file-name (oref this startup-dir)))
514                   ((buffer-file-name)
515                    (file-name-directory (buffer-file-name)))
516                   (t
517                    default-directory)))
518                 (vm-args (list "-classpath" (bsh-build-classpath-argument this)))
519                 (buffer 
520                  (let ((buf (oref this buffer)))
521                    (if (bsh-buffer-live-p buf)
522                        buf
523                      (bsh-create-buffer this))))
524                 (native-buff (oref buffer buffer)))
525                        
526           
527           (setq vm-args (append vm-args (oref this vm-args)))
528           (setq vm-args (append vm-args bsh-vm-args))
529           (setq vm-args (append vm-args (list (oref this class-name))))       
530
531           (with-current-buffer native-buff
532             (erase-buffer)
533
534             (cd dir)
535             (insert (concat "cd " dir "\n"))
536             (insert 
537              (concat (oref this vm) " "
538                      (mapconcat (lambda (x) x) vm-args " ") "\n\n"))
539
540             (setq bsh-the-bsh this))
541
542           (message "%s" "Starting the BeanShell. Please wait...")
543           (bsh-comint-buffer-exec buffer (oref this vm) vm-args)
544
545           (if display-buffer
546               (bsh-buffer-display buffer)))
547     (when display-buffer
548       (message "The BeanShell is already running.")
549       (bsh-buffer-display (oref this buffer)))))
550
551 (defvar bsh-the-bsh nil
552   "The BeanShell instance associated with the current BeanShell buffer.")
553 (make-variable-buffer-local 'bsh-the-bsh)
554
555
556 (defmethod bsh-snag-lisp-output ((this bsh) process output)
557   "Assemble Lisp OUTPUT from the BeanShell." 
558     (let ((end-of-output (string-match ".*bsh % " output)))
559       ;; Check for case
560       ;;   %bsh\n...eval output...%bsh\n
561       ;; This can happen because the beanshell outputs two or more
562       ;; prompts after evaluating some expressions.
563       ;; Thanks to Stephane Nicolas.
564       ;; (if (eq end-of-result 0)
565       ;; (accept-process-output process 0 5))
566       (if end-of-output
567         (oset 
568          this
569          lisp-output 
570          (concat (oref this lisp-output) (substring output 0 end-of-output)))
571         (oset this lisp-output (concat (oref this lisp-output) output))
572         (accept-process-output process bsh-eval-timeout 5))))
573
574 (defmethod bsh-detect-java-eval-error ((this bsh) bsh-output)
575   (if (string-match "// Error:" bsh-output)
576       (progn
577         (message 
578          "Beanshell expression evaluation error.\n  Expression: %s\n  Error: %s"
579          (oref this java-expr) bsh-output)
580         (error "Beanshell eval error. See messages buffer for details."))))
581
582
583 (defmethod bsh-eval-lisp-output ((this bsh))
584   (if (not (string= (oref this lisp-output) ""))
585       (flet ((format-error-msg (error-symbols)
586                (mapconcat (lambda (s) (symbol-name s)) error-symbols " ")))
587         (condition-case eval-error
588             (eval (read (oref this lisp-output)))
589           (error
590             (message "Error evaluating Lisp result of Java expression evaluation.")
591             (message "  Java expression: %s." (oref this java-expr))
592             (message "  Java evaluation result: %s." (oref this lisp-output))
593             ;; The following causes an unreadable object error on XEmacs when
594             ;; trying to load the byte-compiled file:
595             ;;
596             ;; (message "  Error from evaluating result as Lisp: %s"
597             ;;    (mapconcat (lambda (s) (symbol-name s)) eval-error " ")
598             (message "  Error from evaluating result as Lisp: %s"
599                      (format-error-msg eval-error))
600             (error "Error evaluating Java expresson. See *Messages* buffer."))))
601     (progn
602       (message "bsh-eval-r error: Beanshell result is null. Cannot evaluate.")
603       (message "  Expression: %s" (oref this java-expr)))))
604
605 (defmethod bsh-snag-and-eval-lisp-output ((this bsh) process output)
606   "Assemble and parse Lisp OUTPUT from the BeanShell PROCESS." 
607   (bsh-snag-lisp-output this process output)
608   (bsh-detect-java-eval-error this output)
609   (bsh-eval-lisp-output this))
610
611
612 (defmethod bsh-redirect-eval-output ((this bsh) process output)
613   (let ((eval-buffer (oref this eval-buffer)))
614     (assert eval-buffer)
615     (funcall (oref eval-buffer filter) process output)
616     ;; Restore the Beanshell's standard output filter when
617     ;; the Beanshell prompt reappears.
618     (if (string-match ".*bsh % " output)
619        (progn
620         (set-process-filter process (oref (oref this buffer) filter))
621          (oset this eval-buffer nil)))))
622
623 (defmethod bsh-eval ((this bsh) expr &optional eval-return)
624   "Uses the BeanShell Java interpreter to evaluate the Java expression
625 EXPR.  This function returns any text output by the Java interpreter's
626 standard out or standard error pipes.  If EVAL-RETURN is non-nil, this
627 function returns the result of evaluating the Java output as a Lisp
628 expression."
629   
630   (unless (bsh-running-p this)
631     (bsh-launch this))
632     
633   (when (bsh-running-p this)
634     (oset this java-expr expr)
635     (oset this lisp-output "")
636     (set-process-filter (oref (oref this buffer) process) (oref this eval-filter))
637     ;; (message "Evaluating: %s" expr)
638     (process-send-string (oref (oref this buffer) process) (concat expr "\n"))
639
640     (if (not (accept-process-output (oref (oref this buffer) process) bsh-eval-timeout))
641         (progn 
642           (set-process-filter (oref (oref this buffer) process) (oref (oref this buffer) filter))
643           (error "No reply from BeanShell")))
644       
645     (set-process-filter (oref (oref this buffer) process) (oref (oref this buffer) filter))
646
647     (bsh-detect-java-eval-error this (oref this lisp-output))
648     ;; (if eval-return (message "Evaluating reply: %s" (oref this lisp-output)))
649     (if eval-return
650         (bsh-eval-lisp-output this)
651       (oref this lisp-output))))
652
653 (defmethod bsh-eval-r ((this bsh) java-statement) 
654   "Convenience method for evaluating Java statements
655 that return Lisp expressions as output. This function 
656 invokes bsh-eval with the evaluate-return option set to
657 t."
658   (bsh-eval this java-statement t))
659
660 (defmethod bsh-async-eval ((this bsh) expr)
661   "Send the Java statement EXPR to the BeanShell for 
662 evaluation. Do not wait for a response."
663   (unless (bsh-running-p this)
664     (bsh-launch this))
665    
666   (oset this lisp-output "")
667   (oset this java-expr expr)
668   (set-process-filter (oref (oref this buffer) process) (oref this async-filter))
669
670   (when (bsh-running-p this)
671     (process-send-string (oref (oref this buffer) process) (concat expr "\n"))))
672
673 (defmethod bsh-buffer-eval ((this bsh) expr buffer)
674   "Evaluate EXPR and displays its output in BUFFER. BUFFER
675 must be an instance of `bsh-buffer' class. A typical use for this
676 method is to invoke a Java application whose output is compiler-like,
677 e.g., javac, ant, or checkstyle. In this case, BUFFER would be 
678 an instance of a subclass of `bsh-compiler-buffer'."
679   (assert (typep expr 'string))
680   (assert (typep buffer 'bsh-buffer))
681   (unless (bsh-running-p this)
682     (bsh-launch this))
683   (let* ((comint-buffer (oref this buffer))
684          (bsh-process (oref comint-buffer process)))
685     (oset this eval-buffer buffer)
686     (set-process-filter bsh-process (oref this redir-filter))
687     (process-send-string bsh-process expr)))
688
689 (defmethod bsh-kill-process ((this bsh))
690   "Terminates the BeanShell process."
691   (process-send-string  (oref (oref this buffer) process) "exit();\n"))
692
693 (defun get-bsh(buffer-name) 
694   "Get the `bsh' object associated
695 with the buffer named BUFFER-NAME."
696   (let (bsh-object
697         (buffer (get-buffer buffer-name)))
698     (if buffer
699         (save-excursion
700           (set-buffer buffer)
701           (setq bsh-object bsh-the-bsh)))
702     bsh-object))
703
704
705 (defun bsh-demo-eval ()
706   "This command demonstrates use of the BeanShell to 
707 execute Java code. It assumes that 
708 `bsh-jar' points to the location of the BeanShell
709 jar file on your system and that either `exec-path'
710 or `bsh-vm' point to a Java vm on your system."
711    (interactive)
712
713    (assert 
714     (file-exists-p (expand-file-name bsh-jar))
715     nil
716     (concat 
717      "Cannot find the BeanShell jar file at "
718      (expand-file-name bsh-jar)
719      ". Type C-h bsh-jar for more info."))
720
721    (if bsh-vm
722        (assert 
723         (or 
724          (executable-find bsh-vm)
725          (file-exists-p bsh-vm))
726         nil
727         "The vm specified by bsh-vm does not exist: %s." bsh-vm)
728      (assert
729       (executable-find (if (eq system-type 'windows-nt) "javaw" "java"))
730       nil
731       "Cannot find a Java vm on exec-path."))
732
733    
734    (let ((beanshell  (get-bsh "*bsh demo*"))
735          (demo-script
736           (concat
737            "demo() {" 
738              "name = JOptionPane.showInputDialog(\"Enter your name.\");"
739              "print(\"(message \\\"Your name is \" + name + \"\\\")\");" 
740            "};")
741          ))
742
743      (if (not beanshell)
744          (progn
745            
746            ;; Create a BeanShell wrapper object
747            (setq beanshell (bsh "BeanShell"))
748
749            (oset (oref beanshell buffer) buffer-name "*bsh demo*")
750
751            ;; Set the wrapper's jar slot (eieio/CLOS speak for field) to
752            ;; point to the location of the BeanShell on the user's
753            ;; system.
754            (oset beanshell jar (expand-file-name bsh-jar))
755
756            ;; Set the wrapper's vm slot to point to the location
757            ;; of a vm on the user's system. The wrapper's launch
758            ;; method (see below) uses the specified vm to launch
759            ;; the BeanShell.
760            (oset 
761             beanshell
762             vm
763             (if bsh-vm
764                 (or
765                  (executable-find bsh-vm)
766                  bsh-vm)
767               (executable-find (if (eq system-type 'windows-nt) "javaw" "java"))))))
768
769      (unless (bsh-running-p beanshell)
770        (bsh-launch beanshell)
771        (bsh-async-eval beanshell demo-script))
772      (bsh-async-eval beanshell "demo();")))
773
774
775
776 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
777 ;;; Standalone BeanShell                                                      ;;
778 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
779
780 (defclass bsh-standalone-bsh (bsh)
781   ((the-bsh        :type bsh-standalone-bsh
782                    :allocation :class
783                    :documentation
784                    "The single instance of the standalone BeanShell."))
785   "BeanShell intended to be used independently of any other 
786 Emacs package.")
787
788 (defmethod initialize-instance ((this bsh-standalone-bsh) &rest fields)
789   "Constructor for the standard bsh BeanShell instance."
790   (call-next-method)
791
792   (assert 
793    (file-exists-p (expand-file-name bsh-jar))
794    nil
795    (concat 
796     "Cannot find the BeanShell jar file at "
797     (expand-file-name bsh-jar)
798     ". Type C-h bsh-jar for more info."))
799
800    (if bsh-vm
801        (assert 
802         (or 
803          (executable-find bsh-vm)
804          (file-exists-p bsh-vm))
805         nil
806         "The vm specified by bsh-vm does not exist: %s." bsh-vm)
807      (assert
808       (executable-find (if (eq system-type 'windows-nt) "javaw" "java"))
809       nil
810       "Cannot find a Java vm on exec-path."))
811
812
813   (oset this jar (expand-file-name bsh-jar))
814
815   (oset 
816    this 
817    vm
818    (if bsh-vm
819        (or
820         (executable-find bsh-vm)
821         bsh-vm)
822      (executable-find (if (eq system-type 'windows-nt) "javaw" "java"))))
823
824   (oset this cp bsh-classpath)
825
826   (oset this startup-dir bsh-startup-directory))
827
828
829 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
830 ;;; Beanshell commands                                                        ;;
831 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
832
833 (defun bsh-run()
834   "*Starts the standalone version of the BeanShell, a Java interpreter developed 
835 by Pat Niemeyer."
836   (interactive)
837   (oset-default 'bsh-standalone-bsh the-bsh (bsh-standalone-bsh "Standalone BeanShell"))
838   (bsh-launch (oref bsh-standalone-bsh the-bsh) t))
839
840 (defun bsh-exit ()
841   "Closes the standalone version of the BeanShell."
842   (interactive)
843   (let ((bsh  
844          (if (slot-boundp 'bsh-standalone-bsh 'the-bsh)
845              (oref 'bsh-standalone-bsh the-bsh))))
846     (if (and bsh (bsh-running-p bsh))
847         (bsh-kill-process bsh)
848       (message "The beanshell is not running"))))
849
850
851 (defun bsh-find-bsh-data-directory ()
852   "Return the path of the bsh data directory.
853 Returns the path of the directory containing the documentation directory;  nil if the 
854 directory cannot be found. If XEmacs, returns the location of
855 the data directory in the XEmacs distribution hierarchy. On all other Emacs versions, 
856 the bsh expects to find the documentation 
857 in the same directory that contains the bsh.el file."
858   (let ((directory-sep-char ?/)
859         dir)
860     (flet ((find-data-dir 
861             ()
862             (expand-file-name 
863              "../" 
864              (file-name-directory (locate-library "beanshell")))))
865       (if (featurep 'xemacs)
866           (progn
867             (setq dir (locate-data-directory "beanshell"))
868             (if (not dir)
869                 (setq dir (find-data-dir))))
870         (setq dir (find-data-dir))))
871       dir))
872
873
874 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
875 ;;; Beanshell mode                                            ;;  
876 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
877
878 (define-derived-mode
879   bsh-script-mode java-mode "bsh script"
880   "Major mode for developing Beanshell scripts.
881   \\(bsh-script-mode-map)"
882
883   (set (make-local-variable 'font-lock-defaults)
884        (if (featurep 'xemacs)
885            (get 'java-mode 'font-lock-defaults)
886          (cdr (assq 'java-mode font-lock-defaults))))
887   (set (make-local-variable 'font-lock-maximum-decoration) t)
888   (set (make-local-variable 'font-lock-multiline) t)
889   (turn-on-font-lock))
890
891 (add-to-list 'auto-mode-alist '("\\.bsh\\'" . bsh-script-mode))
892
893 ;;;###autoload
894 (defun bsh-script-help ()
895   "Display BeanShell User's Guide."
896   (interactive)
897   (let* ((bsh-dir (bsh-find-bsh-data-directory))
898          (bsh-help
899           (if bsh-dir
900               (expand-file-name "bsh-ug.html" bsh-dir))))      
901     (if (and
902          bsh-help
903          (file-exists-p bsh-help))
904         (browse-url (concat "file://" bsh-help)
905                     (if (boundp 'browse-url-new-window-flag)
906                         'browse-url-new-window-flag
907                       browse-url-new-window-p))
908       (signal 'error '("Cannot find BeanShell help file.")))))
909
910 (defcustom bsh-script-menu-definition
911   (list "Bsh"
912         ["Help" bsh-script-help t])
913   "Definition of menu for BeanShell script buffers."
914   :group 'bsh
915   :type 'sexp
916   :set '(lambda (sym val)
917           (set-default sym val)
918           ; Define Bsh script menu for FSF Emacs.
919           (if (or (not (featurep 'xemacs)) 
920                   (featurep 'infodock))
921               (easy-menu-define bsh-script-menu 
922                                 bsh-script-mode-map
923                                 "Menu for BeanShell Script Buffer."
924                                 val))
925           (if (and (featurep 'xemacs) 
926                    (eq major-mode 'bsh-script-mode))
927               (bsh-script-insert-menu-in-xemacs-menubar))))
928
929 (defun bsh-script-insert-menu-in-xemacs-menubar ()
930   "Insert BeanShell script menu in the XEmacs menu bar."
931   (if (and 
932        (not (featurep 'infodock))
933        (not (memq 'infodock c-emacs-features))
934        (boundp 'current-menubar)
935        current-menubar)
936       (if (fboundp 'add-submenu)
937           (add-submenu nil bsh-script-menu-definition)
938         (add-menu nil "Bsh" (cdr bsh-script-menu-definition)))))
939
940   
941
942 (provide 'beanshell)
943
944 ;; $Log: beanshell.el,v $
945 ;; Revision 1.76  2005/01/23 00:02:39  jslopez
946 ;; Set buffer-read-only to nil after invoking compilation-mode, which sets it to t
947 ;; in latest version of Emacs.
948 ;;
949 ;; Revision 1.75  2004/12/22 04:20:14  paulk
950 ;; Fix bsh-exit to handle case where the standalone beanshell is not running.
951 ;;
952 ;; Revision 1.74  2004/10/14 04:32:43  paulk
953 ;; Set process-connection-type to nil (always uses pipes for process I/O)
954 ;; when starting a beanshell comint buffer. This change is intended to
955 ;; avoid code 129 errors that occur on some versions of Linux.
956 ;;
957 ;; Revision 1.73  2004/06/06 04:31:08  paulk
958 ;; Fixed reference to obsolete font-lock variable.
959 ;;
960 ;; Revision 1.72  2004/06/03 02:54:43  paulk
961 ;; Remove unnecessary format clauses in assert forms.
962 ;;
963 ;; Revision 1.71  2004/05/04 03:59:23  paulk
964 ;; Eliminate optional argument to compilation-mode to ensure compatiblity with next release of Emacs.
965 ;;
966 ;; Revision 1.70  2004/04/30 02:38:16  paulk
967 ;; Makes beanshell not depend on compilation- variables being defined.
968 ;;
969 ;; Revision 1.69  2004/03/21 15:05:02  paulk
970 ;; The beanshell redirect filter now restores the standard filter only when the Beanshell prompt reappears. This ensures that the redirect filter redirects the entire output of the previous Beanshell expression evaluation. Thanks to J\81örg Mensmann.
971 ;;
972 ;; Revision 1.68  2003/06/30 03:52:39  paulk
973 ;; Include bsh-vm-args in the command line that starts the BeanShell, thus fixing a
974 ;; regression error reported by TAKAHASHI Toru.
975 ;;
976 ;; Revision 1.67  2003/06/22 16:06:43  paulk
977 ;; Fix "unreadable object" error when XEmacs tries to load beanshell.elc.
978 ;;
979 ;; Revision 1.66  2003/05/07 04:29:37  paulk
980 ;; Include Lisp error in messages buffer when a Lisp error results from evaluating the result of a Java evaluation as Lisp.
981 ;;
982 ;; Revision 1.65  2003/04/16 04:13:18  paulk
983 ;; Added a require statement for the comint package. This is not necessary for use with the JDEE, which already requires comint, but may be necessary when beanshell.el is used independently of the JDEE.
984 ;;
985 ;; Revision 1.64  2003/04/11 22:51:33  jslopez
986 ;; Fixes typo, orer to oref.
987 ;;
988 ;; Revision 1.63  2003/04/08 03:14:07  paulk
989 ;; Fixes bug that caused the working directory of the compilation buffer to be set incorrectly. Also add methods to bsh-compilation-buffer class that simplify subclassing.
990 ;;
991 ;; Revision 1.62  2003/04/06 07:32:25  paulk
992 ;; Fixed bugs caused by not handling the case when the user has killed a
993 ;; Beanshell buffer. Also added a bsh-create-buffer method to allow
994 ;; derived classes to override the type of buffer used to interact
995 ;; with the BeanShell.
996 ;;
997 ;; Revision 1.61  2003/03/04 10:10:40  paulk
998 ;; Made the following changes to provide generalized support
999 ;; for displaying BeanShell output in a compilation-mode buffer.
1000 ;;
1001 ;; - Defined a new eieio class hierarchy that wraps Emacs buffers.
1002 ;;   The hierarchy contains three classes: bsh-buffer, the base,
1003 ;;   and bsh-comint-buffer and bsh-compilation-buffer class, which
1004 ;;   wrap comint-mode and compilation-mode buffers, respectively.
1005 ;;
1006 ;; - Added a bsh-buffer-eval method to the bsh class that displays
1007 ;;   the results of evaluating a Java expression in a specified
1008 ;;   bsh-buffer.
1009 ;;
1010 ;; Revision 1.60  2003/02/17 08:09:29  paulk
1011 ;; Refactors beanshell.el so that it supports but does not require the
1012 ;; JDEE. This allows beanshell.el to be used to support other Emacs
1013 ;; applications that want to use Java as an extension language. See
1014 ;; the package commentary for more information.
1015 ;;
1016 ;; Revision 1.59  2003/02/15 20:56:53  nsieger
1017 ;; (bsh-eval): Add second optional IGNORE-EMPTY parameter which
1018 ;; suppresses errors if evaluation produces no forms.  Part of initial
1019 ;; JUCI checkin, which necessitated this feature.
1020 ;;
1021 ;; Revision 1.58  2003/01/27 06:38:49  paulk
1022 ;; Moved error-handling for when jde-get-tools-jar returns a nil value into
1023 ;; jde-get-tools-jar itself.
1024 ;;
1025 ;; Revision 1.57  2003/01/20 04:43:47  paulk
1026 ;; Slightly expanded error message for not being able to find the JDK tools jar file.
1027 ;;
1028 ;; Revision 1.56  2003/01/09 18:21:14  ahyatt
1029 ;; Beanshell should be started with an expanded classpath
1030 ;;
1031 ;; Revision 1.55  2003/01/03 16:35:24  jslopez
1032 ;; Fixes bug that was not adding the ant jar files to the beanshell classpath
1033 ;; when jde-ant-home is not bound. This could happen because the jde-ant
1034 ;; package has not been loaded.
1035 ;;
1036 ;; Revision 1.54  2002/12/30 05:09:00  paulk
1037 ;; Define bsh-script-mode for editing BeanShell scripts.
1038 ;;
1039 ;; Revision 1.53  2002/12/14 03:54:09  jslopez
1040 ;; Adds all the jar files in the ant/lib directory to the beanshell classpath.
1041 ;;
1042 ;; Revision 1.52  2002/12/06 03:47:37  ahyatt
1043 ;; Changes to support Mac OS X, which does not use tools.jar
1044 ;;
1045 ;; Revision 1.51  2002/11/14 06:03:34  paulk
1046 ;; Fix regression bug in bsh-exit caused by deferring loading of ant package until used.
1047 ;;
1048 ;; Revision 1.50  2002/10/31 05:19:34  paulk
1049 ;; Applied compatibility fix for Mac OS X. Thanks to Andi Vajda <avajda@nanospace.com>.
1050 ;;
1051 ;; Revision 1.49  2002/10/22 04:41:19  paulk
1052 ;; Checks whether jde-ant-home is bound. This is necessary because jde-ant is now autoloaded and hence jde-ant-home is not bound until the user executes an ant command.
1053 ;;
1054 ;; Revision 1.48  2002/09/16 05:05:59  paulk
1055 ;; Cygwin Emacs compatibility fix. Check for Cygwin Emacs when processing paths. Thanks
1056 ;; to Klaus Berndl.
1057 ;;
1058 ;; Revision 1.47  2002/09/11 03:32:56  paulk
1059 ;; If jde-devel-debug is true, the BeanShell now uses the JDEE classes
1060 ;; in the jde/java/classes directory instead of those in the
1061 ;; jde/java/lib/jde.jar file. This simplifies testing changes
1062 ;; to the JDEE classes.
1063 ;;
1064 ;; Revision 1.46  2002/09/10 04:44:31  paulk
1065 ;; The JDEE now waits for the BeanShell startup message
1066 ;; on Windows. Previously, it returned possibly creating
1067 ;; subtle timing bugs.
1068 ;;
1069 ;; - Paul
1070 ;;
1071 ;; Revision 1.45  2002/08/27 05:03:30  paulk
1072 ;; Put the JDEE libraries ahead of jde-global-classpath in the beanshell classpath to ensure that the
1073 ;; JDEE versions of these libraries are loaded and not other versions that the user may have installed
1074 ;; in their classpath. Thanks to Andy Piper.
1075 ;;
1076 ;; Revision 1.44  2002/06/22 05:52:18  paulk
1077 ;; Fixed minor compilation error.
1078 ;;
1079 ;; Revision 1.43  2002/06/18 06:02:51  paulk
1080 ;; XEmacs compatibility fix: allow user to set bsh-startup-timeout
1081 ;; and bsh-eval-timeout to floating point values and to nil
1082 ;; (no timeout) to accommodate an apparent bug in the way
1083 ;; accept-process-output works on the Windows version of XEmacs.
1084 ;;
1085 ;; Revision 1.42  2002/06/12 07:04:31  paulk
1086 ;; XEmacs compatibility fix: set win32-quote-process-args wherever
1087 ;; the JDEE sets w32-quote-process-args. This allows use of spaces in
1088 ;; paths passed as arguments to processes (e.g., javac)  started by
1089 ;; the JDEE.
1090 ;;
1091 ;; Revision 1.41  2002/06/11 06:30:37  paulk
1092 ;; Provides support for paths containing spaces as beanshell vm arguments via the following change:
1093 ;; locally set the w32-quote-process-args variable to a quotation mark when launching
1094 ;; the beanshell vm process.
1095 ;;
1096 ;; Revision 1.40  2002/02/26 04:35:27  paulk
1097 ;; * Fixes regression bug that calls bsh-eval to fail when ant-home is nil.
1098 ;; * Adds a new eieo class, bsh-compiler, intended to serve as a base class
1099 ;;   for compiler-like tools (e.g., javac, ant, checkstyle) based on
1100 ;;   the beanshell.
1101 ;;
1102 ;; Revision 1.39  2002/02/25 20:07:38  jslopez
1103 ;; Remove no buffering filter.
1104 ;; Add get-process method.
1105 ;;
1106 ;; Revision 1.38  2002/02/21 12:42:33  jslopez
1107 ;; Fixes bug adding incorrect path for ant.jar in
1108 ;; the beanshell classpath.
1109 ;;
1110 ;; Revision 1.37  2002/02/15 17:50:46  jslopez
1111 ;; Removes reference to bsh-eval-comint-filter.
1112 ;; Switch the order of the sit-for and the accept-process-output.
1113 ;;
1114 ;; Revision 1.36  2002/02/15 02:48:20  jslopez
1115 ;; Adds a new non buffering filter, this filter is meant to be used
1116 ;; by the compile server and the ant server.
1117 ;; Modifies bsh-eval to support a new filter.
1118 ;;
1119 ;; Revision 1.35  2001/12/09 17:17:48  jslopez
1120 ;; Replaces repetitive code with jde-get-global-classpath.
1121 ;;
1122 ;; Revision 1.34  2001/11/05 14:18:32  jslopez
1123 ;; Modifies bsh-exit to use two different exit methods.
1124 ;; If Ant Server is enable it uses JdeUtilities.exit()
1125 ;; otherwise it uses the beanshell exit() method.
1126 ;;
1127 ;; Revision 1.33  2001/11/05 02:13:59  jslopez
1128 ;; Modified bsh-exit to class jde.util.JdeUtilities.exit() instead
1129 ;; of using the beanshell exit method.
1130 ;;
1131 ;; Revision 1.32  2001/10/24 05:27:56  paulk
1132 ;; Updated bsh-internal to use jde-run-get-vm (instead of the obsolete
1133 ;; jde-run-java-vm) to get the path to the vm to run the Beanshell.
1134 ;;
1135 ;; Revision 1.31  2001/10/19 09:47:55  paulk
1136 ;; XEmacs compatibility fix: Now correctly converts new lines (^M) on Windows.
1137 ;; Thanks to Andy Piper.
1138 ;;
1139 ;; Revision 1.30  2001/09/05 06:18:05  paulk
1140 ;; bsh-internal now uses jde-get-jdk-directory to determine the JDK directory.
1141 ;;
1142 ;; Revision 1.29  2001/08/30 04:15:06  paulk
1143 ;; Beanshell now uses jde-jdk-directory instead of jde-bug-jdk-directory (soon to be deprecated) to find the JDK tools.jar file.
1144 ;;
1145 ;; Revision 1.28  2001/08/30 01:34:47  paulk
1146 ;; Adds JDK tools.jar file to beanshell classpath. Needed to support compile server. Thanks to Javier Lopez.
1147 ;;
1148 ;; Revision 1.27  2001/08/14 06:11:35  paulk
1149 ;; Add bsh-exit, bsh-open-class-browser, and bsh-open-desktop. Thanks to Javier Lopez.
1150 ;;
1151 ;; Revision 1.26  2001/07/31 05:11:48  paulk
1152 ;; ReleaseNotes.txt
1153 ;;
1154 ;; Revision 1.25  2001/06/13 03:51:44  paulk
1155 ;; Now defines bsh customization group.
1156 ;;
1157 ;; Revision 1.24  2001/05/31 05:14:38  paulk
1158 ;; Provide support for per-project caching of class data in the Beanshell. Thanks to Matt Conway.
1159 ;;
1160 ;; Revision 1.23  2001/05/19 02:39:18  paulk
1161 ;; Put jde-global-classpath first on the classpath to facilitate debugging of Java code run in hthe Beanshell.
1162 ;;
1163 ;; Revision 1.22  2001/04/16 05:33:20  paulk
1164 ;; Normalized paths. Thanks to Nick Sieger.
1165 ;;
1166 ;; Revision 1.21  2001/03/21 20:46:34  paulk
1167 ;; Updated bsh-internal to handle case where both jde-global-classpath and CLASSPATH environment variable are nil. Thanks to Toru TAKAHASHI <torutk@alles.or.jp> for reporting this bug and supply an initial version of a fix.
1168 ;;
1169 ;; Revision 1.20  2001/03/01 05:01:28  paulk
1170 ;; Adds the customization variable bsh-startup-directory.
1171 ;;
1172 ;; Revision 1.19  2001/02/25 04:23:12  paulk
1173 ;; Fixed bug in processing CLASSPATH environment variable.
1174 ;;
1175 ;; Revision 1.18  2001/02/03 07:44:26  paulk
1176 ;; Now uses jde-build-classpath to build BeanShell classpath. This allows enviromnent variables in the classpath.
1177 ;;
1178 ;; Revision 1.17  2000/10/08 12:55:38  paulk
1179 ;; *** empty log message ***
1180 ;;
1181 ;; Revision 1.16  2000/08/10 09:09:47  paulk
1182 ;; Now handles Lisp eval errors gracefully.
1183 ;;
1184 ;; Revision 1.15  2000/08/07 05:11:38  paulk
1185 ;; Adds bsh-vm-args variable.
1186 ;;
1187 ;; Revision 1.14  2000/08/04 02:51:19  paulk
1188 ;; Added bsh-eval-timeout variable.
1189 ;;
1190 ;; Revision 1.13  2000/02/16 04:39:28  paulk
1191 ;; Implemented Cygwin/XEmacs compatiblity fix provided by Fred Hart
1192 ;; <cfhart@Z-TEL.com> in bsh-internal.
1193 ;;
1194 ;; Revision 1.12  2000/02/02 05:51:00  paulk
1195 ;; Expanded doc string.
1196 ;;
1197 ;; Revision 1.11  2000/01/28 04:28:00  paulk
1198 ;; Fixed startup timing bug that cause commands that use the beanshell to
1199 ;; failt the first time on Unix systems.
1200 ;;
1201 ;; Revision 1.10  2000/01/15 08:00:03  paulk
1202 ;; Corrected typo.
1203 ;;
1204 ;; Revision 1.9  1999/11/01 03:13:07  paulk
1205 ;; No change.
1206 ;;
1207 ;; Revision 1.8  1999/09/17 06:55:26  paulk
1208 ;; Set comint-prompt-regexp to the beanshell prompt.
1209 ;; Fixed bug where Emacs was querying user whether to kill the beanshell
1210 ;; buffer on exit from Emacs.
1211 ;;
1212 ;; Revision 1.7  1999/01/15 22:18:41  paulk
1213 ;; Added Andy Piper's NT/XEmacs compatibility changes.
1214 ;;
1215 ;; Revision 1.6  1998/12/13 22:10:04  paulk
1216 ;; Add check for chunked traffic between Emacs and the BeanShell.
1217 ;;
1218 ;; Revision 1.5  1998/12/09 00:59:43  paulk
1219 ;; Added a startup message for beanshell.
1220 ;;
1221 ;; Revision 1.4  1998/11/27 10:07:57  paulk
1222 ;; Use CLASSPATH environment variable if jde-global-classpath is nil.
1223 ;;
1224 ;; Revision 1.3  1998/11/22 23:14:28  paulk
1225 ;; Fixed path separator bug.
1226 ;;
1227 ;; Revision 1.2  1998/11/22 18:11:56  paulk
1228 ;; Changed path to use jde.jar.
1229 ;;
1230 ;; Revision 1.1  1998/10/22 00:07:56  paulk
1231 ;; Initial revision
1232 ;;
1233
1234
1235 ;; End of beanshell.el