From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Art Werschulz Newsgroups: gmane.emacs.help Subject: auto-indenting C++ files upon saving Date: Fri, 19 Feb 2010 11:23:42 -0500 Organization: A noiseless patient Spider Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1266597781 5371 80.91.229.12 (19 Feb 2010 16:43:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Feb 2010 16:43:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 19 17:42:58 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NiVwP-0004FT-Bl for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Feb 2010 17:42:57 +0100 Original-Received: from localhost ([127.0.0.1]:54527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiVwO-0005ns-LW for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Feb 2010 11:42:56 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.glorb.com!news2.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Injection-Date: Fri, 19 Feb 2010 16:23:56 +0000 (UTC) Injection-Info: feeder.eternal-september.org; posting-host="8LkmQYSJF0tOGrwCg8rgUw"; logging-data="27226"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LKYlaiS87mLIpxXQo3Upw" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:WeKPv4hHhbsSXJKSK4+UBHGoR8k= sha1:eHZc8WPx6qwzOTD+qSTlf42ThQI= Original-Xref: news.stanford.edu gnu.emacs.help:176892 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: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71960 Archived-At: Hi. I am trying to teach my students that they should auto-indent their C++ files before saving, by issuing the commands C-x h M-C-\ i.e., (mark-whole-buffer) (indent-region) However, they haven't trained their "muscle memory" to do this, i.e., to automatically type the sequence C-x M-C-\ C-x C-s How can this be automated, so that a file gets auto-indented whenever it's saved? I thinking of something along the lines of (setq auto-save-hook (lambda (mark-whole-region) (indent-region))) but this didn't seem to work. Actually, I'd only want this to work in some situations, e.g., a file whose name matches a certain pattern. Said pattern would be stored in some variable. My emacs-lisp is very weak. Suggestions? Thanks! -- Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r- Net: agw@dsm.fordham.edu http://www.dsm.fordham.edu/~agw Phone: Fordham U. (212) 636-6325, Columbia U. (646) 775-6035