Subject: bug#23038: 25.0.92; M-% from isearch broken (error in isearch--describe-regexp-mode)

From: Kaushal Modi <[email-masked]>
Date: Thu, 17 Mar 2016 10:25:51 -0400

Hi Michael,

I believe that the bug was already there but I can try fixing it (below
patch is my first attempt).

This bug got revealed because when you do "C-s C-w M-%", the space-before
argument is set to t for the isearch--describe-regexp-mode.

The let-bound var description value was staying nil as both
search-default-mode and regexp-function are nil. The bug probably did not
reveal earlier because we had search-default-mode set to a non-nil value by
default.

The error simply tells that

(replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)

is seeing description as a non-string value (nil).

Below patch sets the default case for the cond (which we should technically
anyways be doing). By default the description var is set to an empty string
"" instead of nil. As description is anyways supposed to be a string, I
think that this patch should not hurt.

I would let you and others evaluate this proposed fix.

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 988503e..9b8a0f0 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2594,7 +2594,8 @@ isearch--describe-regexp-mode
           (isearch-regexp "regexp ")
           ;; 4. And finally, if we're in literal mode (and if the
           ;;    default mode is also not literal), describe it.
-               ((functionp search-default-mode) "literal "))))
+          ((functionp search-default-mode) "literal ")
+          (t ""))))
     (if space-before
         ;; Move space from the end to the beginning.
         (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)