Hi. Since I'm using (and abusing) 'jde-wiz-find-and-import', I found
my java files with lots of import sentences (no more *'s, i don't like
them). The problem is the disorder of that sentences (I just type my
keystroke for 'jde-wiz-find-and-import' in each of the "class not
found" errors. So I wrote a small lisp function to sort alphabetically
the import sentences:
(defun sort-imports()
(interactive)
"Sort the \"import\" sentences in a file"
(save-excursion
(beginning-of-buffer)
(search-forward-regexp "^import.*;")
(let ((inicio (match-beginning 0)))
(end-of-buffer)
(search-backward-regexp "^import.*;")
(let ((fin (match-end 0)))
(sort-lines nil inicio fin)))))
Maybe somebody else find this little function useful.
Another useful function related to imports sentences could be
eliminate the "imports" of classes no longer needed in the java file
(something about search the number of occurrences of the word before
the ";" of the "import A.B.C;.*" lines and if equal to 0 remove the
line (well, is not so simple, I suppose, the ocurrence may be in a
comment, or be a substring of the name of another class). Does anybody
know of a function like that? (it exceeds my limited elisp knowledge)
--
Leon