;; $Id: DONjava.el,v 2.0 2000/11/11 09:55:03 tag Exp $ ;; Version $Name: R2_0_1 $ ;; ;; DONjava.el - Java-mode hook for DON Lab usage ;; by T.A. Gonsalves, 10-11-2000 ;; Last modified: Sat 11-Nov-2000 15:19:02 by tag ;; Get stmt templates etc from DONc: c-do-while-loop c-if-then-else ;; c-for-loop c-if-then c-switch c-while-loop ;; insert-relative-buffer-file-name ;; DONc-statement-block c-file-comment (require 'DONc) ;;; ;;; java-file-comment - setup a comment block template at the top of the file ;;; We put in tagged fields such as @bugs to end javadoc's ;;; scanning of paragraphs. (defun java-file-comment () "Sets up a comment template at the top of the file" (interactive "*") (save-match-data (goto-char (point-min)) (forward-line c-file-comment-start-line) (if (search-backward c-comment-block-start () t) (error "File already has a comment at the start")) (goto-char (point-min)) (c-file-comment) (if (y-or-n-p "Add a class template? ") (save-excursion (search-forward c-comment-block-end) (next-line 2) (java-class-comment (base-buffer-file-name)))))) (defun java-file-comment-body () ) (defun java-class-comment (className) "Sets up a comment template at the start of a class" (interactive "*sEnter class name: ") (c-class-comment className t)) (defun java-function-comment (funName retType) "Sets up a comment template at the start of a function" (interactive "*sEnter function name: \nsEnter return type: ") (c-function-comment funName retType)) (defun java-doc-comment () "Sets up an empty javadoc field comment block" (interactive "*") (if (not (eolp)) (end-of-line)) (if (not (progn (skip-chars-backward " \t") (bolp))) (progn (beginning-of-line) (open-line 1))) ; now insert the doc comment (insert "/**\n") (insert " *\n") (insert " */") (previous-line 1) (or (eolp) (end-of-line)) (insert " ")) (defun DONjava-setup () "Set indentation style a la DONLab and bind keys" (message "DON Java setup") (add-hook 'write-file-hooks 'time-stamp) (setq c-indent-level 2) (setq c-continued-statement-offset 4) (setq c-continued-brace-offset -4) (setq c-brace-offset 2) (setq c-brace-imaginary-offset 2) (setq c-label-offset -2) (define-key java-mode-map "\C-cc" 'java-class-comment) (define-key java-mode-map "\C-cd" 'c-do-while-loop) (define-key java-mode-map "\C-ce" 'c-if-then-else) (define-key java-mode-map "\C-cf" 'c-for-loop) (define-key java-mode-map "\C-ci" 'c-if-then) (define-key java-mode-map "\C-cj" 'java-doc-comment) (define-key java-mode-map "\C-cs" 'c-switch) (define-key java-mode-map "\C-cw" 'c-while-loop) (define-key java-mode-map "\C-ct" 'java-file-comment) (define-key java-mode-map "\C-cu" 'java-function-comment) (c-set-local-variables) ; Customize the comments (setq c-comment-prefix " * ") (setq c-comment-block-start "/**") (setq c-comment-block-end " */") (setq c-comment-author-label "@author") (setq c-comment-version-label "@version") (setq c-comment-module-label "@module") (setq c-comment-created-label "@created") (setq c-comment-purpose-label "@purpose") (setq c-comment-see-label "@see") (setq c-comment-bugs-label "@bugs") (setq c-comment-args-label "@param ") (setq c-comment-returns-label "@return") (setq c-comment-throws-label "@exception ") (setq c-comment-created-label "@created") (setq c-file-comment-body-hook 'java-file-comment-body) ) (provide 'DONjava) ;;;---------------------------------------------------------------- ;;; $Log: DONjava.el,v $ ;;; Revision 2.0 2000/11/11 09:55:03 tag ;;; Made DONel into a module, added README and INSTALL files ;;; ;;; Revision 1.2 2000/11/10 11:36:43 tag ;;; Added Version tag to DON\*.el ;;; ;;; Revision 1.1 2000/11/10 11:27:42 tag ;;; Modified to handle javadoc-style comments ;;; ;;; Local Variables: ;;; time-stamp-active: t ;;; time-stamp-line-limit: 20 ;;; time-stamp-start: "Last modified:[ ]+" ;;; time-stamp-format: "%3a %:d-%3b-%:y %02H:%02M:%02S by %u" ;;; time-stamp-end: "$" ;;; End: ;;; End of DONjava.el --------------------------------------------