Subject: bug#6000: describe-text-sexp does not know window-width

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 06 Jun 2021 11:03:47 +0200

martin rudalics <[email-masked]> writes:

> `describe-text-sexp' always works on the current buffer
>
> (defun describe-text-sexp (sexp)
>   "Insert a short description of SEXP in the current buffer."
>
> so the added line will avoid the [Show] button iff the selected window
> doesn't show the current buffer which should be rare enough.

That's what I thought should happen, but your proposed change is the
patch below, which seems to do the opposite?  I.e., it'll always do the
[Show] button if the selected window doesn't show the current buffer...

diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index 85017de5d5..f92f37d53d 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -51,7 +51,8 @@ describe-text-sexp
       (setq pp (substring pp 0 (1- (length pp)))))
 
     (if (and (not (string-match-p "\n" pp))
-    	     (<= (length pp) (- (window-width) (current-column))))
+             (eq (window-buffer) (current-buffer))
+             (<= (length pp) (- (window-width) (current-column))))
 	(insert pp)
       (insert-text-button
        "[Show]"

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no