help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using indent program as filter to automatically view read-only C fil


From: François Gannaz
Subject: Re: Using indent program as filter to automatically view read-only C files
Date: Fri, 3 Feb 2006 20:06:48 +0100
User-agent: Mutt/1.5.11

Le ven 03 fév 03:46, juanleon1@gmail.com a écrit :
> Hi,
> 
> I have to work with C/C++ files with a very ugly and inconsistent
> indentation (many developers adding things with no style guide). This
> is very distracting, and since I cannot change them (to avoid conflicts
> when taking/carryng changes from/to other branches), I had think that
> for read-only files (those that I have not opened in the revision
> control system), it would be nice if emacs could run automagically the
> "indent" program so I can see the code "beatyfully" indented.

Why would you use the indent program when emacs can do it itself? You
can use indent-region, bounded to C-M-\

> I didn't find anything obvious on the net for that. I do not wanna
> modify files in disk, only to make emacs to put the indent output in
> the buffer without changing variables like `buffer-file-name' and so. I
> would like this to be done in a transparent way when opening a C/C++
> file (via find-file, find-tag or whatever).

You might want to add an indent-region call (with the right params) to
your c-mode-hook to make it transparent. Following it with
(set-buffer-modified-p nil) will avoid emacs asking for saving the
buffer on quitting.
If you don't know yet how to program in lisp, it's a good way to
learn :) And if you don't want to, ask for help here.

If you still want to use the indent program, have a look at
shell-command-on-region that should allow you to achieve what you
described.

Hope it helps
--
François Gannaz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]