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

From: Kaushal Modi <[email-masked]>
Date: Fri, 18 Mar 2016 10:58:06 -0400

On Thu, Mar 17, 2016 at 11:53 PM, Artur Malabarba <[email-masked]
> wrote:

> Thanks Kaushal! It looks good to me.

Thanks! Here's a formatted patch (with indentation fixes too).
By mistake I created my last patch with an alias that did git format-patch
ignoring whitespace diffs. Below patch fixes this bug plus those
indentation changes.

>From c06557b30dd8b81362c3970b5b9b54154dfabac9 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <[email-masked]>
Date: Fri, 18 Mar 2016 10:41:04 -0400
Subject: [PATCH] Fix an Isearch var to be a string (bug 23038)

* isearch.el (isearch--describe-regexp-mode): The `description' var needs
  to always be a string. Added the missing default case for the cond
  form that ensures that.

Before this bug fix, for the events when `regexp-function' and
`search-default-mode' both were nil, `description' also stayed nil.
So when `space-before' was non-nil, the "non-string" `description'
(with a value of nil) got passed as an argument to
`replace-regexp-in-string' (where a string was expected). That caused
the error described in debbugs # 23038.
---
 lisp/isearch.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 988503e..48354d3 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2585,16 +2585,19 @@ isearch--describe-regexp-mode
                     (eq search-default-mode isearch-regexp))) "")
           ;; 2. Use the `isearch-message-prefix' set for
           ;;    `regexp-function' if available.
-               (regexp-function
-                (and (symbolp regexp-function)
-                     (or (get regexp-function 'isearch-message-prefix)
-                         "")))
+          (regexp-function
+           (and (symbolp regexp-function)
+                (or (get regexp-function 'isearch-message-prefix)
+                    "")))
           ;; 3. Else if `isearch-regexp' is non-nil, set description
           ;;    to "regexp ".
-               (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 "))))
+          (isearch-regexp "regexp ")
+          ;; 4. Else if we're in literal mode (and if the default
+          ;;    mode is also not literal), describe it.
+          ((functionp search-default-mode) "literal ")
+          ;; 5. And finally, if none of the above is true, set the
+          ;;    description to an empty string.
+          (t ""))))
     (if space-before
         ;; Move space from the end to the beginning.
         (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)
-- 
2.6.0.rc0.24.gec371ff

--
Kaushal Modi