Here is how I run the JIndent utility on a buffer of Java source.
The key routine is jindent which uses shell-command-on-region.

Erik Husby
Domain Pharma Corp
Suite 110      Vox: 781-778-3834
10 Maguire Rd       Fax: 781-778-3800
Lexington, MA 02421 Email: [EMAIL PROTECTED]



----------------Cut here------------JIndent.el --------------------
;; This file is not part of Emacs

;; Copyright (C) 2000 by Erik Husby
;; Author:       Erik Husby [EMAIL PROTECTED]
;; Maintainer:   Erik Husby [EMAIL PROTECTED]
;; Created:      February 17, 2000

;; COPYRIGHT NOTICE
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Description:
;;
;;  This package will run the JIndent program on the current buffer.

;;; Installation:
;;
;;  Put this file on your Emacs-Lisp load path and add following into your
;;  ~/.emacs startup file
;;
;;      (require 'jindent)

;;; Usage:
;;
;;  M-x `jindent'
;;     Format the current buffer using JIndent. The contents of the buffer
are replaced
;;     by the output of JIndent.
;;

;;; Customization:
;;
;;  M-x `jindent-customize' to customize all the jindent options.
;;
;;  The following variables could be set:
;;
;;  o `jindent-command'
;;        The command used to run JIndent.
;;        The easiest thing to do is to wrap JIndent in a command
procedure.
;;        This should then be the name of the command procedure.
;;
;;  o `jindent-args'
;;        The arguments passed on to JIndent.
;;

;;; Support:
;;
;;  Any comments, suggestions, bug reports or upgrade requests are welcome.
;;  Please send them to Erik Husby at [EMAIL PROTECTED]
;;

;;; Code:
(require 'custom)

(defgroup jindent nil
  "jindent package customization."
  :group 'jindent
  :prefix "jindent-")

(defcustom jindent-command  "d:\\raven\\src\\jindent"
  "*The command to be used to run JIndent"
  :group 'jindent
  :type 'string
  )

(defcustom jindent-args "-m"
  "*JIndent parameters."
  :group 'jindent
  :type 'string
  )

(defun jindent-customize()
  "Customization of JIndent"
  (interactive)
  (customize-group "jindent")
  )

(defun jindent ()
  "Runs jindent on the current buffer"
  (interactive)
  (let ((start (point-min))
     (end (point-max))
     (command (concat jindent-command " " jindent-args)))
    (shell-command-on-region start end command nil t)
    )
)


(provide 'jindent)

Reply via email to