Subject: 25.0.50; (buffer-modified-p) errors inside cl-letf

From: Artur Malabarba <[email-masked]>
Date: Thu, 6 Aug 2015 20:47:34 +0100

>From emacs -Q, run the following:

(cl-letf (((buffer-modified-p)))
  (insert "ookok"))

You'll get an error from trying to set a nil buffer.

Using `(buffer-modified-p (current-buffer))' instead works.

Backtrace:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  set-buffer(nil)
  (save-current-buffer (set-buffer nil) (set-buffer-modified-p old))
  (unwind-protect (insert "ookok") (save-current-buffer (set-buffer
nil) (set-buffer-modified-p old)))
  (let* ((old (buffer-modified-p))) (unwind-protect (insert "ookok")
(save-current-buffer (set-buffer nil) (set-buffer-modified-p old))))
  eval((let* ((old (buffer-modified-p))) (unwind-protect (insert
"ookok") (save-current-buffer (set-buffer nil) (set-buffer-modified-p
old)))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)