]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/simple.el (newline): Add assertions to try and help catch bug#18913.
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 31 Oct 2014 20:57:59 +0000 (16:57 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 31 Oct 2014 20:57:59 +0000 (16:57 -0400)
lisp/ChangeLog
lisp/simple.el

index dd9e4b1384641b1a6e80adc19e85cbab38cba832..f3d6f6cb4461083863ad0e8ab735e57d893478a0 100644 (file)
@@ -1,5 +1,7 @@
 2014-10-31  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * simple.el (newline): Add assertions to try and help catch bug#18913.
+
        * emulation/cua-base.el (cua-delete-region): Use delete-active-region
        (bug#18886).
        (cua--last-deleted-region-pos, cua--last-deleted-region-text): Remove.
index 7b505d116450247fedf420f7cdd99ec563c76969..0c0e81583037a313bcb871a2a8fd690f9b68c4a4 100644 (file)
@@ -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" ())
 
@@ -410,6 +412,7 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
           ;; Do the rest in post-self-insert-hook, because we want to do it
           ;; *before* other functions on that hook.
           (lambda ()
+            (cl-assert (eq ?\n (char-before)))
             ;; Mark the newline(s) `hard'.
             (if use-hard-newlines
                 (set-hard-newline-properties
@@ -428,7 +431,8 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
             ;; starts a page.
             (or was-page-start
                 (move-to-left-margin nil t)))))
-    (if (not interactive)
+    (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
         ;; the risk of filling or running abbrevs unexpectedly.
@@ -441,7 +445,9 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
         ;; 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)