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://debbugs.gnu.org/cgi/bugreport.cgi?bug=15767 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems
Subject: Re: bug#15767: 24.3; [patch] electric-indent-mode bug
Date: November 4, 2013 at 12:04:31 PM PST
(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’s actually getting information about the wrong line. It’s 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. (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))))
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-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
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 <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-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)
|