This Emacs package is not an new autocode feature for JDE but can improve JDE class templates by automatically generate the Java package statement.
Put jpack.el on your Emacs-Lisp load path and add following
into your ~/.emacs startup file:
(require 'jpack)
The jpack-generate-package-statement function is intended
for being inserted in a class template instead of a hard-coded package
statement. You must have set the jde-compile-option-classpath
or jde-global-classpath variables (see the JDE user's guide
included in the distribution for details) because jpack use their values
to find the package coding. Your JDE class templates must also be customized
to call (jpack-generate-package-statement).
jde-global-classpath to
("~/java" "/jdk1.1.6/lib/classes.zip")
jde-gen-class-buffer-template to:
'("\"// \""
"(file-name-nondirectory buffer-file-name)"
"\" -- Give a short description here\" 'n"
"\"// $Id$\" 'n"
"'n"
"\"// Copyright (C) 1998 by David Ponce\" 'n"
"\"// Author: David Ponce david.ponce@wanadoo.fr\" 'n"
"\"// Maintainer: David Ponce david.ponce@wanadoo.fr\" 'n"
"\"// Created: \""
"(format-time-string \"%B %d %Y\" (current-time)) 'n"
"'n"
"\"// Change history:\" 'n"
"\"//\" 'n"
"\"// $Log$\" 'n"
"\"//\" 'n"
"(jpack-generate-package-statement) 'n"
"'n"
"\"import java.lang.*;\" 'n"
"'n"
"\"/**\" 'n"
"\" * \""
"(file-name-nondirectory buffer-file-name) 'n"
"\" *\" 'n"
"\" * @author \" (user-full-name) 'n"
"\" * @version $Revision$\" 'n"
"\" */\" 'n>"
"\"public\" 'n>"
"\"class \""
"(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
"\" {\" 'n>"
"'n>"
"\"/**\" 'n>"
"\" * Builds a new \""
"(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
"\" instance.\" 'n>"
"\" */\" 'n>"
"\"public\" 'n>"
"(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
"\"() {\" 'n>"
"\" \" 'n>"
"\"}\" 'n>"
"'n>"
"\"}\" 'n>"
"'n>"
"\"// \" (file-name-nondirectory buffer-file-name) \" ends here.\" 'n")
Then, I edit a new class file by running
M-x jde-gen-class-buffer RET ~/java/FR/test/MyClass.java RETand the following lines where automatically generated:
// MyClass.java -- Give a short description here
// $Id$
// Copyright (C) 1998 by David Ponce
// Author: David Ponce david.ponce@wanadoo.fr
// Maintainer: David Ponce david.ponce@wanadoo.fr
// Created: October 01 1998
// Change history:
//
// $Log$
//
package FR.test; // Generated package name
import java.lang.*;
/**
* MyClass.java
*
* @author David Ponce
* @version $Revision$
*/
public
class MyClass {
/**
* Builds a new MyClass instance.
*/
public
MyClass() {
}
}
// MyClass.java ends here.
The jpack-package-update command could be use to update
the package statement if you move a file to a different directory
(a new package!).
| Copyright © 1998, 1999 David Ponce | Last updated on 2/18/99 at 09:30:42 |