Hello Sonu,
> David, I have been searching the internet looking for one specific
> cuztomization, and I am unable to find it. I was wondering if you
> could help me out? When I create a new .java file, I would like for
> jde-gen-class to run automatically, how do I add this to my .emacs
> file? Any help would be greatly appreciated. Thanks!
I thought about your problem and found it an interesting idea :-)
Following is a possible implementation which seems to work well on my
NT Emacs 20.7, 21.0.102 and NT XEmacs 21.1.13.
------------------------- cut here ----------------------------------
(defvar jde-new-file-p nil
"Non-nil if can initialize this new file with a Java skeleton.")
;; This is a buffer local variable.
(make-variable-buffer-local 'jde-new-file-p)
;; Avoid `kill-all-local-variables' to kill it!
(put 'jde-new-file-p 'permanent-local t)
(defun jde-new-file-hook ()
"Hook run on nonexistent file.
It set the `jde-new-file-p' flag to non-nil if the new file can be
initialized with a Java skeleton.
It seems better to append this hook to `find-file-not-found-hooks'."
(let ((last-cmd (car (car command-history))))
;; Allow insertion of a Java skeleton only when the new file
;; resulted of a direct invocation of `find-file'. This prevent
;; insertion of multiple skeletons when the new file resulted of
;; execution of a `jde-gen-...' command!
(setq jde-new-file-p (eq last-cmd 'find-file)))
nil)
(defun jde-new-file-setup-hook ()
"Hook run after `jde-mode' is setup.
It inserts a Java skeleton in the current buffer if editing a new Java
file in `jde-mode'.
It seems better to append this hook to `jde-mode-hook'."
(and jde-new-file-p
(eq major-mode 'jde-mode)
(= (point-min) (point-max))
(progn
(jde-gen-class)
(beginning-of-buffer)
(search-forward "{")
(backward-char 1)
(c-indent-exp)
(tempo-forward-mark))))
(add-hook 'find-file-not-found-hooks #'jde-new-file-hook t)
(add-hook 'jde-mode-hook #'jde-new-file-setup-hook t)
---------------------- end cut here ---------------------------------
Hope this will help.
Sincerely,
David
__________________________________________________________________
Get your own FREE, personal Netscape Webmail account today at
http://webmail.netscape.com/