Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

97 lines (73 sloc) 2.423 kB
;;;;;;; escj2-java: ESC/Java2 Minor Mode
;;;;;;; Version 0.1
;;; Author: Ragnar Dahlén (
(require 'jde)
(defvar escj2-command nil
"Command for ESC/Java2 executable")
(defvar escj2-command-options nil
"Options for command")
(defvar escj2-mode-keymap nil
"Keymap for ESC/Java2 minor mode")
(defvar escj2-output-buffer-name nil
"Name of output buffer for ESC/Java2")
;;; Set default values
(setq escj2-command "escj"))
(setq escj2-command-options "-loopsafe"))
(setq escj2-mode-keymap (make-sparse-keymap))
(define-key escj2-mode-keymap (kbd "C-c m") 'escj2-verify-method-at-point)
(define-key escj2-mode-keymap (kbd "C-c v") 'escj2-verify-current-buffer)
(define-key escj2-mode-keymap (kbd "C-c b v") 'escj2-verify-buffer))
(setq escj2-output-buffer-name "*escj2-output*"))
;;; Define Minor Mode
(define-minor-mode escj2-mode
"Toggle ESC/Java2 mode.
With no argument, this command toggles the mode.
Non-null prefix argument turns on the mode.
Null prefix argument turns off the mode."
" ESCJ2"
:group 'escj2)
(defun escj2-verify-current-buffer ()
"Verify the current buffer"
(escj2-verify-buffer (buffer-name (current-buffer))))
(defun escj2-verify-buffer (buffer)
"Verify the contents of a buffer"
(interactive "bBuffer: ")
(let ((file-name (buffer-file-name (get-buffer buffer))))
(escj2-run-verifier file-name escj2-command-options)))
(defun escj2-verify-method-at-point ()
"Verify the method at point"
(let ((file-name (buffer-file-name (current-buffer)))
(method (car (jde-parse-get-method-at-point))))
(escj2-verify-method file-name
(car method)
(cdr method))))
(defun escj2-verify-method (file-name class method)
"Verify a method"
(let ((files (list file-name))
(args (concat "-Routine " method)))
(escj2-run-verifier files args)))
(defun escj2-run-verifier (files &rest args)
"Execute ESC/Java2 verifier
Run the verifier for the java source files in FILES, passing
it the arguments in ARGS.
(switch-to-buffer-other-window escj2-output-buffer-name)
(goto-char (point-min))
(let ((program-args (append files args)))
(eval `(start-process "escj"
escj2-command file-name
Jump to Line
Something went wrong with that request. Please try again.