Paul Kinnucan <[EMAIL PROTECTED]> writes:

> At 12:00 PM 4/25/00 -0700, you wrote:
> >
> >Try 
> >
> >(setq jde-global-classpath (getenv "CLASSPATH"))
> >
> 
> Won't work. You MUST use customize to set JDE veriables. This is documented
> in the user's guide and has been discussed many times on this list. See the
> list archive.

I hate to disagree with Paul.  It makes me think I'm doing something
wrong.  But I think you can set your jde-global-claspath from the
$CLASSPATH variable.

I have a particularly ugly classpath need, and I use a shell script to
set it.  I'm attaching an excerpt from my .emacs which accomplishes
this.  It may not be pretty, I'm not a lisp expert.  If anything about
it is pretty, its only because I copied it from the jde source.  What
I have works well for me.  I find that occasionally, for reasons
unknown, my classpath will be forgotten by jde.  It might have
something to do with project files when I load files from other
projects.  At any rate, when that happens, I find that simply type M-x
jde-mode will refresh the classpath properly.  This does not happen
often.

Below is the section of my .emacs which runs my script
/bin/wmClasspath.sh, and sets the jde-global-classpath accordingly.
The script simply echoes the classpath.  My hook also prepends the
value of $CLASSPATH to the output of that script.  It would not take
much modification to have it work only with $CLASSPATH (and leave out
my script).

I use windows NT, and cygwin bash for a shell, and I'm not using the
very latest jde (yet).  Your mileage may vary.

-Dave

;; begin .emacs exerpt

;; Java Development environment
;; first make sure java environment is set up for jde
(add-to-list 'load-path "d:/dinstall/emacs/jde-2.1.6beta18/lisp")
(require 'jde)
(setq jde-bug-jdpa-directory "d:/dinstall/jdpa-1.0")

(defun dc-get-wm-classpath ()
  (shell-command "/bin/wmClasspath.sh" "*wmClasspath*")
  (save-excursion
    (set-buffer "*wmClasspath*")
    (buffer-string)
    )
  )

(defun dc-jde-path-string-to-list (paths)
 "Converts a string of paths to a list of paths.
It is assumed that the default path separator for the
current platform (e.g., semicolon on Win32) separates
the paths.  this function modified by dc to only include a path if it isn't there 
already.  Otherwise copied from jde
"
 (let ((path-list (list))
       (m 0)
       (n (string-match jde-classpath-separator paths)))
   (while n
     (let ((path (w32-long-file-name (substring paths m n))))
       (if path
           (add-to-list 'path-list path))
       (setq m (+ n 1))
       (setq n (string-match jde-classpath-separator paths m))))
   (setq n (length paths))
   (if (and (> n 0) (< m n))
       (let ((path (w32-long-file-name (substring paths m n))))
         (if path
             (add-to-list 'path-list path))))
   (setq path-list (nreverse path-list))
   ))

(defun dc-append-path-string-to-list (path-list paths)
 "Converts a string of paths to a list of paths.
It is assumed that the default path separator for the
current platform (e.g., semicolon on Win32) separates
the paths.  this function modified by dc to only include a path if it isn't there 
already.  Otherwise copied from jde
"
 (let ((m 0)
       (n (string-match jde-classpath-separator paths)))
   (while n
     (let ((path (w32-long-file-name (substring paths m n))))
       (if path
           (if (file-accessible-directory-p path)
               (add-to-list 'path-list (concat path "/"))
             (add-to-list 'path-list path)))
       (setq m (+ n 1))
       (setq n (string-match jde-classpath-separator paths m))))
   (setq n (length paths))
   (if (and (> n 0) (< m n))
       (let ((path (w32-long-file-name (substring paths m n))))
         (if path
             (if (file-accessible-directory-p path)
                 (add-to-list 'path-list (concat path "/"))
               (add-to-list 'path-list path)))
         (setq path-list (nreverse path-list))
         ))))

(defun dc-initialize-jde-global-classpath ()
  (setq jde-global-classpath
        (dc-append-path-string-to-list jde-global-classpath
         (concat (getenv "CLASSPATH") ";" (dc-get-wm-classpath) ";.")
         )))
  
(defun dc-initialize-jde-global-classpath-old ()
  ;; if classpath not already set, use $CLASSPATH
  (if jde-global-classpath ;; != nil
      ;; then
      (message "classpath already set to %S" jde-global-classpath)
    ;; else
    (setq jde-global-classpath
          (dc-jde-path-string-to-list
           (concat (getenv "CLASSPATH") ";" (dc-get-wm-classpath))
           ))
    );; endif
  )  

;; (setq jde-global-classpath nil)

;; my attempts to make jde customization easier
(defun dc-jde-mode-hook ()
  (message "my-jde-mode-hook...")
  (dc-initialize-jde-global-classpath)
  (setq jde-db-source-directories jde-global-classpath)
  (message "global classpath is now %S" jde-global-classpath)
  ;; (turn-on-auto-fill)
  (local-set-key [C-tab] 'dabbrev-expand)
  (set (make-local-variable 'dabbrev-case-fold-search) nil)
  (set (make-local-variable 'dabbrev-case-replace) nil)
  (setq tab-width 4)
  (setq c-basic-offset 4)
  (setq compilation-window-height 10)
  (message "end dc-jde-mode-hook")
  )
(add-hook 'jde-mode-hook 'dc-jde-mode-hook)

;; end .emacs excerpt

> 
> Unfortunately, customize expects a list of strings for jde-global-classpath
> so you can't set it to a lisp for via customize.
> 
> In any event, if your aim is to use the CLASSPATH environment variable,
> just customize jde-global-classpath to nil. If jde-global-classpath is
> nil,the JDE does not pass -classpath to the vm or javac and so the vm or
> javac use the setting of the CLASSPATH variable.
> 
> - Paul
> 
> ------------------------------------------------------------
> TECH SUPPORT POLICY
> 
> I respond only to requests that contain a complete problem report. The
> easiest way to ensure that your report is complete is to include the output
> of the JDE->Help->Submit Problem Report command in your request. 
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> JDE website: http://sunsite.auc.dk/jde/
> 
> JDE mailing list archive: 
> http://www.mail-archive.com/[email protected]/maillist.html

Reply via email to