From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dave Abrahams Newsgroups: gmane.emacs.bugs Subject: bug#15767: closed (Re: bug#15767: 24.3; [patch] electric-indent-mode bug) Date: Mon, 4 Nov 2013 21:06:33 -0800 Message-ID: <04CD2009-757D-471D-8338-325882009851@boostpro.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_49F9BE8B-38F4-42EC-BAC3-3E0D74739C67" X-Trace: ger.gmane.org 1383628040 5749 80.91.229.3 (5 Nov 2013 05:07:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Nov 2013 05:07:20 +0000 (UTC) To: 15767@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 05 06:07:22 2013 Return-path: Envelope-to: geb-bug-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 1VdYrG-0005WL-1W for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2013 06:07:18 +0100 Original-Received: from localhost ([::1]:53304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdYrF-0000pf-2U for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2013 00:07:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdYr6-0000pQ-5R for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2013 00:07:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdYr1-0003B0-90 for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2013 00:07:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdYr1-0003Am-3y for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2013 00:07:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VdYr0-0004Sq-Gm for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2013 00:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dave Abrahams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Nov 2013 05:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15767 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 15767-submit@debbugs.gnu.org id=B15767.138362801217144 (code B ref 15767); Tue, 05 Nov 2013 05:07:02 +0000 Original-Received: (at 15767) by debbugs.gnu.org; 5 Nov 2013 05:06:52 +0000 Original-Received: from localhost ([127.0.0.1]:34921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdYqo-0004SQ-N7 for submit@debbugs.gnu.org; Tue, 05 Nov 2013 00:06:52 -0500 Original-Received: from mail-ie0-f174.google.com ([209.85.223.174]:48090) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdYqk-0004SB-Lm for 15767@debbugs.gnu.org; Tue, 05 Nov 2013 00:06:49 -0500 Original-Received: by mail-ie0-f174.google.com with SMTP id qd12so14097496ieb.5 for <15767@debbugs.gnu.org>; Mon, 04 Nov 2013 21:06:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=DsSbF+RtRseYRJHhEkIH94cWdEXZjhByPMXqQ856rkQ=; b=PehdOcCcLKKT4MG6FeFtJJEtpLD7SjHzzbyj4hJYpZbiuP/zdGSKBqEXMKZJLKGjZj KOdlvZ5g37Jtg0rQAzBTtp3N3kOL4uBEmVfK0/OxNmRaxawqD8M/V47IqdZ7tk5n0zVh 3UJxK9EqYP2k8OwY69DkN1fWADpj1KX3pUwcSz+jS0+/guYPC2r5eUOYepW5xU+hyME4 030hl0eOhHoUHUfrmne75fVjdxqgA9KfsH0Vjsq/hslqhXW034eM615h1N7FUIE4fbhQ E3UyHN2wRfO0FjaScj6iI6NZaoJXk4IJROPxtdomPXomfNk0TQk7fj6Z+L1nIrdwQM0B 4d5A== X-Gm-Message-State: ALoCoQmRe3qm9asldsF16x+b2Gyrfnsq7AHXS7kT2k0dLU2G91MIOXtVBtQQbIwwmxyKSqovORVo X-Received: by 10.50.13.104 with SMTP id g8mr14661517igc.30.1383627999998; Mon, 04 Nov 2013 21:06:39 -0800 (PST) Original-Received: from papi.luannocracy.com (107-219-149-247.lightspeed.sntcca.sbcglobal.net. [107.219.149.247]) by mx.google.com with ESMTPSA id q6sm19949839igi.0.2013.11.04.21.06.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Nov 2013 21:06:35 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.1822) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80010 Archived-At: --Apple-Mail=_49F9BE8B-38F4-42EC-BAC3-3E0D74739C67 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Nov 4, 2013, at 12:05 PM, GNU bug Tracking System = wrote: > Your bug report >=20 > #15767: 24.3; [patch] electric-indent-mode bug >=20 > which was filed against the emacs package, has been closed. >=20 > The explanation is attached below, along with your original report. > If you require more details, please reply to 15767@debbugs.gnu.org. >=20 > --=20 > 15767: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15767 > GNU Bug Tracking System > Contact help-debbugs@gnu.org with problems >=20 > From: Stefan Monnier > Subject: Re: bug#15767: 24.3; [patch] electric-indent-mode bug > Date: November 4, 2013 at 12:04:31 PM PST > To: Dave Abrahams > Cc: 15767-done@debbugs.gnu.org >=20 >=20 >> (electric-indent-mode) >> (electric-layout-mode) >> (setq electric-indent-chars (append "{}" electric-indent-chars)) >> (setq electric-layout-rules '((?\{ . after) (?\} . before))) >=20 >> 3. type `f o o SPC {' >=20 > Thanks. Your patch defeated a useful case, so I replaced it with the > one below, Well, the problem I see is that you left the call to = line-beginning-position where it was in the original call. At that = point, point may be on a different line than it started on, so it=92s = actually getting information about the wrong line. It=92s possible that = your patch somehow makes everything work out, but leaving the call to = line-beginning-position where it is seems at best fragile to me. =20 >=20 > Stefan >=20 >=20 > --- lisp/electric.el 2013-10-07 18:51:26 +0000 > +++ lisp/electric.el 2013-11-04 20:01:20 +0000 > @@ -251,9 +251,10 @@ > ;; whereas we need `move after insertion', so we do the > ;; save/restore by hand. > (goto-char before) > + (when (eolp) > ;; Remove the trailing whitespace after indentation = because > ;; indentation may (re)introduce the whitespace. > - (delete-horizontal-space t)))) > + (delete-horizontal-space t))))) > (unless (or (memq indent-line-function '(indent-to-left-margin)) > (and electric-indent-inhibit > (> pos (line-beginning-position)))) >=20 >=20 >=20 >=20 > From: Dave Abrahams > Subject: 24.3; [patch] electric-indent-mode bug > Date: October 30, 2013 at 4:03:34 PM PDT > To: bug-gnu-emacs@gnu.org >=20 >=20 >=20 > 1. emacs -Q > 2. eval the following: >=20 > (electric-indent-mode) > (electric-layout-mode) > (setq electric-indent-chars (append "{}" electric-indent-chars)) > (setq electric-layout-rules '((?\{ . after) (?\} . before))) >=20 > 3. type `f o o {' >=20 > Result expected: a buffer containing > ----- schnipp ----- > foo { >=20 > ----- schnapp ----- >=20 > Result received: a buffer containing > ----- schnipp ----- > foo{ >=20 > ----- schnapp ----- >=20 > Patch is enclosed that fixes the problem. >=20 >=20 > diff --git a/lisp/electric.el b/lisp/electric.el > index 58b8e10..e4257b2 100644 > --- a/lisp/electric.el > +++ b/lisp/electric.el > @@ -212,7 +212,7 @@ point right after that char, and it should return = t to cause indentation, > ;; electric-pair-mode wrapping a region with a pair of parens. > ;; There might be a way to get it working by analyzing = buffer-undo-list, but > ;; it looks challenging. > - (let (pos) > + (let (pos line-beginning-pos) > (when (and > electric-indent-mode > ;; Don't reindent while inserting spaces at beginning of = line. > @@ -221,6 +221,7 @@ point right after that char, and it should return = t to cause indentation, > (setq pos (electric--after-char-pos)) > (save-excursion > (goto-char pos) > + (setq line-beginning-pos (line-beginning-position)) > (let ((act (or (run-hook-with-args-until-success > 'electric-indent-functions > last-command-event) > @@ -231,7 +232,7 @@ point right after that char, and it should return = t to cause indentation, > (unless (eq act 'do-indent) (nth 8 = (syntax-ppss)))))))) > ;; For newline, we want to reindent both lines and basically = behave like > ;; reindent-then-newline-and-indent (whose code we hence = copied). > - (when (< (1- pos) (line-beginning-position)) > + (when (< (1- pos) line-beginning-pos) > (let ((before (copy-marker (1- pos) t))) > (save-excursion > (unless (memq indent-line-function >=20 >=20 >=20 > In GNU Emacs 24.3.1 (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 = AppKit 1138.51) > of 2013-10-27 on Yukikaze.local > Windowing system distributor `Apple Inc.', version 10.9.0 > Configured using: > `configure '--with-mac' > '--enable-mac-app=3D/Users/xin/Documents/emacs-mac-port/build' > '--prefix=3D/Users/xin/Documents/emacs-mac-port/build'' >=20 > Important settings: > locale-coding-system: utf-8-unix > default enable-multibyte-characters: t >=20 > Major mode: Emacs-Lisp >=20 > Minor modes in effect: > electric-layout-mode: t > electric-pair-mode: t > electric-indent-mode: t > shell-dirtrack-mode: t > recentf-mode: t > diff-auto-refine-mode: t > global-auto-complete-mode: t > auto-complete-mode: t > override-global-mode: t > workgroups-mode: t > nxhtml-menu-mode: t > yas-global-mode: t > yas-minor-mode: t > me-minor-mode: t > which-function-mode: t > show-paren-mode: t > server-mode: t > global-auto-revert-mode: t > display-time-mode: t > delete-selection-mode: t > tooltip-mode: t > mac-mouse-wheel-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t >=20 > Recent input: > C-e C-p C-p C-p C-p C-p C-p C-p C-p C-p C-b SPC l i=20 > n e - b e g g i n - p o s C-b C-b C-b C-b=20 > i n g b b =20 > n n i n g C-n C-e C-p C-e C-,=20 > C-, C-, C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n=20 > C-n C-n C-n C-n C-n C-n C-n C-e C-n C-b C-SPC C-, C-,=20 > C-, C-b M-w C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p=20 > C-p C-p C-p C-p C-p C-p C-p C-e C-n C-n C-n C-n C-n=20 > C-n C-e ( s e t q SPC l i n e - b e=20 > M-/ SPC C-y C-e C-n C-n C-n C-n C-n C-n C-n C-n C-n=20 > C-n C-n C-, C-, C-, C-. C-. C-. C-d =20 > C-x=20 > C-s C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n=20 > C-n C-n C-n C-n C-n C-n C-n C-n C-n C-e C-p C-p C-e=20 > C-n C-x C-e C-p C-e C-n =20 > SPC { C-SPC C-p=20 > C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p=20 > C-p C-g C-g C-g M-! g i t SPC d i f f =20 > C-s e l e C-p C-n C-n C-s e l e c t r i c C-a C-SPC=20 > C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n=20 > C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n=20 > C-n C-n C-n C-n M-w C-x C-b C-x C-b M-x=20 > e m a v c - =20 > r e p o r t - e=20 > m >=20 > Recent messages: > Mark set > Saving file /Users/dave/src/emacs-mac-port/lisp/electric.el... > Wrote /Users/dave/src/emacs-mac-port/lisp/electric.el > electric-indent-post-self-insert-function > Mark set > Quit [3 times] > Mark saved where search started [2 times] > Mark set > delete-backward-char: Text is read-only > Loading = /Users/dave/.emacs.d/el-get/dwamacs/settings/message-settings.el = (source)...done >=20 > Load-path shadows: > /Users/dave/.emacs.d/el-get/php-mode/php-mode hides = /Users/dave/.emacs.d/el-get/nxhtml/related/php-mode > /Users/dave/.emacs.d/el-get/nxhtml/related/csharp-mode hides = /Users/dave/.emacs.d/el-get/csharp-mode/csharp-mode > /Users/dave/.emacs.d/el-get/cedet/lisp/speedbar/loaddefs hides = /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/loaddefs > /Users/dave/.emacs.d/el-get/cedet/lisp/speedbar/loaddefs hides = /Users/dave/.emacs.d/el-get/cedet/lisp/cedet/loaddefs > /Users/dave/.emacs.d/el-get/magit/.dir-locals hides = /Users/dave/.emacs.d/el-get/el-get/.dir-locals > /Users/dave/.emacs.d/el-get/cedet/lisp/speedbar/loaddefs hides = /Applications/Emacs.app/Contents/Resources/lisp/loaddefs > /Users/dave/.emacs.d/el-get/dwamacs/site-lisp/ediff-util hides = /Applications/Emacs.app/Contents/Resources/lisp/vc/ediff-util > /Users/dave/.emacs.d/el-get/python/python hides = /Applications/Emacs.app/Contents/Resources/lisp/progmodes/python > /Users/dave/.emacs.d/el-get/dwamacs/site-lisp/compile hides = /Applications/Emacs.app/Contents/Resources/lisp/progmodes/compile > /Users/dave/.emacs.d/el-get/nxhtml/util/org-odt hides = /Applications/Emacs.app/Contents/Resources/lisp/org/org-odt > /Users/dave/.emacs.d/el-get/magit/.dir-locals hides = /Applications/Emacs.app/Contents/Resources/lisp/gnus/.dir-locals > /Users/dave/.emacs.d/el-get/dwamacs/site-lisp/ert hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/ert > /Users/dave/.emacs.d/el-get/dwamacs/site-lisp/ert-x hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/ert-x > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-speedbar hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-speedbar > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-opt hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-opt > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-datadebug hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-datadebug= > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-custom hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-custom > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-base hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-base > /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/chart hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/chart >=20 > Features: > (shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec > mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils > mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils debug pcase > cedet-edebug edebug mule-util tabify electric cmake-mode thingatpt > dired-aux gnus-dired sh-script smie executable view dabbrev hl-line > shell pcomplete misearch multi-isearch magit-svn sticky-windows = recentf > tree-widget jka-compr sb-info info shiny-mode flymake compile comint > ansi-color auto-complete-clang-async magit-bisect magit-key-mode magit > diff-mode log-edit ring pcvs-util add-log proof-site proof-autoloads > pg-vars page-ext ffap url-parse auth-source gnus-util mm-util = mail-prsvr > password-cache url-vars auto-complete-config auto-complete popup > use-package bind-key session-settings session system-type-darwin-theme > osx-plist xml .loaddefs workgroups flymake-files flymakemsg > nxhtml-autostart nxhtml-autoload majmodpri vc-git nxhtml-menu > web-autoload nxhtml-base helm-config helm-aliases = fill-column-indicator > initsplit cus-edit diminish csharp-mode cc-langs rust-mode modal = cc-mode > cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine = cc-vars > cc-defs cm-mode cedet-devel-load warnings eieio-opt find-func > srecode/map semantic/edit srecode/srt-mode srecode/template > srecode/srt-wy semantic/wisent semantic/wisent/wisent srecode/ctxt > srecode/compile srecode/dictionary srecode/table srecode > semantic/canned-configs semantic/ia-sb semantic/analyze semantic/sort > semantic/scope semantic/analyze/fcn semantic/db semantic/ctxt > semantic/format semantic/tag-ls semantic/find semantic/util-modes > semantic/util semantic semantic/tag semantic/lex semantic/fw = mode-local > cedet-compat inversion ede/speedbar ede/files ede ede/base ede/auto > ede/source eieio-base eieio-speedbar speedbar sb-image ezimage dframe > eieio-custom wid-edit cedet eieio byte-opt eieio-core > cedet-remove-builtin yasnippet advice advice-preload dropdown-list > derived edmacro kmacro el-get el-get-autoloads el-get-list-packages > el-get-notify help-mode el-get-dependencies el-get-build el-get-status > pp el-get-recipes el-get-byte-compile el-get-methods el-get-fossil > el-get-svn el-get-pacman el-get-github-zip el-get-github-tar > el-get-http-zip el-get-http-tar el-get-hg el-get-git-svn el-get-fink > el-get-emacswiki el-get-http el-get-emacsmirror el-get-github = el-get-git > el-get-elpa package cl-macs gv el-get-darcs el-get-cvs el-get-bzr > el-get-brew el-get-builtin el-get-apt-get el-get-custom el-get-core > autoload help-fns bytecomp byte-compile cconv cl cl-lib dired-x = easymenu > dired easy-mmode which-func imenu paren server ido autorevert time > delsel cus-start cus-load elhome time-date tooltip ediff-hook vc-hooks > lisp-float-type mwheel mac-win tool-bar dnd fontset image regexp-opt > fringe tabulated-list newcomment lisp-mode register page menu-bar > rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax > facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese > tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak > czech european ethiopic indian cyrillic chinese case-table epa-hook > jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces > cus-face macroexp files text-properties overlay sha1 md5 base64 format > env code-pages mule custom widget hashtable-print-readable backquote = mac > multi-tty make-network-process emacs) >=20 >=20 --Apple-Mail=_49F9BE8B-38F4-42EC-BAC3-3E0D74739C67 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
On Nov 4, 2013, at 12:05 PM, GNU bug = Tracking System <help-debbugs@gnu.org> = wrote:

Your bug report

#15767: 24.3; [patch] = electric-indent-mode bug

which was filed against the emacs = package, has been closed.

The explanation is attached below, = along with your original report.
If you require more details, please = reply to 15767@debbugs.gnu.org.

--=
15767: http://debbu= gs.gnu.org/cgi/bugreport.cgi?bug=3D15767
GNU Bug Tracking = System
Contact help-debbugs@gnu.org with = problems

From: Stefan= Monnier <monnier@iro.umontreal.ca><= br>
Subject: Re: bug#15767: 24.3; [patch] = electric-indent-mode bug
Date: November 4, 2013 at 12:04:31 PM = PST
To: Dave = Abrahams <dave@boostpro.com>


=  (electric-indent-mode)
 (electric-layout-mode)
=  (setq electric-indent-chars (append "{}" = electric-indent-chars))
 (setq electric-layout-rules '((?\{ . = after) (?\} . before)))

3. = type `f o o SPC {'

Thanks.  Your patch defeated = a useful case, so I replaced it with the
one = below,


Well, the problem I = see is that you left the call to line-beginning-position where it was in = the original call.  At that point, point may be on a different line = than it started on, so it=92s actually getting information about the = wrong line.  It=92s possible that your patch somehow makes = everything work out, but leaving the call to line-beginning-position = where it is seems at best fragile to me.
 

=        Stefan


--- = lisp/electric.el = 2013-10-07 18:51:26 +0000
+++ lisp/electric.el = 2013-11-04 20:01:20 +0000
@@ -251,9 +251,10 @@
=             ;;= whereas we need `move after insertion', so we do the
=             ;;= save/restore by hand.
=             (g= oto-char before)
+    (when = (eolp)
=             ;;= Remove the trailing whitespace after indentation because
=             ;;= indentation may (re)introduce the whitespace.
- =            (delete-= horizontal-space t))))
+ =      (delete-horizontal-space t)))))
=       (unless (or (memq = indent-line-function '(indent-to-left-margin))
=             &n= bsp;     (and electric-indent-inhibit
=             &n= bsp;          (> = pos (line-beginning-position))))




From: Dave Abrahams <dave@boostpro.com>
Subject: 24.3; [patch] electric-indent-mode = bug
Date: October 30, 2013 at 4:03:34 PM = PDT



1. emacs -Q
2. eval the following:

=  (electric-indent-mode)
 (electric-layout-mode)
=  (setq electric-indent-chars (append "{}" = electric-indent-chars))
 (setq electric-layout-rules '((?\{ . = after) (?\} . before)))

3. type `f o o {'

Result expected: = a buffer containing
----- schnipp -----
foo {

----- schnapp = -----

Result received: a buffer containing
----- schnipp = -----
foo{

----- schnapp -----

Patch is enclosed that = fixes the problem.


diff --git a/lisp/electric.el = b/lisp/electric.el
index 58b8e10..e4257b2 100644
--- = a/lisp/electric.el
+++ b/lisp/electric.el
@@ -212,7 +212,7 @@ = point right after that char, and it should return t to cause = indentation,
  ;; electric-pair-mode wrapping a region = with a pair of parens.
  ;; There might be a way to get it = working by analyzing buffer-undo-list, but
  ;; it looks = challenging.
-  (let (pos)
+  (let (pos = line-beginning-pos)
    (when (and
=            electric= -indent-mode
=            ;; = Don't reindent while inserting spaces at beginning of line.
@@ -221,6 = +221,7 @@ point right after that char, and it should return t to cause = indentation,
=            (setq = pos (electric--after-char-pos))
=            (save-ex= cursion
=             &n= bsp;(goto-char pos)
+ =             (s= etq line-beginning-pos (line-beginning-position))
=             &n= bsp;(let ((act (or (run-hook-with-args-until-success
=             &n= bsp;           &nbs= p;    'electric-indent-functions
=             &n= bsp;           &nbs= p;    last-command-event)
@@ -231,7 +232,7 @@ = point right after that char, and it should return t to cause = indentation,
=             &n= bsp;       (unless (eq act = 'do-indent) (nth 8 (syntax-ppss))))))))
=       ;; For newline, we want to reindent = both lines and basically behave like
=       ;; reindent-then-newline-and-indent = (whose code we hence copied).
-      (when = (< (1- pos) (line-beginning-position))
+ =      (when (< (1- pos) = line-beginning-pos)
=         (let ((before = (copy-marker (1- pos) t)))
=           (save-excursio= n
=             (u= nless (memq indent-line-function



In GNU Emacs 24.3.1 = (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 AppKit 1138.51)
of = 2013-10-27 on Yukikaze.local
Windowing system distributor `Apple = Inc.', version 10.9.0
Configured using:
`configure = '--with-mac'
= '--enable-mac-app=3D/Users/xin/Documents/emacs-mac-port/build'
= '--prefix=3D/Users/xin/Documents/emacs-mac-port/build''

Important = settings:
 locale-coding-system: utf-8-unix
 default = enable-multibyte-characters: t

Major mode: = Emacs-Lisp

Minor modes in effect:
 electric-layout-mode: = t
 electric-pair-mode: t
 electric-indent-mode: t
=  shell-dirtrack-mode: t
 recentf-mode: t
=  diff-auto-refine-mode: t
 global-auto-complete-mode: = t
 auto-complete-mode: t
 override-global-mode: t
=  workgroups-mode: t
 nxhtml-menu-mode: t
=  yas-global-mode: t
 yas-minor-mode: t
=  me-minor-mode: t
 which-function-mode: t
=  show-paren-mode: t
 server-mode: t
=  global-auto-revert-mode: t
 display-time-mode: t
=  delete-selection-mode: t
 tooltip-mode: t
=  mac-mouse-wheel-mode: t
 menu-bar-mode: t
=  file-name-shadow-mode: t
 global-font-lock-mode: t
=  font-lock-mode: t
 auto-composition-mode: t
=  auto-encryption-mode: t
 auto-compression-mode: t
=  line-number-mode: t
 transient-mark-mode: t

Recent = input:
C-e C-p C-p C-p C-p C-p C-p C-p C-p C-p C-b SPC l i
n e - = b e g g <backspace> i n - p o s C-b C-b C-b C-b
i n g b b = <backspace> <backspace> <backspace> <backspace> =
<backspace> <backspace> n n i n g C-n C-e C-p C-e C-, =
C-, C-, C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n = C-n C-n C-n C-n C-e C-n C-b C-SPC C-, C-,
C-, C-b M-w C-p C-p C-p = C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-e C-n C-n = C-n C-n C-n
C-n C-e <return> <tab> ( s e t q SPC l i n e = - b e
M-/ SPC C-y C-e C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n = C-n C-, C-, C-, <backspace> C-. C-. C-. C-d <backspace> =
<backspace> <backspace> <backspace> = <backspace> C-x
C-s C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n = C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-e C-p C-p C-e
C-n = C-x C-e <C-return> C-p C-e C-n <backspace> <backspace> =
<backspace> <backspace> SPC { <C-return> C-SPC C-p =
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-g C-g = C-g M-! g i t SPC d i f f <return> <C-return>
C-s e l e = C-p C-n C-n C-s e l e c t r i c C-a C-SPC
C-n C-n C-n C-n C-n C-n = C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n = C-n C-n C-n
C-n C-n C-n C-n M-w <C-return> C-x C-b C-x C-b M-x =
e m a v <backspace> c - <backspace> <backspace> = <backspace>
<backspace> <backspace> = <backspace> r e p o r t - e
m <tab> = <return>

Recent messages:
Mark set
Saving file = /Users/dave/src/emacs-mac-port/lisp/electric.el...
Wrote = /Users/dave/src/emacs-mac-port/lisp/electric.el
electric-indent-post-se= lf-insert-function
Mark set
Quit [3 times]
Mark saved where = search started [2 times]
Mark set
delete-backward-char: Text is = read-only
Loading = /Users/dave/.emacs.d/el-get/dwamacs/settings/message-settings.el = (source)...done

Load-path = shadows:
/Users/dave/.emacs.d/el-get/php-mode/php-mode hides = /Users/dave/.emacs.d/el-get/nxhtml/related/php-mode
/Users/dave/.emacs.= d/el-get/nxhtml/related/csharp-mode hides = /Users/dave/.emacs.d/el-get/csharp-mode/csharp-mode
/Users/dave/.emacs.= d/el-get/cedet/lisp/speedbar/loaddefs hides = /Users/dave/.emacs.d/el-get/cedet/lisp/eieio/loaddefs
/Users/dave/.emac= s.d/el-get/cedet/lisp/speedbar/loaddefs hides = /Users/dave/.emacs.d/el-get/cedet/lisp/cedet/loaddefs
/Users/dave/.emac= s.d/el-get/magit/.dir-locals hides = /Users/dave/.emacs.d/el-get/el-get/.dir-locals
/Users/dave/.emacs.d/el-= get/cedet/lisp/speedbar/loaddefs hides = /Applications/Emacs.app/Contents/Resources/lisp/loaddefs
/Users/dave/.e= macs.d/el-get/dwamacs/site-lisp/ediff-util hides = /Applications/Emacs.app/Contents/Resources/lisp/vc/ediff-util
/Users/da= ve/.emacs.d/el-get/python/python hides = /Applications/Emacs.app/Contents/Resources/lisp/progmodes/python
/Users= /dave/.emacs.d/el-get/dwamacs/site-lisp/compile hides = /Applications/Emacs.app/Contents/Resources/lisp/progmodes/compile
/User= s/dave/.emacs.d/el-get/nxhtml/util/org-odt hides = /Applications/Emacs.app/Contents/Resources/lisp/org/org-odt
/Users/dave= /.emacs.d/el-get/magit/.dir-locals hides = /Applications/Emacs.app/Contents/Resources/lisp/gnus/.dir-locals
/Users= /dave/.emacs.d/el-get/dwamacs/site-lisp/ert hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/ert
/Users/d= ave/.emacs.d/el-get/dwamacs/site-lisp/ert-x hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/ert-x
/Users= /dave/.emacs.d/el-get/cedet/lisp/eieio/eieio hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio
/Users= /dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-speedbar hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-speedbar<= br>/Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-opt hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-opt
/U= sers/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-datadebug hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-datadebug=
/Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-custom hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-custom/Users/dave/.emacs.d/el-get/cedet/lisp/eieio/eieio-base hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-base
/= Users/dave/.emacs.d/el-get/cedet/lisp/eieio/chart hides = /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/chart

Fe= atures:
(shadow sort mail-extr emacsbug message format-spec rfc822 = mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 = mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums = mail-utils debug pcase
cedet-edebug edebug mule-util tabify electric = cmake-mode thingatpt
dired-aux gnus-dired sh-script smie executable = view dabbrev hl-line
shell pcomplete misearch multi-isearch magit-svn = sticky-windows recentf
tree-widget jka-compr sb-info info shiny-mode = flymake compile comint
ansi-color auto-complete-clang-async = magit-bisect magit-key-mode magit
diff-mode log-edit ring pcvs-util = add-log proof-site proof-autoloads
pg-vars page-ext ffap url-parse = auth-source gnus-util mm-util mail-prsvr
password-cache url-vars = auto-complete-config auto-complete popup
use-package bind-key = session-settings session system-type-darwin-theme
osx-plist xml = .loaddefs workgroups flymake-files flymakemsg
nxhtml-autostart = nxhtml-autoload majmodpri vc-git nxhtml-menu
web-autoload nxhtml-base = helm-config helm-aliases fill-column-indicator
initsplit cus-edit = diminish csharp-mode cc-langs rust-mode modal cc-mode
cc-fonts = cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine = cc-vars
cc-defs cm-mode cedet-devel-load warnings eieio-opt = find-func
srecode/map semantic/edit srecode/srt-mode = srecode/template
srecode/srt-wy semantic/wisent = semantic/wisent/wisent srecode/ctxt
srecode/compile = srecode/dictionary srecode/table srecode
semantic/canned-configs = semantic/ia-sb semantic/analyze semantic/sort
semantic/scope = semantic/analyze/fcn semantic/db semantic/ctxt
semantic/format = semantic/tag-ls semantic/find semantic/util-modes
semantic/util = semantic semantic/tag semantic/lex semantic/fw = mode-local
cedet-compat inversion ede/speedbar ede/files ede ede/base = ede/auto
ede/source eieio-base eieio-speedbar speedbar sb-image = ezimage dframe
eieio-custom wid-edit cedet eieio byte-opt = eieio-core
cedet-remove-builtin yasnippet advice advice-preload = dropdown-list
derived edmacro kmacro el-get el-get-autoloads = el-get-list-packages
el-get-notify help-mode el-get-dependencies = el-get-build el-get-status
pp el-get-recipes el-get-byte-compile = el-get-methods el-get-fossil
el-get-svn el-get-pacman = el-get-github-zip el-get-github-tar
el-get-http-zip el-get-http-tar = el-get-hg el-get-git-svn el-get-fink
el-get-emacswiki el-get-http = el-get-emacsmirror el-get-github el-get-git
el-get-elpa package = cl-macs gv el-get-darcs el-get-cvs el-get-bzr
el-get-brew = el-get-builtin el-get-apt-get el-get-custom el-get-core
autoload = help-fns bytecomp byte-compile cconv cl cl-lib dired-x easymenu
dired = easy-mmode which-func imenu paren server ido autorevert time
delsel = cus-start cus-load elhome time-date tooltip ediff-hook = vc-hooks
lisp-float-type mwheel mac-win tool-bar dnd fontset image = regexp-opt
fringe tabulated-list newcomment lisp-mode register page = menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock = syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang = vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek = romanian slovak
czech european ethiopic indian cyrillic chinese = case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer = loaddefs button faces
cus-face macroexp files text-properties overlay = sha1 md5 base64 format
env code-pages mule custom widget = hashtable-print-readable backquote mac
multi-tty make-network-process = emacs)



= --Apple-Mail=_49F9BE8B-38F4-42EC-BAC3-3E0D74739C67--