unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: capnwhit@yahoo.com (Bob Whitaker)
Subject: How to set Emacs indentation style in batch mode
Date: 25 Oct 2004 18:28:54 -0700	[thread overview]
Message-ID: <27dcd52b.0410251728.272540da@posting.google.com> (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

             reply	other threads:[~2004-10-26  1:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-26  1:28 Bob Whitaker [this message]
2004-10-26  9:26 ` How to set Emacs indentation style in batch mode Aidan Kehoe
2004-10-26 14:41   ` Bob Whitaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27dcd52b.0410251728.272540da@posting.google.com \
    --to=capnwhit@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).