unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to set Emacs indentation style in batch mode
@ 2004-10-26  1:28 Bob Whitaker
  2004-10-26  9:26 ` Aidan Kehoe
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Whitaker @ 2004-10-26  1:28 UTC (permalink / raw)


Hello,

My end goal is to create a "pretty print" utility to indent poorly
indented C++ code automatically.

I have been successful by using XEmacs in batch mode but the only
problem is that it defaults to "gnu" indentation style, whereas I
would like "stroustrup" indentation style. Does anyone know how to do
this?

Here is the simple "emacs_pretty_print.el" file which I use:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FILE
;; ====
;; emacs_pretty_print.el
;;
;; USAGE
;; =====
;; Invoke "xemacs" as follows:
;;
;;   xemacs -batch MyFile.cpp -load emacs_pretty_print.el
;;
(setq-default c-default-style "stroustrup")
(setq-default c-basic-offset 3)
(setq-default indent-tabs-mode  nil)
(untabify (point-min) (point-max))
(indent-region (point-min) (point-max) nil)
(save-buffer)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Unfortunately this ".el" file does not work 100%. The formatted code
is in "gnu" style instead of "stroustrup" style. Notice that the other
"setq-default" parameters are set correctly (offset 3, and tabs nil).
I can change "c-basic-offset" to 2 or 4 and I can change
"indent-tabs-mode" to t or nil to verify correct operation. The only
problem is that "c-default-style" seems to be ignored. I have also
tried other modes like "ellemtel" without success.

I have searched Usenet archives and I have tried numerous other
combinations, such as follows:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(setq-default c-set-style "stroustrup")
(setq         c-set-style "stroustrup")
(setq-default c-default-style "stroustrup")
(setq         c-default-style "stroustrup")
(add-hook 'c-mode-hook '(lambda() (c++-mode)))
(add-hook 'c-mode-common-hook '(lambda() (c-set-style "stroustrup")))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

None of the above combinations works either. I have tried this using
the following version of Xemacs:

galaxy>xemacs -V
XEmacs 20.4 "Emerald" [Lucid] (sparc-sun-solaris2.6) of Wed May 16
2001 on guild

There must be a simple way to set the indentation style in batch mode,
but I just can't figure it out... Any help would be appreciated.

Thanks,

Bob

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-26 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-26  1:28 How to set Emacs indentation style in batch mode Bob Whitaker
2004-10-26  9:26 ` Aidan Kehoe
2004-10-26 14:41   ` Bob Whitaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).