From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer Date: Tue, 01 Aug 2023 07:47:32 +0000 Message-ID: <87o7jrgq5n.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39686"; mail-complaints-to="usenet@ciao.gmane.io" To: 64986@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 01 09:48:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQk75-000A6o-FW for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Aug 2023 09:48:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQk6t-0005Mk-GH; Tue, 01 Aug 2023 03:48:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQk6s-0005Ma-5F for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 03:48:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQk6r-0001K6-Th for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 03:48:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQk6r-0007Mr-PF for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 03:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Aug 2023 07:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64986 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169087605428146 (code B ref -1); Tue, 01 Aug 2023 07:48:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Aug 2023 07:47:34 +0000 Original-Received: from localhost ([127.0.0.1]:47107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQk6P-0007Jt-UC for submit@debbugs.gnu.org; Tue, 01 Aug 2023 03:47:34 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:58600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQk6O-0007Jf-3t for submit@debbugs.gnu.org; Tue, 01 Aug 2023 03:47:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQk6I-0004su-TV for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 03:47:26 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQk6G-0001C8-D3 for bug-gnu-emacs@gnu.org; Tue, 01 Aug 2023 03:47:26 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id C8B91240028 for ; Tue, 1 Aug 2023 09:47:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1690876041; bh=dIcgUhnuolgVext6gDl+gdy6cGtGkBfEiEmUwOncPPA=; h=From:To:Subject:Date:Message-ID:MIME-Version:From; b=U2tZxXOqCAsInmOUc4SaH81pTed6si5chlBuHXRMlkQr1dnYRSdrudrd6Z+CH1OTm 4sGj1HUyT5Ml/XnOUTKd6TkXBjB23iskFZn5G3bKlGJ/0WKJYfVpmt20TFZ235cazw 7AaHpEi+QTUkORQfh3C6HUmPbcRk/hQJd2ceTqmelrHwJgVhAXvWumniriewNENlM2 Sv/T72f3XLRRWFfJIkkDVvloXHI7LgZCNM1Eqg676kjD4dfq4NEI8/kcI3lRoEddet dijlE6Oub2G42hZYtSQIlRRFIAhwRFNWxZ4SRg+cM2uSA0wyRfzOrHgLtG7OVmfZGb nzUG0Lhk2jffQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RFRyx11VGz9sH8 for ; Tue, 1 Aug 2023 09:47:20 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266437 Archived-At: Hi, I stumbled upon apparently unexpected return value of `window-text-pixel-size'. There is no easy reproducer involving emacs -Q, but I can reliably reproduce it with certain variant of `org-string-width' function. I am not 100% sure if it is a real Emacs bug or if it is my misunderstanding of `window-text-pixel-size'. Steps to reproduce: 1. git clone --depth 1 --branch bug/window-text-pixel-size https://git.sr.ht/~yantar92/org-mode 2. cd org-mode 3. make repro REPRO_ARGS="-l ./testing/org-test.el" 4. (setq org-confirm-babel-evaluate nil) 5. M-x debug-on-entry org-string-width 6. Insert and execute the following in *scratch* (org-test-with-temp-text-in-file " #+NAME: example-list - simple - not - nested - list #+BEGIN_SRC emacs-lisp :var x=example-list (print x) #+END_SRC" (should (equal '("simple" "list") (org-babel-execute-src-block))) (forward-line 5) (should (string= "| simple | list |" (buffer-substring (point-at-bol) (point-at-eol))))) 7. If we "c" in the debugger, there is arith error originating from the second call to `window-text-pixel-size' returning (0 . X) in buffer containing text "a". The code of `org-string-width' is: (defun org-string-width (string &optional pixels) "Return width of STRING when displayed in the current buffer. Return width in pixels when PIXELS is non-nil." .... (with-current-buffer (get-buffer-create " *Org string width*") (setq-local display-line-numbers nil line-prefix nil wrap-prefix nil) (setq-local buffer-invisibility-spec (if (listp current-invisibility-spec) (mapcar (lambda (el) ;; Consider ellipsis to have 0 width. ;; It is what Emacs 28+ does, but we have ;; to force it in earlier Emacs versions. (if (and (consp el) (cdr el)) (list (car el)) el)) current-invisibility-spec) current-invisibility-spec)) (setq-local char-property-alias-alist current-char-property-alias-alist) (let (pixel-width symbol-width) (with-silent-modifications (erase-buffer) (insert string) (setq pixel-width (car (window-text-pixel-size nil (line-beginning-position) (point-max)))) (unless pixels (erase-buffer) (insert "a") (setq symbol-width (car (window-text-pixel-size ;; <---- unexpected return nil (line-beginning-position) (point-max)))))) (if pixels pixel-width (/ pixel-width symbol-width))))))) In GNU Emacs 30.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-07-29 built on localhost Repository revision: ce48073f1597ceecb82800e71c89b53badc9f9d0 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Gentoo Linux Configured using: 'configure --with-native-compilation' -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at