all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: joaotavora@gmail.com (João Távora)
Cc: emacs-devel@gnu.org
Subject: Re: [patch] make electric-pair-mode smarter/more useful
Date: Sat, 07 Dec 2013 18:07:21 -0500	[thread overview]
Message-ID: <jwvwqjg6zg5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87haalh806.fsf@gmail.com> ("João Távora"'s message of "Fri, 06 Dec 2013 23:31:05 +0000")

> In a recent cleanup I did of my autopair.el library [1], I decided to
> try and add one of its core features to emacs's built-in
> `electric-pair-mode' and make it the default behaviour.

Thank you, very appreciated.

> The feature was surprisingly easy to implement using the existing
> `electric-pair-inhibit-predicate' customization variable and only
> slightly changing the semantics of the existing
> `electric-pair-skip-self` variable.

Overall, the integration looks very good, indeed.

> +(defun electric-pair--pair-of (char)
> +  "Return pair of CHAR if it has parenthesis or delimiter syntax."
> +  (and (memq (char-syntax char) '(?\( ?\) ?\" ?\$))
> +       (cdr (aref (syntax-table) char))))

Hmmm... the existing code already has such a functionality.  Can you try
and use your new function in that code, or somehow merge the two?

> +(defun electric-pair--up-list (&optional n)
> +  "Try to up-list forward as much as N lists.
> +
> +With negative N, up-list backward. N default to `point-max'.
> +
> +Return a cons of two descritions (MATCHED START END) for the
> +innermost and outermost lists that enclose point. The outermost
> +list enclosing point is either the first top-level or mismatched
> +list found by uplisting."

Could you try and use up-list, instead?
Also, you can find the START of all enclosing lists in (nth
9 (syntax-ppss)), which seems like it might be helpful here.

It would be good to try and avoid moving all the way to the START or END
of the outermost list, since that may require scanning the whole buffer,
which in pathological cases will make the feature slow.  Maybe using
syntax-ppss could help us avoid those pathological cases (since
syntax-ppss uses a cache to avoid re-scanning).


        Stefan



  parent reply	other threads:[~2013-12-07 23:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 23:31 [patch] make electric-pair-mode smarter/more useful João Távora
2013-12-07  2:09 ` Leo Liu
2013-12-07  2:36 ` Dmitry Gutov
2013-12-07 21:01   ` João Távora
2013-12-07 23:16     ` Stefan Monnier
2013-12-12  3:05       ` João Távora
2013-12-12  4:29         ` Dmitry Gutov
2013-12-12 11:26           ` João Távora
2013-12-12 16:30           ` Stefan Monnier
2013-12-12 17:06             ` João Távora
2013-12-12 20:12               ` Stefan Monnier
2013-12-13  2:55               ` Dmitry Gutov
2013-12-14 15:18                 ` Stefan Monnier
2013-12-14 16:56                   ` Dmitry Gutov
2013-12-15  1:39                     ` Stefan Monnier
2013-12-16  0:35                       ` João Távora
2013-12-16  3:34                         ` Stefan Monnier
2013-12-16 19:26                           ` João Távora
2013-12-17  1:54                             ` Stefan Monnier
2013-12-18  2:43                               ` João Távora
2013-12-18 15:32                                 ` João Távora
2013-12-23 14:41                                   ` João Távora
2013-12-24 14:29                                     ` Bozhidar Batsov
2013-12-07 23:07 ` Stefan Monnier [this message]
2013-12-12  3:01   ` João Távora
2013-12-12 18:08     ` Stefan Monnier
2013-12-13  1:02       ` João Távora
2013-12-13  2:32         ` Stefan Monnier
2013-12-15 22:10           ` João Távora
2013-12-16  3:22             ` Stefan Monnier
2013-12-16 14:21               ` João Távora
2013-12-16 15:30                 ` Stefan Monnier
2013-12-16 18:40                   ` Stefan Monnier
2013-12-16 19:06                     ` João Távora
2013-12-17  1:42                       ` Stefan Monnier
     [not found]                   ` <CALDnm52AoShN891-L9=Cbng98UtYPEntzO+n_XDMmEL+UV0r-A@mail.gmail.com>
2013-12-16 19:02                     ` Fwd: " João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwqjg6zg5.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.