* Re: electric-pair-mode
2013-11-16 23:27 electric-pair-mode Stefan Monnier
@ 2013-11-17 3:10 ` Xue Fuqiao
2013-11-17 18:30 ` electric-pair-mode Jorgen Schaefer
` (3 subsequent siblings)
4 siblings, 0 replies; 19+ messages in thread
From: Xue Fuqiao @ 2013-11-17 3:10 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On Sun, Nov 17, 2013 at 7:27 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>
> AFAIK, most of the issues pointed out in the previous electric-pair-mode
> have been resolved:
> E.g. C-j and (newline) now insert a plain newline. Some indentation
> functions are marked as "unable to reindent".
>
> I'm thinking of enabling electric-pair-mode in Emacs-24.4, and I think
> the best way to do that is to actually enable it and then deal with the
> complaints. But that only works if the complaints are
> sufficiently constructive.
>
> So, please try enabling it and report any annoyance you notice.
> If you just plain don't like the feature, then just disable it.
You mean electric-indent-mode, I assume? But anyway, both of them works
well for me.
--
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-16 23:27 electric-pair-mode Stefan Monnier
2013-11-17 3:10 ` electric-pair-mode Xue Fuqiao
@ 2013-11-17 18:30 ` Jorgen Schaefer
2013-11-17 21:12 ` electric-pair-mode Stefan Monnier
2013-11-18 11:04 ` electric-pair-mode Xue Fuqiao
2013-11-17 21:05 ` electric-indent-mode (was: electric-pair-mode) Stefan Monnier
` (2 subsequent siblings)
4 siblings, 2 replies; 19+ messages in thread
From: Jorgen Schaefer @ 2013-11-17 18:30 UTC (permalink / raw)
To: emacs-devel, Stefan Monnier
On Sat, 16 Nov 2013 18:27:30 -0500
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> I'm thinking of enabling electric-pair-mode in Emacs-24.4, and I think
> the best way to do that is to actually enable it and then deal with
> the complaints. But that only works if the complaints are
> sufficiently constructive.
>
> So, please try enabling it and report any annoyance you notice.
> If you just plain don't like the feature, then just disable it.
If this is about electric-PAIR-mode:
Works nicely, except the default `electric-pair-inhibit-predicate'
makes it so that {{ results in "{{_|_}", even though I'd expect
"{{_|_}}".
If this is about electric-INDENT-mode:
The global mode does not work well with ido-mode. When opening a new
buffer or file, you have to use C-j to confirm that you really want to
open a non-existing buffer/file. electric-indent-mode inserts the ^J
verbatim instead of this.
Reproduction:
Enable ido-mode for buffers
C-x b t C-j should create a new buffer named "t". With
electric-indent-mode, it does not confirm, but adds ^J to the buffer
name. RET then opens a buffer named "t^J". (This might also be a
misfeature in ido, not sure).
Regards,
Jorgen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-17 18:30 ` electric-pair-mode Jorgen Schaefer
@ 2013-11-17 21:12 ` Stefan Monnier
2013-11-18 11:04 ` electric-pair-mode Xue Fuqiao
1 sibling, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2013-11-17 21:12 UTC (permalink / raw)
To: Jorgen Schaefer; +Cc: emacs-devel
> The global mode does not work well with ido-mode. When opening a new
> buffer or file, you have to use C-j to confirm that you really want to
> open a non-existing buffer/file. electric-indent-mode inserts the ^J
> verbatim instead of this.
Indeed, thanks. Can you make it a bug-report, so I don't forget?
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-17 18:30 ` electric-pair-mode Jorgen Schaefer
2013-11-17 21:12 ` electric-pair-mode Stefan Monnier
@ 2013-11-18 11:04 ` Xue Fuqiao
1 sibling, 0 replies; 19+ messages in thread
From: Xue Fuqiao @ 2013-11-18 11:04 UTC (permalink / raw)
To: Jorgen Schaefer; +Cc: Stefan Monnier, emacs-devel
On Mon, Nov 18, 2013 at 2:30 AM, Jorgen Schaefer <forcer@forcix.cx> wrote:
>> I'm thinking of enabling electric-pair-mode in Emacs-24.4, and I think
>> the best way to do that is to actually enable it and then deal with
>> the complaints. But that only works if the complaints are
>> sufficiently constructive.
>>
>> So, please try enabling it and report any annoyance you notice.
>> If you just plain don't like the feature, then just disable it.
>
> If this is about electric-PAIR-mode:
>
> Works nicely, except the default `electric-pair-inhibit-predicate'
> makes it so that {{ results in "{{_|_}", even though I'd expect
> "{{_|_}}".
Another problem:
In CPerl Mode (and maybe in other modes as well), for example, I'd
like to type:
print 'Hello World!';
When I press the first apostrophe character, Emacs only inserts one
apostrophe; when I press the second apostrophe, Emacs inserts two
apostrophes, which is very annoying. And I also found two other bugs
about electric-pair-mode in Debbugs.
--
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 19+ messages in thread
* electric-indent-mode (was: electric-pair-mode)
2013-11-16 23:27 electric-pair-mode Stefan Monnier
2013-11-17 3:10 ` electric-pair-mode Xue Fuqiao
2013-11-17 18:30 ` electric-pair-mode Jorgen Schaefer
@ 2013-11-17 21:05 ` Stefan Monnier
2013-11-19 9:48 ` electric-indent-mode (was electric-pair-mode) Stephen Berman
2013-11-21 13:48 ` electric-pair-mode Tassilo Horn
4 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2013-11-17 21:05 UTC (permalink / raw)
To: emacs-devel
> AFAIK, most of the issues pointed out in the previous electric-pair-mode
> have been resolved:
> E.g. C-j and (newline) now insert a plain newline. Some indentation
> functions are marked as "unable to reindent".
In case some of you aren't confused enough yet: I really meant
"electric-indent-mode", not electric-pair-mode!
Sorry,
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* electric-indent-mode (was Re: electric-pair-mode)
2013-11-16 23:27 electric-pair-mode Stefan Monnier
` (2 preceding siblings ...)
2013-11-17 21:05 ` electric-indent-mode (was: electric-pair-mode) Stefan Monnier
@ 2013-11-19 9:48 ` Stephen Berman
2013-11-19 13:41 ` Stefan Monnier
2013-11-21 13:48 ` electric-pair-mode Tassilo Horn
4 siblings, 1 reply; 19+ messages in thread
From: Stephen Berman @ 2013-11-19 9:48 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On Sat, 16 Nov 2013 18:27:30 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> AFAIK, most of the issues pointed out in the previous electric-pair-mode
> have been resolved:
> E.g. C-j and (newline) now insert a plain newline. Some indentation
> functions are marked as "unable to reindent".
>
> I'm thinking of enabling electric-pair-mode in Emacs-24.4, and I think
> the best way to do that is to actually enable it and then deal with the
> complaints. But that only works if the complaints are
> sufficiently constructive.
>
> So, please try enabling it and report any annoyance you notice.
Will there be a new key binding for eval-print-last-sexp in *scratch*?
Steve Berman
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-16 23:27 electric-pair-mode Stefan Monnier
` (3 preceding siblings ...)
2013-11-19 9:48 ` electric-indent-mode (was electric-pair-mode) Stephen Berman
@ 2013-11-21 13:48 ` Tassilo Horn
2013-11-22 1:13 ` electric-pair-mode Stefan Monnier
4 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2013-11-21 13:48 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> So, please try enabling it and report any annoyance you notice. If
> you just plain don't like the feature, then just disable it.
No annoyance so far but I'm wondering why both `electric-pair-mode' and
`electric-indent-mode' are *global* minor modes.
For example, in all kinds of lisp modes I'm using paredit which provides
both features, too, in a slightly different form. So there I wouldn't
want to activate these modes (although it seems having them activated
doesn't do any harm).
Bye,
Tassilo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-21 13:48 ` electric-pair-mode Tassilo Horn
@ 2013-11-22 1:13 ` Stefan Monnier
2013-11-22 13:20 ` electric-pair-mode Alexander Baier
2013-11-29 7:01 ` electric-pair-mode Tassilo Horn
0 siblings, 2 replies; 19+ messages in thread
From: Stefan Monnier @ 2013-11-22 1:13 UTC (permalink / raw)
To: emacs-devel
> No annoyance so far but I'm wondering why both `electric-pair-mode' and
> `electric-indent-mode' are *global* minor modes.
Because in my experience, most people who like those features, like
them everywhere.
> For example, in all kinds of lisp modes I'm using paredit which
> provides both features, too, in a slightly different form. So there
> I wouldn't want to activate these modes (although it seems having them
> activated doesn't do any harm).
Looks like there's no problem, then.
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 1:13 ` electric-pair-mode Stefan Monnier
@ 2013-11-22 13:20 ` Alexander Baier
2013-11-22 19:13 ` electric-pair-mode Tassilo Horn
2013-11-29 7:01 ` electric-pair-mode Tassilo Horn
1 sibling, 1 reply; 19+ messages in thread
From: Alexander Baier @ 2013-11-22 13:20 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> No annoyance so far but I'm wondering why both `electric-pair-mode' and
>> `electric-indent-mode' are *global* minor modes.
>
> Because in my experience, most people who like those features, like
> them everywhere.
>
>> For example, in all kinds of lisp modes I'm using paredit which
>> provides both features, too, in a slightly different form. So there
>> I wouldn't want to activate these modes (although it seems having them
>> activated doesn't do any harm).
>
> Looks like there's no problem, then.
>
In my experience electric-indent-mode screws up indentation in
python-mode buffers:
----------------------------------------------------------------
def foo(x):
print (x)
def bar ():|
----------------------------------------------------------------
Put this content into a buffer and turn on python-mode and
electric-indent-mode. Put the cursor where the "|" is and press RET.
On my machine the "def bar():" gets reindented so it lines up with the
preceding "print(x):" line. This is usually not what you want.
>
> Stefan
Regards,
Alex
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 13:20 ` electric-pair-mode Alexander Baier
@ 2013-11-22 19:13 ` Tassilo Horn
2013-11-22 20:35 ` electric-pair-mode Alexander Baier
0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2013-11-22 19:13 UTC (permalink / raw)
To: Alexander Baier; +Cc: emacs-devel
Alexander Baier <lexi.baier@gmail.com> writes:
>>> For example, in all kinds of lisp modes I'm using paredit which
>>> provides both features, too, in a slightly different form. So there
>>> I wouldn't want to activate these modes (although it seems having them
>>> activated doesn't do any harm).
>>
>> Looks like there's no problem, then.
>
> In my experience electric-indent-mode screws up indentation in
> python-mode buffers:
That's the purpose of:
,----[ C-h v electric-indent-inhibit RET ]
| electric-indent-inhibit is a variable defined in `electric.el'.
| Its value is nil
|
| Automatically becomes buffer-local when set.
|
| Documentation:
| If non-nil, reindentation is not appropriate for this buffer.
| This should be set by major modes such as `python-mode' since
| Python does not lend itself to fully automatic indentation.
`----
In the current trunk, `python-mode' sets that to t.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 19:13 ` electric-pair-mode Tassilo Horn
@ 2013-11-22 20:35 ` Alexander Baier
2013-11-22 21:09 ` electric-pair-mode Tassilo Horn
2013-11-23 1:53 ` electric-pair-mode Stefan Monnier
0 siblings, 2 replies; 19+ messages in thread
From: Alexander Baier @ 2013-11-22 20:35 UTC (permalink / raw)
To: emacs-devel
Tassilo Horn <tsdh@gnu.org> writes:
> Alexander Baier <lexi.baier@gmail.com> writes:
>
>>>> For example, in all kinds of lisp modes I'm using paredit which
>>>> provides both features, too, in a slightly different form. So there
>>>> I wouldn't want to activate these modes (although it seems having them
>>>> activated doesn't do any harm).
>>>
>>> Looks like there's no problem, then.
>>
>> In my experience electric-indent-mode screws up indentation in
>> python-mode buffers:
>
> That's the purpose of:
>
> ,----[ C-h v electric-indent-inhibit RET ]
> | electric-indent-inhibit is a variable defined in `electric.el'.
> | Its value is nil
> |
> | Automatically becomes buffer-local when set.
> |
> | Documentation:
> | If non-nil, reindentation is not appropriate for this buffer.
> | This should be set by major modes such as `python-mode' since
> | Python does not lend itself to fully automatic indentation.
> `----
>
> In the current trunk, `python-mode' sets that to t.
>
> Bye,
> Tassilo
Thank you, I did not know about this. I am still running 24.3, which
does not offer this. I will add this to my config as soon as 24.4 is
released.
Regards,
Alex
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 20:35 ` electric-pair-mode Alexander Baier
@ 2013-11-22 21:09 ` Tassilo Horn
2013-11-23 1:53 ` electric-pair-mode Stefan Monnier
1 sibling, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2013-11-22 21:09 UTC (permalink / raw)
To: Alexander Baier; +Cc: emacs-devel
Alexander Baier <lexi.baier@gmail.com> writes:
Hi Alex,
>>> In my experience electric-indent-mode screws up indentation in
>>> python-mode buffers:
>>
>> That's the purpose of:
>>
>> ,----[ C-h v electric-indent-inhibit RET ]
>> | electric-indent-inhibit is a variable defined in `electric.el'.
>> | Its value is nil
>> |
>> | Automatically becomes buffer-local when set.
>> |
>> | Documentation:
>> | If non-nil, reindentation is not appropriate for this buffer.
>> | This should be set by major modes such as `python-mode' since
>> | Python does not lend itself to fully automatic indentation.
>> `----
>>
>> In the current trunk, `python-mode' sets that to t.
>
> Thank you, I did not know about this. I am still running 24.3, which
> does not offer this. I will add this to my config as soon as 24.4 is
> released.
You don't need to configure anything. With 24.4, it'll work correct out
of the box.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 20:35 ` electric-pair-mode Alexander Baier
2013-11-22 21:09 ` electric-pair-mode Tassilo Horn
@ 2013-11-23 1:53 ` Stefan Monnier
1 sibling, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2013-11-23 1:53 UTC (permalink / raw)
To: Alexander Baier; +Cc: emacs-devel
> I am still running 24.3
The 24.3 version of electric-indent-mode is definitely not fit for being
enabled by default. If you want to help with it, use the latest trunk
code: that code is meant to be "good enough to be enabled by default".
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-22 1:13 ` electric-pair-mode Stefan Monnier
2013-11-22 13:20 ` electric-pair-mode Alexander Baier
@ 2013-11-29 7:01 ` Tassilo Horn
2013-11-29 13:44 ` electric-pair-mode Stefan Monnier
1 sibling, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2013-11-29 7:01 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> For example, in all kinds of lisp modes I'm using paredit which
>> provides both features, too, in a slightly different form. So there
>> I wouldn't want to activate these modes (although it seems having
>> them activated doesn't do any harm).
>
> Looks like there's no problem, then.
Ok, now I've found a mode where it's a problem. AUCTeX has its own
TeX-ified brace pairing feature which for example knows that \left( has
to be closed by \right(, \{ by \}, etc. With `electric-pair-mode'
enabled, when typing a { I get two closing braces.
Right now, I have "disabled" `electric-pair-mode' for auctex using:
;; AUCTeX brace pairing feature doesn't play nice with `electric-pair-mode'
;; which is a global minor mode as of emacs 24.4.
(when (and (boundp 'electric-pair-mode)
(boundp 'electric-pair-inhibit-predicate))
(set (make-local-variable 'electric-pair-inhibit-predicate)
(lambda (char) t))))
Is that the way it's supposed to be done?
I somehow have the feeling that `electric-pair-mode' should only do its
magic if the opening paren/brace/bracket is inserted with
`self-insert-command'. For modes that bind ({[ to special commands
(like paredit and auctex), chances are high that you get some
interference with whatever special logic the mode does. On the other
hand, there doesn't seem to be a problem with paredit, so maybe we're
just doing something wrong in auctex...
Bye,
Tassilo
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-29 7:01 ` electric-pair-mode Tassilo Horn
@ 2013-11-29 13:44 ` Stefan Monnier
2013-11-29 17:10 ` electric-pair-mode Tassilo Horn
0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2013-11-29 13:44 UTC (permalink / raw)
To: emacs-devel
> Ok, now I've found a mode where it's a problem. AUCTeX has its own
> TeX-ified brace pairing feature which for example knows that \left( has
> to be closed by \right(, \{ by \}, etc. With `electric-pair-mode'
> enabled, when typing a { I get two closing braces.
Yes, that is a problem. AUCTeX's pairing should be made aware of
electric-pair-mode (including being enabled/disabled by
calling/setting electric-pair-mode as well).
> Right now, I have "disabled" `electric-pair-mode' for auctex using:
> ;; AUCTeX brace pairing feature doesn't play nice with `electric-pair-mode'
> ;; which is a global minor mode as of emacs 24.4.
> (when (and (boundp 'electric-pair-mode)
> (boundp 'electric-pair-inhibit-predicate))
> (set (make-local-variable 'electric-pair-inhibit-predicate)
> (lambda (char) t))))
A simpler way to disable it is to set electric-pair-mode to nil
(buffer-locally). No need to check boundp of anything.
> I somehow have the feeling that `electric-pair-mode' should only do its
> magic if the opening paren/brace/bracket is inserted with
> `self-insert-command'.
What happens is that AUCTeX's pairing commands call self-insert-command.
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: electric-pair-mode
2013-11-29 13:44 ` electric-pair-mode Stefan Monnier
@ 2013-11-29 17:10 ` Tassilo Horn
0 siblings, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2013-11-29 17:10 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Ok, now I've found a mode where it's a problem. AUCTeX has its own
>> TeX-ified brace pairing feature which for example knows that \left(
>> has to be closed by \right(, \{ by \}, etc. With
>> `electric-pair-mode' enabled, when typing a { I get two closing
>> braces.
>
> Yes, that is a problem. AUCTeX's pairing should be made aware of
> electric-pair-mode (including being enabled/disabled by
> calling/setting electric-pair-mode as well).
>
>> Right now, I have "disabled" `electric-pair-mode' for auctex using:
>
>> ;; AUCTeX brace pairing feature doesn't play nice with `electric-pair-mode'
>> ;; which is a global minor mode as of emacs 24.4.
>> (when (and (boundp 'electric-pair-mode)
>> (boundp 'electric-pair-inhibit-predicate))
>> (set (make-local-variable 'electric-pair-inhibit-predicate)
>> (lambda (char) t))))
>
> A simpler way to disable it is to set electric-pair-mode to nil
> (buffer-locally). No need to check boundp of anything.
Ah, that's indeed much better.
Thanks,
Tassilo
^ permalink raw reply [flat|nested] 19+ messages in thread