From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brahimi Saifullah Newsgroups: gmane.emacs.bugs Subject: bug#51995: 29.0.50; `string-pixel-width' depends on the current window width Date: Sat, 20 Nov 2021 18:42:01 -0300 Message-ID: <84h7c67bdi.fsf@gmail.com> References: <84czmvbepd.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39368"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51995@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 20 22:43:14 2021 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 1moY8f-0009zW-Sn for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Nov 2021 22:43:13 +0100 Original-Received: from localhost ([::1]:53156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moY8e-00064I-Ln for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Nov 2021 16:43:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1moY8U-00061k-Fe for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2021 16:43:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1moY8U-0001dp-70 for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2021 16:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1moY8U-0000cf-5j for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2021 16:43:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <84czmvbepd.fsf@gmail.com> Resent-From: Brahimi Saifullah Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Nov 2021 21:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51995 X-GNU-PR-Package: emacs Original-Received: via spool by 51995-submit@debbugs.gnu.org id=B51995.16374445322326 (code B ref 51995); Sat, 20 Nov 2021 21:43:02 +0000 Original-Received: (at 51995) by debbugs.gnu.org; 20 Nov 2021 21:42:12 +0000 Original-Received: from localhost ([127.0.0.1]:43772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1moY7f-0000bS-Q0 for submit@debbugs.gnu.org; Sat, 20 Nov 2021 16:42:12 -0500 Original-Received: from mail-ua1-f54.google.com ([209.85.222.54]:39743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1moY7e-0000bE-AK for 51995@debbugs.gnu.org; Sat, 20 Nov 2021 16:42:10 -0500 Original-Received: by mail-ua1-f54.google.com with SMTP id i6so28484110uae.6 for <51995@debbugs.gnu.org>; Sat, 20 Nov 2021 13:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:from:to:cc:subject; bh=+8KhxvcFTxz8Ht2vklNZS1L0iYm6PgvaBo3Konmbm5k=; b=EF8EwZo+BoS7dciDZ1CzYeibrhJe/ECjoLYis6Z3D6L+cIpIGoe4WmaNl9GoFl2yo/ PIC094XJcqi1x+XJXYOcuYhEdyyLrdBOVA9pO6HiQe7DtOdFIL0g1NxqQOxwxx5kjnvv 9S0QY4G/aKQenXiM50ANK9ErxDFrsJItyLaOPpUICkT8pfQgpkW+zr8Qz1bQD8wrWBX1 nbvyd4y+k9xyjlQuodUQyUU1E2so9dQLaZ+vYz3pL1cwTI209cAjvM58weQ/wuv4qpzk 7YQdMmUITW4X23pIoUOs1JrHAvAVYejSCQ+3uq1gxMDLE+kBPYVXJUiJe1SnnDdlUz1M o0WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:from:to:cc:subject; bh=+8KhxvcFTxz8Ht2vklNZS1L0iYm6PgvaBo3Konmbm5k=; b=aAb1AKAQn8REJa/9Su6qjvgIwbgJ89jBfK51JsHMoNugMk1Sv6QbYjB/+NEoYrYRvc zSsapvzGrS1hf+hYuJeA4fAZ1m/Q/L5fONcoqbk8rfletIw8Y5nEpuLmyTleN8i1v8YU qBTzJ1xxYJ6mVIcDdaA3nHl+rbGJEG41e11xmCNy/3vaUFe+I+nC/ExEm6ZkXnUea6fh k1tVY2FTgt7AOWDag4uNrPWdfnObx9JPvwD94+/m/dO7YBjFnNSpasJDr6WyT0uv5Vg4 wEy0TsTuCSKy4ggKyk0eKc43Gel1mOkAmLGVsPzy1wkq7Zyq0EMtEC8U5vPZqtqxzSI2 1m/A== X-Gm-Message-State: AOAM533ZEP+speLgR670Rt7uxzD/OpRJNLZnzFaEkmULTI4WRziCXR+8 gIdZDEM/2aialxtGQC1i+JiTbtYGvyyDxqLO X-Google-Smtp-Source: ABdhPJzZHSOdb9A8iSkof8Odd2nacUj1aiT+RljT6gzL8jZpZLPBt5xHWJ/BvYmwDYDMdsPEWN/1Aw== X-Received: by 2002:ab0:4301:: with SMTP id k1mr65275381uak.75.1637444524537; Sat, 20 Nov 2021 13:42:04 -0800 (PST) Original-Received: from COMPUTADOR ([2804:14d:90bc:8726:6928:8009:bb3:aa5f]) by smtp.googlemail.com with ESMTPSA id u125sm2223836vsb.4.2021.11.20.13.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 13:42:04 -0800 (PST) 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" Xref: news.gmane.io gmane.emacs.bugs:220523 Archived-At: >Since 'window-text-pixel-size' has to deal with arbitrary buffers, it is >not a good idea to set X-LIMIT or Y-LIMIT to very large values. The >doc-string of 'window-text-pixel-size' explicitly warns about X-LIMIT >that > > Since calculating the width of long lines can take some time, it's > always a good idea to make this argument as small as possible; in > particular, if the buffer contains long lines that shall be truncated > anyway. I saw the warnings, but I'm unsure of their validity. Here are some benchmarks that I did. Each form was run on a fresh emacs -Q. Apologies in advance if there is something wrong about them: ;;; X-LIMIT nil (window width is the limit) (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "foo") (car (window-text-pixel-size nil (point-min) (point)))))) ;; (15.551981 588 8.272839) (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size nil (point-min) (point)))))) ;; (17.975419000000002 588 8.30243) ;;; X-LIMIT is equal to the width of the string plus 1 (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "foo") (car (window-text-pixel-size nil (point-min) (point) 25))))) ;; (15.489861 587 8.267005000000001) (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size nil (point-min) (point) 873))))) ;; (17.98802 587 8.421413) ;;; X-LIMIT is unreasonably large (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "foo") (car (window-text-pixel-size nil (point-min) (point) 1000000))))) ;; (15.508047000000001 587 8.281872) (benchmark-run 100000 (save-window-excursion (with-temp-buffer (set-window-buffer nil (current-buffer)) (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size nil (point-min) (point) 1000000))))) ;; (18.031506 588 8.440261) The limit actually seems to be rather irrelevant. Long strings take expectedly longer, but it doesn't seem related to how big or how small X-LIMIT is. The following use a buffer as WINDOW, as `string-pixel-width' currently does: (benchmark-run 100000 (with-temp-buffer (insert "foo") (car (window-text-pixel-size (current-buffer) (point-min) (point))))) ;; (5.935459 164 2.328032) (benchmark-run 100000 (with-temp-buffer (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size (current-buffer) (point-min) (point))))) ;; (8.362771 168 2.349145) (benchmark-run 100000 (with-temp-buffer (insert "foo") (car (window-text-pixel-size (current-buffer) (point-min) (point) 25)))) ;; (5.922218 164 2.350169) (benchmark-run 100000 (with-temp-buffer (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size (current-buffer) (point-min) (point) 873)))) ;; (7.989145 164 2.2566439999999997) (benchmark-run 100000 (with-temp-buffer (insert "foo") (car (window-text-pixel-size (current-buffer) (point-min) (point) 1000000)))) ;; (5.933362 168 2.378873) (benchmark-run 100000 (with-temp-buffer (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore") (car (window-text-pixel-size (current-buffer) (point-min) (point) 1000000)))) ;; (8.006855 167 2.318854) It's a lot more efficient to use a buffer, but the difference between the limits themselves continue to be insignificant. -------------------------------------------------------------------------------- >'string-pixel-width' and the accompanying change of >'window-text-pixel-size' are broken in many ways, see also > > https://mail.gnu.org/archive/html/emacs-devel/2021-11/msg00339.html > >If you see a problem that is not mentioned there, please tell us. Yes, those seem to be the exact problems I was experiencing. >I hopefully fixed most of the issues here but cannot send you a patch at >the moment to test because my local copy is completely out of synch with >master. So please bear with me. Take your time :)