[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] make electric-pair-mode smarter/more useful

From: João Távora
Subject: Re: [patch] make electric-pair-mode smarter/more useful
Date: Sat, 07 Dec 2013 21:01:30 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Dmitry Gutov <address@hidden> writes:

> Autobackspacing two adjacent parens sounds good.

How should one approach this in electric.el? Should a hook be added to
`backward-delete-char-untabify`? Should this be included in the
`electric-layout-mode' somehow?

> I'm also partial to the `autopair-newline' feature. It would probably
> serve best as an extension of `electric-layout-mode'.

Yes, I agree that `electric-layout-mode' seems the place for this, but
how to write these rules in the existing `electric-layout-rules' var? It
seems a little too rigid, I couldn't make much sense of it.

(add-to-list 'electric-layout-rules
                 `(,(aref "\n" 0)  . electric-layout-in-between-parenthesis))

    (defun electric-layout-in-between-parenthesis ()
        (skip-chars-backward " \t\n")
        (when (looking-at "([ \t\n]*)")

But it didn't really work... inserting "\n" between "()" leaves point
after the two newlines, not inside as intended. It would need to return
'after-then-back or something. Also, an undo after this doesn't restore
the "()" state... In general, looking at the code and reading the
comments, this might need to be enhanced considerably.

Also, regarding the autowrapping feature already found in electric.el's

- I found (and reported) a bug when using cua-mode with it
- both openers and closers should cause a wrap (currently only
  openers do). A closer should move point to after the wrapping.
- additionally one should be able to customize if points ends up
  inside or outside the wrapped region.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]