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.
;;; Code:
+(eval-when-compile (require 'cl-lib))
+
(declare-function widget-convert "wid-edit" (type &rest args))
(declare-function shell-mode "shell" ())
;; 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
;; 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.
;; 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)