[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Electric indentation (Was: Re: js.el changes)
From: |
Lennart Borgman |
Subject: |
Re: Electric indentation (Was: Re: js.el changes) |
Date: |
Fri, 21 Aug 2009 18:42:16 +0200 |
On Fri, Aug 21, 2009 at 6:35 PM, Daniel Colascione<address@hidden> wrote:
> 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.
Yes, you are right, we were talking past each other. I see now how you
mean. (But maybe a globalized minor mode would be better?)
I do not know which way is the best. Using a function instead would
make it possible to define common default behaviour, but I do not know
if it is useful.