Subject: bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first

From: Jambunathan K <[email-masked]>
Date: Sat, 09 Mar 2013 22:55:18 +0530

"Drew Adams" <[email-masked]> writes:

>> > Do you at least see why your *Messages* logged `exit-minibuffer'?
>> 
>> ,---- In `read-regexp'
>> | +  (let ((user-defaults (read-regexp-defaults)))
>> | +    (unless (eq user-defaults t)
>> | +      (setq defaults user-defaults)
>> | +      (message "cmd: %s defaults: %S" this-command defaults)))
>> | +
>> `----
>> 
>> cmd: exit-minibuffer defaults: nil
>> 
>> > Your code checks only (eq user-defaults t).  When 
>> > `user-defaults' is nil, this returns nil.
>> 
>> The cmd is `exit-minibuffer'.  That corresponds to RET in minibuffer
>> map.  I have no other explanation.
>> 
>> Btw, your explanation is *totally* off the mark.  It talks about
>> defaults in my snippet and not the cmd.
>
> NOW I suppose I AM dealing with a dead horse.  But in hopes of helping and at
> the risk of being told once more to f___ off, let me try once more:
>
> +(defun read-regexp-defaults ()
> +  (if (not read-regexp-user-defaults) t
> +    (let ((user-default (assoc this-command read-regexp-user-defaults)))
> +      (pcase user-default
> +	  (`(,cmd ,(and (pred functionp) getter))
> +	   (funcall getter))
> +	  (`nil nil)
> +	  (_ t)))))
>
> Don't you think that that will return nil when `this-command' =
> `exit-minibuffer', since `exit-minibuffer' is not in your value of alist
> `read-regexp-user-defaults'?

Right.

> And if it returns nil, don't you think that the following will then print `cmd:
> exit-minibuffer defaults: nil'?
>
> +  (let ((user-defaults (read-regexp-defaults)))
> +    (unless (eq user-defaults t)
> +      (setq defaults user-defaults)
> +      (message "cmd: %s defaults: %S" this-command defaults)))
>
> If this doesn't help, I give up and lie down next to your dead horse.

Right.

The question is why is this-command `exit-minibuffer' when it should
have been `multi-occur-in-matching-buffers'.  Where does
`exit-minibuffer' come from.

I am not concerned about the defaults, I am concerned about how the cmd.
Do you have an explanation.  There should be an explanation... and the
closest I have come to is to map RET to `exit-minibuffer'.