Subject: bug#25482: 26.0.50; Allow setting `query-replace-from-to-separator` to nil

From: Thierry Volpiatto <[email-masked]>
Date: Fri, 20 Jan 2017 12:35:29 +0100

Eli Zaretskii <[email-masked]> writes:

> [You've replied only to me.]

Yes sorry, I am so used to github that I sometimes forget to reply to
all.

> So you are saying that even setting the string to " -> " gets " → "
> into the history?

No even if you set the string to " -> " the string is not a plain string
but "\0" with 'display property " -> ".

> If so, that's the bug that we should solve, I think.

The patch is fixing this.

> Is it a problem to have the ASCII " -> " in the history?

It is not ASCII but ^@.

> Assuming we solve this part of the problem, would you still need to
> disable adding the string to the history?

No that would be ok as long as we use a plain string for " -> ".
But note that the fix I provided make the defcustom simpler and easier
to maintain both from user and developer side, thus it allow to use both
custom and setq which is not the case with actual code.

So to resume,

With actual code:

1) Using (setq query-replace-from-to-separator " -> ")
is not working.

2) Using (customize-set-variable query-replace-from-to-separator " -> ")
is working but " -> " will not be a plain ascii string and will be added
to history.

3) Setting query-replace-from-to-separator to nil is not possible, apart perhaps
using a sexp that evaluate to nil, which is not obvious and in which
case do not add a prompt with a default value like in 24.5 (regression).

With the patch:

1) and 2) are working and preserve the actual behavior, which is adding
"from<separator>to" to history.

3) Is working and provide the exact behavior as 24.5, that is use a
plain ascii string " -> " as separator and do not add
"from<separator>to" to history.

The default setting is the same as the actual code, no change.

Unrelated,

I also fixed this block of code:

    (if regexp-flag
        (read-regexp prompt nil 'minibuffer-history)
      (read-from-minibuffer
        prompt nil nil nil nil
        (car (if regexp-flag regexp-search-ring search-ring)) t))

-- 
Thierry