Subject: Re: bug#18913: 24.4.51; point going back to bol after every insertion

From: Stefan Monnier <[email-masked]>
Date: Fri, 31 Oct 2014 16:27:34 -0400

> I found myself in the situation where cursor would go to bol after every
> character I would insert.

Could you rebuild with the patch below (and run with debug-on-error
enabled) and see if you can get those asserts to trigger, which would
give us some information about how/when this happens.

        Stefan

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2014-08-18 15:20:27 +0000
+++ lisp/simple.el	2014-10-31 20:25:11 +0000
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (declare-function widget-convert "wid-edit" (type &rest args))
 (declare-function shell-mode "shell" ())
 
@@ -428,6 +430,7 @@
             ;; starts a page.
             (or was-page-start
                 (move-to-left-margin nil t)))))
+    (unwind-protect
     (if (not interactive)
         ;; FIXME: For non-interactive uses, many calls actually just want
         ;; (insert "\n"), so maybe we should do just that, so as to avoid
@@ -441,7 +444,9 @@
         ;; We first used let-binding to protect the hook, but that was naive
         ;; since add-hook affects the symbol-default value of the variable,
         ;; whereas the let-binding might only protect the buffer-local value.
-        (remove-hook 'post-self-insert-hook postproc))))
+        (remove-hook 'post-self-insert-hook postproc)))
+      (cl-assert (not (member postproc post-self-insert-hook)))
+      (cl-assert (not (member postproc (default-value 'post-self-insert-hook))))))
   nil)
 
 (defun set-hard-newline-properties (from to)