Christophe writes:
> I have made a couple of modification to jdee to have the capability to
> open source file directly from jar file (if jar file is specified in
> jde-sourcepath)
>
> this modification are based on code found in arc-mode.
>
> I have modified the function "jde-find-class-source-file"
> and re-write the function "jde-search-src-dirs"
>
> Maybe it is possible to add this modification to jdee for future release.
> I'm not an expert lisp coder, if something is wrong, tou can mdofiy this
> code without hesitating
Hi Christophe,
Thanks for contributing this useful enhancement. I have updated
jde-util.el to include your contribution, making a few changes to
simplify the code. Your contribution will require a similar
enhancement to be made to the command for finding the definition of
the symbol at point so that it supports symbols defined in source code
stored in jar and zip files. I plan to make this enhancement as soon
as possible. Users who want to get your enhancement can do so by
downloading the latest version of jde-util.el from the JDEE CVS
repository.
Paul
>
> Christophe
>
> ; jde-search-src-dirs ;;;
> (defun jde-find-class-source-file (class)
> "*Find the source file for a specified class.
> CLASS is the fully qualified name of the class. This
> function searchs the source file paths specified by
> `jde-sourcepath' for the source file
> corresponding to CLASS. If it finds the source file,
> it returns the file's path. Otherwise, it returns nil."
> (let* ((class (jde-remove-inner-class class))
> (source-dir (jde-search-src-dirs class))
> (file-name
> (concat (jde-parse-get-unqualified-name class)
> ".java")))
> (if source-dir
> (if (not (string= source-dir "jar-src"))
> (expand-file-name file-name source-dir)
> )
>(message "JDE error: Could not find source for \"%s\". See
> `jde-sourcepath' for more information." class)
>nil)))
> ;
>
> ; jde-search-src-dirs ;;;
> (defun jde-search-src-dirs(class)
> ;;(interactive)
> ;;(setq class (read-buffer "CLASS: "))
>(let ((file (concat
> (jde-parse-get-unqualified-name class)
> ".java"))
> (package (jde-parse-get-package-from-name class))
> )
> (catch 'found
> (loop for dir in jde-sourcepath do
> (progn
>(setq dir(jde-normalize-path dir 'jde-sourcepath))
>(setq extractor nil)
>(if (and (or (string-match "\.jar$" dir)
> (string-match "\.zip$" dir)
> )
> (file-exists-p dir))
>(progn
> (let* ((other-window-p nil)
> (pkg-path (subst-char-in-string ?. ?/ package))
> (view-p (eq other-window-p 'view))
> (class-file-name (concat pkg-path "/" file))
> (bufname (concat file " (" (file-name-nondirectory
> dir) ")"))
> (buffer (get-buffer bufname))
> (just-created nil)
> exit-status success)
>(if buffer
>(progn
> (or (not (buffer-name buffer))
> (progn
>(if view-p
>(view-buffer buffer (and just-created
> 'kill-buffer))
> (if (eq other-window-p 'display)
> (display-buffer buffer)
>(if other-window-p
>(switch-to-buffer-other-window buffer)
> (switch-to-buffer buffer)))
> )))
> )
> (setq buffer (get-buffer-create bufname))
> (setq just-created t)
> (save-excursion
>(set-buffer buffer)
>(setq buffer-file-name (expand-file-name (concat dir
> ":"
> class-file-name)))
>(setq buffer-file-truename file)
>(setq default-directory (file-name-directory dir))
>(setq exit-status (archive-extract-by-stdout dir
> class-file-name
> archive-zip-extract))
>(message "status:%s" exit-status)
>(if (and (numberp exit-status) (= exit-status 0))
>(progn
> (message "found");
> (setq buffer-read-only t)
> (goto-char (point-min))
>