From: Stefan Monnier Date: Fri, 31 Oct 2014 20:57:59 +0000 (-0400) Subject: * lisp/simple.el (newline): Add assertions to try and help catch bug#18913. X-Git-Tag: emacs-24.4.90~287 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=62ee8b1a59d5343197cb59d9f0a52e07a23af1d8;p=emacs.git * lisp/simple.el (newline): Add assertions to try and help catch bug#18913. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dd9e4b13846..f3d6f6cb446 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2014-10-31 Stefan Monnier + * 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. diff --git a/lisp/simple.el b/lisp/simple.el index 7b505d11645..0c0e8158303 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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)