emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117650: * lisp/simple.el (newline): Add assertio


From: Stefan Monnier
Subject: [Emacs-diffs] emacs-24 r117650: * lisp/simple.el (newline): Add assertions to try and help catch bug#18913.
Date: Fri, 31 Oct 2014 20:58:05 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117650
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: emacs-24
timestamp: Fri 2014-10-31 16:57:59 -0400
message:
  * lisp/simple.el (newline): Add assertions to try and help catch bug#18913.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-10-31 15:31:27 +0000
+++ b/lisp/ChangeLog    2014-10-31 20:57:59 +0000
@@ -1,5 +1,7 @@
 2014-10-31  Stefan Monnier  <address@hidden>
 
+       * 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.

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-08-18 15:20:27 +0000
+++ b/lisp/simple.el    2014-10-31 20:57:59 +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" ())
 
@@ -410,6 +412,7 @@
           ;; 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 @@
             ;; 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 @@
         ;; 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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]