Subject: bug#38219: Error on leaving Ediff after killing vital buffer

From: Juri Linkov <[email-masked]>
Date: Sat, 16 Nov 2019 22:18:24 +0200

> 'y-or-n-p' mangles 'this-command'.  Something like the attached patch
> should fix that.

Can the same be said about read-from-minibuffer?
Shouldn't read-from-minibuffer mangle 'this-command'?
What it some command wants to check if 'this-command'
is 'exit-minibuffer' afterwards?  Shouldn't this change better
to be localized to callers in ediff, instead of adding such hack?

> diff --git a/lisp/subr.el b/lisp/subr.el
> index eaec223585..68e25c96d9 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -2828,7 +2828,8 @@ y-or-n-p
>  		    (concat prompt
>  			    (if (or (zerop l) (eq ?\s (aref prompt (1- l))))
>  				"" " ")
> -			    (if dialog "" "(y or n) "))))))
> +			    (if dialog "" "(y or n) ")))))
> +        (old-this-command this-command))
>      (cond
>       (noninteractive
>        (setq prompt (funcall padded prompt))
> @@ -2858,6 +2859,7 @@ y-or-n-p
>      (let ((ret (eq answer 'act)))
>        (unless noninteractive
>          (message "%s%c" prompt (if ret ?y ?n)))
> +      (setq this-command old-this-command)
>        ret)))
>  
>