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