* Re: How to change indent width one buffer at a time?
[not found] <mailman.13169.1261147585.2239.help-gnu-emacs@gnu.org>
@ 2009-12-18 15:25 ` despen
2009-12-18 18:41 ` Mat
[not found] ` <mailman.13194.1261214347.2239.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: despen @ 2009-12-18 15:25 UTC (permalink / raw)
To: help-gnu-emacs
Mat <nabble.mexon@spamgourmet.com> writes:
> I've been trying to google this, but any search on "emacs indent width" turns
> up suggestions for setting c-basic-offset or similar. That's great if
> you're the only person who works on your code or there's an efficient
> code-formatting gestapo in your office. For normal people, who have to work
> with other normal people, some files use two spaces, some four, some eight,
> and if you reformat an entire file to your preferred depth just to make a
> one-line fix and check it into the repository then everyone shouts at you.
>
> So how do I quickly change the indent width for this buffer only?
Google "emacs file local variables".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to change indent width one buffer at a time?
2009-12-18 15:25 ` How to change indent width one buffer at a time? despen
@ 2009-12-18 18:41 ` Mat
2009-12-19 21:31 ` Kevin Rodgers
[not found] ` <mailman.13194.1261214347.2239.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 7+ messages in thread
From: Mat @ 2009-12-18 18:41 UTC (permalink / raw)
To: Help-gnu-emacs
despen wrote:
>
>
> Google "emacs file local variables".
>
>
OK, so the answer is "M-x set-variable", "c-basic-offset", then the value.
I was surprised that doing the setf in .emacs affects every buffer, but
doing it interactively only changes the current buffer.
Anyway, since that's a lot of trouble, I made myself a shortcut:
(defun change-c-basic-offset (size)
(interactive "nNew indent size: ")
(setf c-basic-offset size))
--
View this message in context: http://old.nabble.com/How-to-change-indent-width-one-buffer-at-a-time--tp26842186p26847770.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to change indent width one buffer at a time?
2009-12-18 18:41 ` Mat
@ 2009-12-19 21:31 ` Kevin Rodgers
0 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2009-12-19 21:31 UTC (permalink / raw)
To: help-gnu-emacs
Mat wrote:
> OK, so the answer is "M-x set-variable", "c-basic-offset", then the value.
> I was surprised that doing the setf in .emacs affects every buffer, but
Because cc-vars hasn't been loaded at that point, so you are setting its
global default value (effectively, setq-default).
> doing it interactively only changes the current buffer.
,----[ C-h v c-basic-offset RET ]
| c-basic-offset is a variable defined in `cc-vars.el'.
| Its value is 2
| Local in buffer foo.c; global value is set-from-style
| Automatically becomes buffer-local when set in any fashion.
|
|
| This variable is safe as a file local variable if its value
| satisfies the predicate `integerp'.
|
| Documentation:
| *Amount of basic offset used by + and - symbols in `c-offsets-alist'.
| Also used as the indentation step when `c-syntactic-indentation' is
| nil.
|
| This is a style variable. Apart from the valid values described
| above, it can be set to the symbol `set-from-style'. In that case, it
| takes its value from the style system (see `c-default-style' and
| `c-style-alist') when a CC Mode buffer is initialized. Otherwise,
| the value set here overrides the style system (there is a variable
| `c-old-style-variable-behavior' that changes this, though).
|
| You can customize this variable.
|
| [back]
`----
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.13194.1261214347.2239.help-gnu-emacs@gnu.org>]
* Re: How to change indent width one buffer at a time?
[not found] ` <mailman.13194.1261214347.2239.help-gnu-emacs@gnu.org>
@ 2009-12-19 14:52 ` despen
2009-12-21 9:35 ` Mat
[not found] ` <mailman.2.1261406580.1956.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: despen @ 2009-12-19 14:52 UTC (permalink / raw)
To: help-gnu-emacs
Mat <nabble.mexon@spamgourmet.com> writes:
> despen wrote:
>>
>>
>> Google "emacs file local variables".
>>
>>
>
> OK, so the answer is "M-x set-variable", "c-basic-offset", then the value.
> I was surprised that doing the setf in .emacs affects every buffer, but
> doing it interactively only changes the current buffer.
>
> Anyway, since that's a lot of trouble, I made myself a shortcut:
>
> (defun change-c-basic-offset (size)
> (interactive "nNew indent size: ")
> (setf c-basic-offset size))
No, that's not the answer...
Go to the first hit, then select the first item.
You'll see:
;; -*- mode: Lisp; fill-column: 75; comment-column: 50; -*
Which is good for Lisp, but I think you're looking for C.
So you want:
/* -*- mode: C; c-basic-offset: 1; -*- */
Put a line like that at the top of each file with the offset the file
uses.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to change indent width one buffer at a time?
2009-12-19 14:52 ` despen
@ 2009-12-21 9:35 ` Mat
[not found] ` <mailman.2.1261406580.1956.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Mat @ 2009-12-21 9:35 UTC (permalink / raw)
To: Help-gnu-emacs
despen wrote:
>
>
> No, that's not the answer...
>
> Go to the first hit, then select the first item.
>
> You'll see:
>
> ;; -*- mode: Lisp; fill-column: 75; comment-column: 50; -*
>
> Which is good for Lisp, but I think you're looking for C.
>
> So you want:
>
> /* -*- mode: C; c-basic-offset: 1; -*- */
>
> Put a line like that at the top of each file with the offset the file
> uses.
>
An interesting feature. But no, not the answer in this case, because it
involves putting editor-specific lines inside shared code, and I'm the only
person in this office using emacs. Also, it only seems to allow you to set
one offset for a particular file, which is no good here since there are
often different indent widths at different places within the same file.
--
View this message in context: http://old.nabble.com/How-to-change-indent-width-one-buffer-at-a-time--tp26842186p26871701.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.2.1261406580.1956.help-gnu-emacs@gnu.org>]
* Re: How to change indent width one buffer at a time?
[not found] ` <mailman.2.1261406580.1956.help-gnu-emacs@gnu.org>
@ 2009-12-21 17:18 ` despen
0 siblings, 0 replies; 7+ messages in thread
From: despen @ 2009-12-21 17:18 UTC (permalink / raw)
To: help-gnu-emacs
Mat <nabble.mexon@spamgourmet.com> writes:
> despen wrote:
>>
>>
>> No, that's not the answer...
>>
>> Go to the first hit, then select the first item.
>>
>> You'll see:
>>
>> ;; -*- mode: Lisp; fill-column: 75; comment-column: 50; -*
>>
>> Which is good for Lisp, but I think you're looking for C.
>>
>> So you want:
>>
>> /* -*- mode: C; c-basic-offset: 1; -*- */
>>
>> Put a line like that at the top of each file with the offset the file
>> uses.
>>
>
> An interesting feature. But no, not the answer in this case, because it
> involves putting editor-specific lines inside shared code, and I'm the only
> person in this office using emacs. Also, it only seems to allow you to set
> one offset for a particular file, which is no good here since there are
> often different indent widths at different places within the same file.
Different offsets in the same file.
That's nuts!
C-x h
C-M-\
(Make region whole buffer, indent-region.)
^ permalink raw reply [flat|nested] 7+ messages in thread
* How to change indent width one buffer at a time?
@ 2009-12-18 11:33 Mat
0 siblings, 0 replies; 7+ messages in thread
From: Mat @ 2009-12-18 11:33 UTC (permalink / raw)
To: Help-gnu-emacs
I've been trying to google this, but any search on "emacs indent width" turns
up suggestions for setting c-basic-offset or similar. That's great if
you're the only person who works on your code or there's an efficient
code-formatting gestapo in your office. For normal people, who have to work
with other normal people, some files use two spaces, some four, some eight,
and if you reformat an entire file to your preferred depth just to make a
one-line fix and check it into the repository then everyone shouts at you.
So how do I quickly change the indent width for this buffer only?
Thanks,
Mat
--
View this message in context: http://old.nabble.com/How-to-change-indent-width-one-buffer-at-a-time--tp26842186p26842186.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-12-21 17:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.13169.1261147585.2239.help-gnu-emacs@gnu.org>
2009-12-18 15:25 ` How to change indent width one buffer at a time? despen
2009-12-18 18:41 ` Mat
2009-12-19 21:31 ` Kevin Rodgers
[not found] ` <mailman.13194.1261214347.2239.help-gnu-emacs@gnu.org>
2009-12-19 14:52 ` despen
2009-12-21 9:35 ` Mat
[not found] ` <mailman.2.1261406580.1956.help-gnu-emacs@gnu.org>
2009-12-21 17:18 ` despen
2009-12-18 11:33 Mat
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.