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: 24.3; [patch] electric-indent-mode bug Date: Wed, 30 Oct 2013 16:03:34 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1383176597 16254 80.91.229.3 (30 Oct 2013 23:43:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Oct 2013 23:43:17 +0000 (UTC) To: 15767@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 31 00:43:21 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 1VbfPz-0003EA-17 for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Oct 2013 00:43:19 +0100 Original-Received: from localhost ([::1]:54875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbfPy-0004Ai-Hx for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Oct 2013 19:43:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbfPp-00049X-At for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:43:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbfPi-0003K8-H4 for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:43:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbfPi-0003K1-Du for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VbfPi-0002sk-81 for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dave Abrahams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Oct 2013 23:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15767 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.138317656811056 (code B ref -1); Wed, 30 Oct 2013 23:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Oct 2013 23:42:48 +0000 Original-Received: from localhost ([127.0.0.1]:53739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbfPS-0002sF-Ag for submit@debbugs.gnu.org; Wed, 30 Oct 2013 19:42:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53164) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbfPQ-0002s2-6Q for submit@debbugs.gnu.org; Wed, 30 Oct 2013 19:42:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbfPE-0003Ci-KM for submit@debbugs.gnu.org; Wed, 30 Oct 2013 19:42:39 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:36985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbfPE-0003CW-Gg for submit@debbugs.gnu.org; Wed, 30 Oct 2013 19:42:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbfP8-00048O-3d for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:42:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbfP1-00039O-BK for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:42:26 -0400 Original-Received: from [2620:149:4:1503:e089:acbb:2b8:b499] (port=51680 helo=fripp.apple.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1VbfOr-00036s-50 for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2013 19:42:19 -0400 Original-Received: by da0603a-dhcp217.apple.com (Postfix, from userid 501) id 8984F1AE2EF5; Wed, 30 Oct 2013 16:03:34 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:79803 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=electric.el.patch 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 --=-=-= Content-Type: text/plain 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=/Users/xin/Documents/emacs-mac-port/build' '--prefix=/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 i n - p o s C-b C-b C-b C-b i n g b b 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 ( 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-, C-. C-. C-. C-d 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-p C-e C-n SPC { 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 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-x C-b C-x C-b M-x e m a v c - r e p o r t - e m 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 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 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) --=-=-=--