From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: auto indenting code blocks Date: Sat, 13 Jun 2015 19:14:38 +0600 Message-ID: References: <43ca5eee-94a4-47f3-8b69-3af8a38227cd@googlegroups.com> <87616rlt63.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1434201317 1886 80.91.229.3 (13 Jun 2015 13:15:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Jun 2015 13:15:17 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 13 15:15:16 2015 Return-path: Envelope-to: geh-help-gnu-emacs@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 1Z3lHH-00036B-T9 for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Jun 2015 15:15:16 +0200 Original-Received: from localhost ([::1]:55928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3lHH-0005Ke-AI for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Jun 2015 09:15:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3lH3-0005J4-AT for help-gnu-emacs@gnu.org; Sat, 13 Jun 2015 09:15:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3lH2-0003I1-9p for help-gnu-emacs@gnu.org; Sat, 13 Jun 2015 09:15:01 -0400 Original-Received: from mail-la0-x232.google.com ([2a00:1450:4010:c03::232]:36436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3lH2-0003Hh-1A for help-gnu-emacs@gnu.org; Sat, 13 Jun 2015 09:15:00 -0400 Original-Received: by lacny3 with SMTP id ny3so14270006lac.3 for ; Sat, 13 Jun 2015 06:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=c+tT6gRH61eee/WTuYpbv1lE05A0MwV5+QYSWmp0e/k=; b=NZe1v2Kn3OK6Ly5AJ0+dJNMMUjCD89Vk5QZL8N/m8N17/XGHG7ylPAT1Gaqahd+J2Y hWzWGogOueIQ3pZVAtckqohjx2m9MVlx/pHx4LgG4FjDfx2Qak/2pgHTqEk6MAn0Hvsc jWqraNjmfsN2V+mB2wSUxf/CV517ULO30ez6q9JJhXwUxlYf99Lr3Cc6Bd2/tqOWhoQp DcLXCuEDXF4dKo40mqeZ2FCPSJvz6mgCsaG9sZSfQMehJR1jHgS63zknPoB3OHazUtHQ wY0v/yycVCossiQI147biBPjuVHisb5bg1Ode45JBjLVDEDaf4wk2Hka2Zz/fFhJuVJD srqw== X-Received: by 10.112.140.231 with SMTP id rj7mr19226793lbb.76.1434201299339; Sat, 13 Jun 2015 06:14:59 -0700 (PDT) Original-Received: by 10.25.43.65 with HTTP; Sat, 13 Jun 2015 06:14:38 -0700 (PDT) In-Reply-To: <87616rlt63.fsf@web.de> X-Google-Sender-Auth: aTHRkIKSavp7PpYBn2jSzz56PZY X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::232 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104915 Archived-At: On Sat, Jun 13, 2015 at 5:55 PM, Michael Heerdegen wrote: > Shouldn't `electric-indent-mode' be able to do this? Maybe it should, but it does not for me. $ emacs --version GNU Emacs 24.4.1 [=E2=80=A6] $ emacs -Q M-: (add-to-list 'load-path "~/.emacs.d/dash.el") ;; as of github:magnars/dash.el tag 2.10.0 M-: (add-to-list 'load-path "~/.emacs.d/smartparens") ;; as of github:Fuco1/smartparens.git commit 8d22a6b M-x load-library smartparens-config M-x smartparens-global-mode M-x load-library cc-mode M-: (setq c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "stroustrup"))) C-x C-f ~/test.cpp ;; where the file does not exist Now I start typing: =3D=3D=3D int main(| =3D=3D=3D As soon as I type the opening parenthesis, smartparens adds a matching closing parenthesis after the point: =3D=3D=3D int main(|) =3D=3D=3D I press End to get out of parentheses and then press Enter to start a new l= ine: =3D=3D=3D int main() | =3D=3D=3D I press =E2=80=9C{=E2=80=9D. smartparens adds a matching closing brace. electric-indent-mode unindents the newly inserted pair of braces to the level of =E2=80=9Cint=E2=80=9D: =3D=3D=3D int main() {|} =3D=3D=3D (1) I press Enter. Nothing special happens: =3D=3D=3D int main() { |} =3D=3D=3D (2) I press Enter again. Nothing special happens again: =3D=3D=3D int main() { |} =3D=3D=3D The behavior does not change if I use Ctrl+J instead of Enter. If at point (2) I go to the end of the line with the opening brace and press Enter, or if at point (1) I press Ctrl+O and then Enter, then I get the desired function skeleton: =3D=3D=3D int main() { | } =3D=3D=3D But those are not key sequences I=E2=80=99d like to repeat every time. If I forgo smartparens, then electric-indent-mode does indeed yield the desired sequence: =3D=3D=3D int main()| =3D=3D=3D Enter =3D=3D=3D int main() | =3D=3D=3D Opening brace =3D=3D=3D int main() {| =3D=3D=3D Enter =3D=3D=3D int main() { | =3D=3D=3D Some text =3D=3D=3D int main() { std::cout << "Hello World\n";| =3D=3D=3D Enter =3D=3D=3D int main() { std::cout << "Hello World\n"; | =3D=3D=3D Closing brace =3D=3D=3D int main() { std::cout << "Hello World\n"; }| =3D=3D=3D However, smartparens is too convenient to give up.