some handy emacs code

Tom Tromey tromey@redhat.com
Wed Aug 6 20:18:00 GMT 2003


For those of you using Emacs, here's some handy code I wrote for
looking inside .jar files.

Put this in .emacs, and then when visiting a .jar or .zip file, you
can use "?" to run jcf-dump on the class.

Tom

(defun tjt-view-class-file ()
  (interactive)
  (if (eq archive-subtype 'zip)
      (let* ((descr (archive-get-descr))
	     (ename (aref descr 0))
	     (iname (aref descr 1))
	     ;; strip ".class"
	     (class (substring iname 0 -6)))
	(if (string-equal (substring iname -6) ".class")
	    (shell-command (concat "jcf-dump -c -I"
				   (buffer-file-name)
				   " "
				   class))))))

(add-hook 'archive-mode-hook
	  (function
	   (lambda ()
	     (define-key archive-mode-map "?" 'tjt-view-class-file))))



More information about the Java mailing list