Subject: Re: bug#17324: 24.3.90; (wrong-type-argument number-or-marker-p nil) in redisplay--update-region-highlight

From: Stefan Monnier <[email-masked]>
Date: Wed, 23 Apr 2014 08:54:18 -0400

> I got the following error (but I can't reproduce it in a fresh session) :
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   min(2623 nil)
[...]
>   redisplay--update-region-highlight(#<window 3 on *Backtrace*>)

I've been tracking down this problem for a while now, but can't seem to
find its source.  So I installed the patch below to work around it for now.

        Stefan

--- lisp/simple.el	2014-04-12 19:20:44 +0000
+++ lisp/simple.el	2014-04-23 12:50:59 +0000
@@ -4495,7 +4495,12 @@
 mode is enabled.  Usually, such commands should use
 `use-region-p' instead of this function, because `use-region-p'
 also checks the value of `use-empty-active-region'."
-  (and transient-mark-mode mark-active))
+  (and transient-mark-mode mark-active
+       ;; FIXME: Somehow we sometimes end up with mark-active non-nil but
+       ;; without the mark being set (e.g. bug#17324).  We really should fix
+       ;; that problem, but in the mean time, let's make sure we don't say the
+       ;; region is active when there's no mark.
+       (mark)))

 (defvar redisplay-unhighlight-region-function