tags:

views:

289

answers:

1

I am using windows emacs with specifications below.

GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600) of 2009-02-26

I want to be able to run astyle so it can reformat the code by using a key command or menu. What is some other equivalent in emacs?

+2  A: 

Something like this might do:

(defun astyle-this-buffer (pmin pmax)
  (interactive "r")
  (shell-command-on-region pmin pmax
                           "astyle" ;; add options here...
                           (current-buffer) t 
                           (get-buffer-create "*Astyle Errors*") t))

This will run the "astyle" command on the selected region.

Or, you could simply use emacs' built-in code formatting by typing something like

 C-x h C-M-\

(I.e. select the whole buffer and run indent-region)

Edric