all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Electric indentation (Was: Re: js.el changes)
       [not found] <87y6plkhj6.fsf@stupidchicken.com>
@ 2009-08-21 16:18 ` Daniel Colascione
  2009-08-21 16:22   ` Lennart Borgman
       [not found] ` <200908211228.17606.danc@merrillprint.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Colascione @ 2009-08-21 16:18 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

On Friday 14 August 2009, you wrote:
> 4. I removed the "electric indentation" feature implemented by
> js-auto-indent-flag and js-insert-and-indent.  I appreciate the intent,
> but it's not consistent with the way the other programming modes work,
> and this behavior should be implemented separately---as a minor mode
> that can be used generally.  Feel free to suggest this on emacs-devel.

I agree that a generic toggle switch for electric indentation would be nice. However, there's quite a bit of precedent for modes implementing their own electric indentation, often using complex logic (see c-electric-brace).

To me, the simplest option would be to create a new trivial minor mode, electric-indentation-mode, and modify all current mode-specific indentation code to check that mode's flag instead of relying on something mode-specific like js-auto-indent-flag or c-electric-flag. The actual mode-specific indentation can survive otherwise unchanged.




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

* Re: Electric indentation (Was: Re: js.el changes)
  2009-08-21 16:18 ` Electric indentation (Was: Re: js.el changes) Daniel Colascione
@ 2009-08-21 16:22   ` Lennart Borgman
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman @ 2009-08-21 16:22 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Chong Yidong, emacs-devel

On Fri, Aug 21, 2009 at 6:18 PM, Daniel Colascione<danc@merrillprint.com> wrote:
> On Friday 14 August 2009, you wrote:
>> 4. I removed the "electric indentation" feature implemented by
>> js-auto-indent-flag and js-insert-and-indent.  I appreciate the intent,
>> but it's not consistent with the way the other programming modes work,
>> and this behavior should be implemented separately---as a minor mode
>> that can be used generally.  Feel free to suggest this on emacs-devel.
>
> I agree that a generic toggle switch for electric indentation would be nice. However, there's quite a bit of precedent for modes implementing their own electric indentation, often using complex logic (see c-electric-brace).
>
> To me, the simplest option would be to create a new trivial minor mode, electric-indentation-mode, and modify all current mode-specific indentation code to check that mode's flag instead of relying on something mode-specific like js-auto-indent-flag or c-electric-flag. The actual mode-specific indentation can survive otherwise unchanged.


Maybe it could be done similar to indent-line-function etc?




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

* Re: Electric indentation (Was: Re: js.el changes)
       [not found]   ` <e01d8a50908210930l5677cb86jb63c21632b1ac1a3@mail.gmail.com>
@ 2009-08-21 16:35     ` Daniel Colascione
  2009-08-21 16:42       ` Lennart Borgman
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Colascione @ 2009-08-21 16:35 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: emacs-devel

On Friday 21 August 2009, you wrote:
> On Fri, Aug 21, 2009 at 6:28 PM, Daniel Colascione<danc@merrillprint.com> 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.




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

* Re: Electric indentation (Was: Re: js.el changes)
  2009-08-21 16:35     ` Daniel Colascione
@ 2009-08-21 16:42       ` Lennart Borgman
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman @ 2009-08-21 16:42 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: emacs-devel

On Fri, Aug 21, 2009 at 6:35 PM, Daniel Colascione<danc@merrillprint.com> wrote:
> On Friday 21 August 2009, you wrote:
>> On Fri, Aug 21, 2009 at 6:28 PM, Daniel Colascione<danc@merrillprint.com> 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.




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

end of thread, other threads:[~2009-08-21 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87y6plkhj6.fsf@stupidchicken.com>
2009-08-21 16:18 ` Electric indentation (Was: Re: js.el changes) Daniel Colascione
2009-08-21 16:22   ` Lennart Borgman
     [not found] ` <200908211228.17606.danc@merrillprint.com>
     [not found]   ` <e01d8a50908210930l5677cb86jb63c21632b1ac1a3@mail.gmail.com>
2009-08-21 16:35     ` Daniel Colascione
2009-08-21 16:42       ` Lennart Borgman

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.