all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Indenting with 2 spaces
       [not found] ` <xeiafwviv6td.fsf@kobe.laptop>
@ 2010-11-03 22:21   ` Philip
       [not found]     ` <jwvwrosvroy.fsf-monnier+gnu.emacs.help@gnu.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Philip @ 2010-11-03 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

On Nov 3, 10:07 am, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:
> On Tue, 2 Nov 2010 20:15:23 -0700 (PDT), Philip <phil.ganc...@gmail.com> wrote:
> > How can I set the indentation level to 2 spaces in all modes, so that
> > I get (for example) when I press Tab on the second line, I get the
> > following:
>
> > if test "$x"; then
> >   echo yes
> > fi
>
> > Notice there are only 2 spaces before the "echo"
>
> The indentation step is mode specific, so you can't set its value for
> *all* programming modes in one place.  You will have to add a hook to
> those modes you are interested in like:
>
>     ;;; Indentation setup for cc-mode and derivatives.
>
>     (defun keramida/cc-mode-setup ()
>       (interactive)
>       (make-local-variable 'c-basic-offset)
>       (setq c-basic-offset 2))
>
>     (eval-after-load "cc-mode"
>       '(add-hook 'c-mode-common-hook 'keramida/cc-mode-setup))
>
>     ;;; Indentation setup for text-mode and derivatives.
>
>     (defun keramida/text-mode-setup ()
>       (interactive)
>       (make-local-variable 'standard-indent)
>       (setq standard-indent 2))
>
>     (eval-after-load "text-mode"
>       '(add-hook 'text-mode-hook 'keramida/text-mode-setup))
>
>     ;; Indentation setup for sh-mode and derivatives.
>
>     (defun keramida/sh-mode-setup ()
>       (interactive)
>       (setq sh-basic-offset 2
>             sh-indentation 2))
>
>     (eval-after-load "sh-mode"
>       '(add-hook 'sh-mode-hook 'keramida/sh-mode-setup))
>
> Note: Using `eval-after-load' to set up the mode-hooks means that your
> average startup time shouldn't increase too much, and Emacs shouldn't
> try to auto-load all the affected modes *every* time it launches.

Thanks! That seems like a big limitation of Emacs that there is no way
to specify all modes at once.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Indenting with 2 spaces
       [not found]     ` <jwvwrosvroy.fsf-monnier+gnu.emacs.help@gnu.org>
@ 2010-11-04 21:05       ` despen
  0 siblings, 0 replies; 2+ messages in thread
From: despen @ 2010-11-04 21:05 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Thanks! That seems like a big limitation of Emacs that there is no way
>> to specify all modes at once.
>
> Yes and no:
> - it's an inconvenience that many aspects of major modes are not
>   sufficiently standardized for there to be a central place where the
>   default can be changed once and for all modes.
> - favorite indentation steps tend to depend on the language because
>   different styles of syntaxes lend themselves more or less well to
>   shallow/deep indentation steps.  Furthermore, most projects impose
>   a particular indentation style (and indentation's basic step is part
>   of it), so it's fairly common to have to use different basic steps in
>   different files, even for the same language, if you work on more than
>   a single project.
> So while I generally agree with you, in the specific case of basic
> indentation step, I don't think it's nearly as bad as you say.

Other issues:

1. Makefiles have a specific indentation and attempts to mess with
it would not work.

Whether there are other languages like that, I don't know.

I use my own BAL mode for mainframe Assembler that wouldn't tolerate
being adjusted.

2. Setting up a wrapper for a couple dozen common modes wouldn't be
all that hard as long as all you were worried about is basic indentation
but indentation rules are more complex than just width and spaces
vs. tabs.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-04 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <afc2d1bd-05a2-4068-bfd7-3793f40f9a96@j18g2000yqd.googlegroups.com>
     [not found] ` <xeiafwviv6td.fsf@kobe.laptop>
2010-11-03 22:21   ` Indenting with 2 spaces Philip
     [not found]     ` <jwvwrosvroy.fsf-monnier+gnu.emacs.help@gnu.org>
2010-11-04 21:05       ` despen

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.