[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Electric indentation (Was: Re: js.el changes)
From: |
Daniel Colascione |
Subject: |
Re: Electric indentation (Was: Re: js.el changes) |
Date: |
Fri, 21 Aug 2009 12:35:44 -0400 |
User-agent: |
KMail/1.11.4 (Linux/2.6.29.6-217.2.8.fc11.i586; KDE/4.2.4; i686; ; ) |
On Friday 21 August 2009, you wrote:
> On Fri, Aug 21, 2009 at 6:28 PM, Daniel Colascione<address@hidden> wrote:
> > On Friday 21 August 2009, you wrote:
> >> Maybe it could be done similar to indent-line-function etc?
> >
> > Err, how do you mean? Different electric keys require different behavior in
> > different modes. One variable can't be used to dispatch to all these
> > various pieces of code. You could have electric-indentation-mode call a
> > mode-specific function that decides what to do with a given electric key,
> > but isn't that just reimplementating the keymap mechanism?
>
>
> It allows you to have a minor mode to toggle the behaviour.
I feel like we're talking past each other. Right now, a mode like js-mode or
cc-mode binds keys that are supposed to be electric to a mode-specific
function. Let's use cc-mode as an example: it binds { to c-electric-brace.
c-electric-brace runs self-insert-command and checks whether the variable
c-electric-flag is true. If it is, it performs some specific indentation
operations.
My proposal is to create a new globalized minor mode called
electric-indentation-mode. An electric insert function like c-electric-brace,
instead of checking a mode-specific flag, would instead check the value of the
variable electric-indentation-mode. That way, the user can use one interface to
enable or disable electric indentation for all supported modes at once.