From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: capnwhit@yahoo.com (Bob Whitaker) Newsgroups: gmane.emacs.help Subject: How to set Emacs indentation style in batch mode Date: 25 Oct 2004 18:28:54 -0700 Organization: http://groups.google.com Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <27dcd52b.0410251728.272540da@posting.google.com> NNTP-Posting-Host: deer.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1098805209 8085 80.91.229.6 (26 Oct 2004 15:40:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Oct 2004 15:40:09 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 26 17:40:02 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CMTQY-0008T2-00 for ; Tue, 26 Oct 2004 17:40:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CMTYF-0000Mz-5G for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Oct 2004 11:47:59 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: comp.emacs.xemacs,comp.emacs,gnu.emacs.help,gnu.emacs Original-Lines: 67 Original-NNTP-Posting-Host: 207.200.26.240 Original-X-Trace: posting.google.com 1098754135 11563 127.0.0.1 (26 Oct 2004 01:28:55 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 26 Oct 2004 01:28:55 +0000 (UTC) Original-Xref: shelby.stanford.edu comp.emacs.xemacs:75841 comp.emacs:86773 gnu.emacs.help:126057 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21439 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21439 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