Patch for allowing wildcards in jde-sourcepath

Troy Daniels <[email protected]>
Newsgroups gmane.emacs.jdee.devel
Message-ID <[email protected]>
Greetings,

Attached is a patch to the 2.4.0 branch which allows wildcards in
jde-sourcepath.  I've been using it at work for a few days and it works for
me.  Can somebody with commit permissions add it to the repository?

Troy

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
jdee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-devel
jde-sourcepath-wildcards.patch (application/octet-stream, 8 KB)
Index: jde/lisp/jde-db.el
===================================================================
--- jde/lisp/jde-db.el	(revision 216)
+++ jde/lisp/jde-db.el	(working copy)
@@ -2006,12 +2006,11 @@
        (string-match
 	(concat
 	 "^"
-	 (jde-normalize-path
-	  dir-x
-	  'jde-sourcepath))
-	filename))
-     jde-sourcepath)))
+	 dir-x
+	 )))
+     (jde-expand-wildcards-in-paths-p jde-sourcepath 'jde-sourcepath))))
 
+
 (provide 'jde-db)
 
 ;;; End of jde-db.el
Index: jde/lisp/jde-javadoc-gen.el
===================================================================
--- jde/lisp/jde-javadoc-gen.el	(revision 216)
+++ jde/lisp/jde-javadoc-gen.el	(working copy)
@@ -328,8 +328,7 @@
 	       (list
 		"-sourcepath"
 		(jde-build-classpath
-		 jde-sourcepath
-		 'jde-sourcepath)))))
+		 (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))))))
 
 
     ;; Insert bootclasspath
Index: jde/lisp/jde-open-source.el
===================================================================
--- jde/lisp/jde-open-source.el	(revision 216)
+++ jde/lisp/jde-open-source.el	(working copy)
@@ -317,45 +317,43 @@
 		".java")
 	  package (jde-parse-get-package-from-name outer-class))
     (catch 'found
-      (loop for path in jde-sourcepath do
-	    (progn
-	      (setq path (jde-normalize-path path 'jde-sourcepath))
-	      (if (and (file-exists-p path)
-		       (or (string-match "\.jar$" path)
-			   (string-match "\.zip$" path)))
-		  (let* ((bufname (concat file " (" (file-name-nondirectory path) ")"))
-			 (buffer (get-buffer bufname)))
-		    (if buffer
-			(throw 'found buffer)
-		      (let* ((pkg-path (subst-char-in-string ?. ?/ package))
-			     (class-file-name (concat  pkg-path "/" file))
-			     success)
-			(setq buffer (get-buffer-create bufname))
-			(save-excursion
-			  (set-buffer buffer)
-			  (setq buffer-file-name (expand-file-name (concat path ":" class-file-name)))
-			  (setq buffer-file-truename file)
-			  (let ((exit-status
-				 (archive-extract-by-stdout path class-file-name archive-zip-extract)))
-			    (if (and (numberp exit-status) (= exit-status 0))
-				(progn
-				  (jde-mode)
-				  (goto-char (point-min))
-				  (setq buffer-undo-list nil)
-				  (setq buffer-saved-size (buffer-size))
-				  (set-buffer-modified-p nil)
-				  (setq buffer-read-only t)
-				  (throw 'found buffer))
+      (loop for path in (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath) do
+	    (if (and (file-exists-p path)
+		     (or (string-match "\.jar$" path)
+			 (string-match "\.zip$" path)))
+		(let* ((bufname (concat file " (" (file-name-nondirectory path) ")"))
+		       (buffer (get-buffer bufname)))
+		  (if buffer
+		      (throw 'found buffer)
+		    (let* ((pkg-path (subst-char-in-string ?. ?/ package))
+			   (class-file-name (concat  pkg-path "/" file))
+			   success)
+		      (setq buffer (get-buffer-create bufname))
+		      (save-excursion
+			(set-buffer buffer)
+			(setq buffer-file-name (expand-file-name (concat path ":" class-file-name)))
+			(setq buffer-file-truename file)
+			(let ((exit-status
+			       (archive-extract-by-stdout path class-file-name archive-zip-extract)))
+			  (if (and (numberp exit-status) (= exit-status 0))
 			      (progn
+				(jde-mode)
+				(goto-char (point-min))
+				(setq buffer-undo-list nil)
+				(setq buffer-saved-size (buffer-size))
 				(set-buffer-modified-p nil)
-				(kill-buffer buffer))))))))
-		(if (file-exists-p (expand-file-name file path))
-		    (throw 'found (expand-file-name file path))
-		  (let* ((pkg-path (subst-char-in-string ?. ?/ package))
-			 (pkg-dir (expand-file-name pkg-path path))
-			 (file-path (expand-file-name file pkg-dir)))
-		    (if (file-exists-p file-path)
-			(throw 'found file-path))))))))))
+				(setq buffer-read-only t)
+				(throw 'found buffer))
+			    (progn
+			      (set-buffer-modified-p nil)
+			      (kill-buffer buffer))))))))
+	      (if (file-exists-p (expand-file-name file path))
+		  (throw 'found (expand-file-name file path))
+		(let* ((pkg-path (subst-char-in-string ?. ?/ package))
+		       (pkg-dir (expand-file-name pkg-path path))
+		       (file-path (expand-file-name file pkg-dir)))
+		  (if (file-exists-p file-path)
+		      (throw 'found file-path)))))))))
 
 (defcustom jde-preferred-packages
   '("java.util" "java" "javax")
Index: jde/lisp/jde-package.el
===================================================================
--- jde/lisp/jde-package.el	(revision 216)
+++ jde/lisp/jde-package.el	(working copy)
@@ -152,7 +152,7 @@
    (jde-package-get-classpath)))
 
 
-(defun jde-package-seach-package-directories ()
+(defun jde-package-search-package-directories ()
   "Return a list of package directory candidates or nil if not found."
   (let ((dir (jde-normalize-path default-directory))
 	;; case-insensitive for Windows
@@ -166,9 +166,8 @@
      (append (jde-package-get-directories-in-classpath)
 	     (mapcar
 	      (lambda (p)
-		(file-name-as-directory
-		 (jde-normalize-path p 'jde-sourcepath)))
-	      jde-sourcepath)))))
+		(file-name-as-directory p))
+	      (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))))))
 
 (defun jde-package-best-package-candidate (candidates)
   "Return the best package directory candidate from CANDIDATES.
@@ -181,7 +180,7 @@
   "Return the package directory, if found; otherwise,
 `jde-package-unknown-package-name'."
   (or (jde-package-best-package-candidate
-       (jde-package-seach-package-directories))
+       (jde-package-search-package-directories))
       jde-package-unknown-package-name))
 
 
Index: jde/lisp/jde-xref.el
===================================================================
--- jde/lisp/jde-xref.el	(revision 216)
+++ jde/lisp/jde-xref.el	(working copy)
@@ -190,7 +190,11 @@
     (when (and (eq major-mode 'jde-mode) jde-sourcepath)
       (let ((first-prefix (car (split-string (jde-parse-get-package-name)
 					     "\\."))) (prefixes))
-	(dolist (path (remove-if-not (lambda (path) (file-exists-p path)) jde-sourcepath) prefixes)
+	(dolist (path (remove-if-not 
+		       (lambda (path) 
+			 (file-exists-p path))
+		       (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))
+		      prefixes)
 	  (when (member first-prefix (directory-files path nil "[^.]$"))
 	    (message (concat "path = " path))
 	    (add-to-list 'prefixes (get-prefix path first-prefix))))))))
Index: jde/lisp/jde.el
===================================================================
--- jde/lisp/jde.el	(revision 216)
+++ jde/lisp/jde.el	(working copy)
@@ -543,7 +543,7 @@
 source files corresponding to class files.  When entering paths in the
 custom buffer, enter each path as a separate item in a separate edit
 field. Do NOT put more than one path in the same edit field. You'll
-only confuse JDE.  Paths may contain environment variables."
+only confuse JDE.  Paths may contain environment variables or wildcards."
   :group 'jde-project
   :type '(repeat (file :tag "Path")))
 
@@ -1490,6 +1490,30 @@
     (setq p (jde-convert-cygwin-path p))
     p))
 
+(defcustom jde-expand-wildcards-in-paths-p t
+  "Expands entries in the 'jde-sourcepath which are wildcards patterns into a list of matching files or directories which are interpolated into the sourcepath list."
+   :group 'jde-project
+   :type 'boolean)
+
+(defun jde-expand-wildcards-and-normalize (path &optional symbol)
+  "Expand any entries with wildcard patterns in path and interpolate them into the result"
+  (if jde-expand-wildcards-in-paths-p
+      (mapcan
+       (lambda (path)
+	 (let ((exp-paths (file-expand-wildcards path)))
+	   (if exp-paths exp-paths (list path))))
+       (jde-normalize-paths path symbol))
+    (jde-normalize-paths path symbol)
+    ))
+
+(defmacro jde-normalize-paths (pathlist &optional symbol)
+  "Normalize all paths of the list PATHLIST and returns a list with the
+expanded paths."
+  (` (mapcar (lambda (path)
+               (jde-normalize-path path (, symbol)))
+             (, pathlist))))
+
+
 (defun jde-directory-files-recurs (dir &optional include-regexp)
   "Get all the files in DIR, and any subdirectories of DIR, whose
 names match INCLUDE-REGEXP."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.