At 06:52 PM 8/16/2001 +0200, Max Rydahl Andersen wrote:
>Sounds great - but is there not a method for adding such templates
>programattically as an extension to the current buffer-templates ?
>The custom-set-variables should only be used in .emacs, should it not ?
>

Yes, there is. Customize jde-gen-buffer-templates to add a template to the
JDE New->Other list.

- Paul


>Regards
> Max
>
>
>"Paul Kinnucan" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> At 07:26 AM 8/15/2001 -0600, Kevin Mukhar wrote:
>> >I don't know enough lisp to know if this is the best way, but sometime
>ago
>> >(from this list I think) someone posted some lisp that does what you
>need.
>> >After putting the code into my .emacs, I can select File/JDE New/Other,
>then
>> >press the space bar in the mini buffer to get a selection list of the
>> >templates, from which I can select the Test Class template that I have in
>my
>> >.emacs.
>> >
>>
>> I will include the JUnit template in a future release of the JDE.
>>
>> - Paul
>>
>>
>> >The parts of my .emacs that seem to be related to creating a junit test
>class
>> >are as follows:
>> >
>> >(custom-set-variables
>> >;;;other variables from my .emacs not shown
>> > '(jde-gen-test-class-buffer-template (quote ("(funcall
>> >jde-gen-boilerplate-function)" "\"package ;\"'>'n" "'>'n" "\"import
>> >junit.framework.*;\"'>'n" "'>'n" "\"/**\" '>'n" "\" * \""
>> >"(file-name-nondirectory buffer-file-name) '>'n" "\" *\" '>'n" "\" *\"
>'>'n"
>> >"\" * Created: \" (current-time-string) '>'n" "\" *\" '>'n" "\" * @author
><a
>> >href=\\\"mailto: \\\"\" (user-full-name)
>> >\"</a>\"'>'n" "\" * @version\" '>'n" "\" */\" '>'n'" "'>'n" "\"public
>class
>> >\"" "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))" "\" extends TestCase\"" "(if jde-gen-k&r " "()"
>"'>'n)"
>> >"\" {\"'>'n'n" "\"public \"" "(file-name-sans-extension
>> >(file-name-nondirectory
>> >buffer-file-name))" "\" (String name)\"" "(if jde-gen-k&r " "()" "'>'n)"
>"\"
>> >{\"'>'n" "\"super(name);\"" "'>'p'n" "\"}\">" "'>'n'n" "\"protected void
>> >setUp() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\">" "'>'n'n"
>> >"\"public static Test suite() \"" "(if jde-gen-k&r " "()" "'>'n)"
>"\"{\"'>'n"
>> >"\"return new TestSuite(\"" "(file-name-sans-extension
>(file-name-nondirectory
>> >buffer-file-name))" "\".class);\"'n" "\"}\">" "'>'n'n" "\"public static
>void
>> >main(String[] args) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n"
>> >"\"junit.textui.TestRunner.run(\"" "(file-name-sans-extension
>> >(file-name-nondirectory
>> >buffer-file-name))" "\".class);\"'n" "\"}\">" "'>'n" "\"}\">" "'>'n")))
>> >
>> > '(jde-gen-buffer-templates (quote (("Test Class" . jde-gen-test-class)
>> >("Class" . jde-gen-class) ("Console" . jde-gen-console) ("Swing App" .
>> >jde-gen-jfc-app))))
>> >) ;;;this should close custom-set-variables
>> >
>> >(defcustom jde-gen-test-class-buffer-template
>> >  (list
>> >    "(funcall jde-gen-boilerplate-function) '>'n"
>> >    "\"/**\" '>'n"
>> >    "\" * \""
>> >    "(file-name-nondirectory buffer-file-name) '>'n"
>> >    "\" *\" '>'n"
>> >    "\" *\" '>'n"
>> >    "\" * Created: \" (current-time-string) '>'n"
>> >    "\" *\" '>'n"
>> >    "\" * @author <a href=\\\"mailto: \\\"\" (user-full-name)
>> >\"</a>\"'>'n"
>> >    "\" * @version\" '>'n"
>> >    "\" */\" '>'n'"
>> >    "'>'n"
>> >    "\"public class \""
>> >    "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))"
>> >    "\" extends TestCase\""
>> >
>> >    "(if jde-gen-k&r "
>> >     "()"
>> >     "'>'n)"
>> >     "\"{\"'>'n'n"
>> >
>> >    "\"public \""
>> >    "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))"
>> >    "\" (String name)\""
>> >
>> >    "(if jde-gen-k&r "
>> >     "()"
>> >     "'>'n)"
>> >     "\"{\"'>'n"
>> >
>> >
>> >    "\"super(name);\""
>> >    "'>'p'n"
>> >    "\"}\">"
>> >    "'>'n'n"
>> >    "\"protected void setUp() \""
>> >    "(if jde-gen-k&r "
>> >     "()"
>> >     "'>'n)"
>> >     "\"{\"'>'n"
>> >
>> >    "'>'p'n"
>> >    "\"}\">"
>> >    "'>'n'n"
>> >    "\"public static Test suite() \""
>> >    "(if jde-gen-k&r "
>> >     "()"
>> >     "'>'n)"
>> >     "\"{\"'>'n"
>> >     "\"return new TestSuite(\""
>> >     "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))"
>> >     "\".class);\"'n"
>> >    "'>'p'n"
>> >    "\"}\">"
>> >    "'>'n'n"
>> >
>> >    "\"public static void main(String[] args) \""
>> >    "(if jde-gen-k&r "
>> >     "()"
>> >     "'>'n)"
>> >     "\"{\"'>'n"
>> >     "\"junit.textui.TestRunner.run(\""
>> >     "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))"
>> >     "\".class);\"'n"
>> >    "'>'p'n"
>> >    "\"}\">"
>> >    "'>'n'n"
>> >
>> >
>> >    "\"}\">"
>> >    "\"// \""
>> >    "(file-name-sans-extension (file-name-nondirectory
>> >buffer-file-name))"
>> >    "'>'n")
>> >  "*Template for new Java class.
>> >Setting this variable defines a template instantiation
>> >command `jde-gen-test-class', as a side-effect."
>> >  :group 'jde-gen
>> >  :type '(repeat string)
>> >  :set '(lambda (sym val)
>> >         (defalias 'jde-gen-test-class
>> >           (tempo-define-template "java-test-class-buffer-template"
>> >                      (jde-gen-read-template val)
>> >                       nil
>> >                       "Insert a generic Java class buffer skeleton."))
>> >         (set-default sym val)))
>> >
>> >;;;###autoload
>> >(defun jde-gen-test-class-buffer (file)
>> >  "Create a new Java buffer containing a class of the same name.
>> >This command inserts the class template generated by `jde-gen-class'.
>> >It then moves the point to the location to the constructor."
>> >  (interactive "F")
>> >  (find-file file)
>> >  (jde-gen-test-class)
>> >  (beginning-of-buffer)
>> >  (search-forward "{")
>> >  (backward-char 1)
>> >  (c-indent-exp)
>> >  (tempo-forward-mark))
>> >
>> >
>> >Max Rydahl Andersen wrote:
>> >>
>> >> How does one correctly register a new template so it will be available
>via
>> >> the Files/JDE New/Other... ?
>>
>

Reply via email to