From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) Newsgroups: gmane.emacs.devel Subject: Re: [patch] make electric-pair-mode smarter/more useful Date: Sat, 07 Dec 2013 21:01:30 +0000 Message-ID: <87fvq49xzp.fsf@gmail.com> References: <87haalh806.fsf@gmail.com> <87d2l9wfne.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386450177 11822 80.91.229.3 (7 Dec 2013 21:02:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Dec 2013 21:02:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 07 22:03:02 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VpP1h-000585-Bj for ged-emacs-devel@m.gmane.org; Sat, 07 Dec 2013 22:03:01 +0100 Original-Received: from localhost ([::1]:37384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpP1h-0001nh-0W for ged-emacs-devel@m.gmane.org; Sat, 07 Dec 2013 16:03:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpP1Z-0001nB-Cp for emacs-devel@gnu.org; Sat, 07 Dec 2013 16:02:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VpP1T-0003Xz-J0 for emacs-devel@gnu.org; Sat, 07 Dec 2013 16:02:53 -0500 Original-Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:37711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VpP1T-0003Xn-CT for emacs-devel@gnu.org; Sat, 07 Dec 2013 16:02:47 -0500 Original-Received: by mail-we0-f173.google.com with SMTP id u57so2059264wes.32 for ; Sat, 07 Dec 2013 13:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:wfrom:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=YPrHTtHAHHYjdDLWklQwSGJFaCo6fxjH/aDisCFhbrM=; b=HeF3RmZ3rW8m5pfY6q/J0PA6hDKe5PSiA3tgA8BAWq+Xa90RXT27kzbSHvDIrLorI0 43dieUWlStm6SKjOaNigduWa0Md2ohQ6eGIOVbPebyJ9mvvt4ZiIIjOITkXdNwzKze4u 2ErD/oQxl1/Mo2GKQO0vOYetumTDn88TescgyVqy05PtmQ4qbXffVJRI6OmobhMvzMuC jNHB2enknvKfsB8XZE2CgW17HRak6Veb/ds+4adHsUATJ1TPKTjiT3kaTaRnL+CjF/KF Eg9tdVwlrGHQy/6IkBO7bx+WjOtRzGeIi1WVp7N7tsHjpqI9+fhKo85t58rxl3xUuHEQ 0s7Q== X-Received: by 10.180.189.6 with SMTP id ge6mr7965810wic.1.1386450166347; Sat, 07 Dec 2013 13:02:46 -0800 (PST) Original-Received: from kitaj.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id x4sm8780378wif.0.2013.12.07.13.02.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 07 Dec 2013 13:02:45 -0800 (PST) WFrom: joaotavora@gmail.com =?utf-8?Q?=28Jo=C3=A3o_T=C3=A1vora=29?= In-Reply-To: <87d2l9wfne.fsf@yandex.ru> (Dmitry Gutov's message of "Sat, 07 Dec 2013 04:36:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:166189 Archived-At: Dmitry Gutov 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 () (save-excursion (skip-chars-backward " \t\n") (backward-char) (when (looking-at "([ \t\n]*)") 'after))) 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 electric-pair-mode - 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.