From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.bugs Subject: bug#52129: 29.0.50; Wish: Extend `:align-to center' to work on lines in buffer Date: Sat, 27 Nov 2021 09:47:58 +0100 Message-ID: References: <83o86616m2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29560"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 52129@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 27 09:49:12 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 1mqtOR-0007VL-CV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Nov 2021 09:49:12 +0100 Original-Received: from localhost ([::1]:44118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqtOQ-0003oV-7h for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Nov 2021 03:49:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqtOI-0003oM-OO for bug-gnu-emacs@gnu.org; Sat, 27 Nov 2021 03:49:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mqtOI-0002py-Ei for bug-gnu-emacs@gnu.org; Sat, 27 Nov 2021 03:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mqtOI-0000OZ-BK for bug-gnu-emacs@gnu.org; Sat, 27 Nov 2021 03:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Arthur Miller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Nov 2021 08:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52129 X-GNU-PR-Package: emacs Original-Received: via spool by 52129-submit@debbugs.gnu.org id=B52129.16380028891457 (code B ref 52129); Sat, 27 Nov 2021 08:49:02 +0000 Original-Received: (at 52129) by debbugs.gnu.org; 27 Nov 2021 08:48:09 +0000 Original-Received: from localhost ([127.0.0.1]:32890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mqtNR-0000NQ-31 for submit@debbugs.gnu.org; Sat, 27 Nov 2021 03:48:09 -0500 Original-Received: from mail-oln040092072028.outbound.protection.outlook.com ([40.92.72.28]:6628 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mqtNP-0000N0-Bt for 52129@debbugs.gnu.org; Sat, 27 Nov 2021 03:48:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j17YCcUpE9qCpt59LxOY2lUI5SbPlR3eUV9Ndrsj5NjY5LBDxMqypTWO0e4bro6V6U8wO0/wD27n+OOs1+9PeP5uKt5coQrbFaRBqlmj/Xg6MZvyrR9kwOuRumb+gQ7IPmW5xkF+CIB+P5CNj2bhVG0lol9kfHfO1b3tO/SU8FQBEpGe4C/4wMis7Tev3wMp+jIoHo3P6c6HZY6xul9e0XWLrCILsAPwRNKMhiPZkp27XXSLvqzb0GtGqydUISGmxeEvIdLaGhYRDPekxT5EOSEiMgbnqfi5Vae4RhcOkbuyVVbVSLYutRTdjmHwuxizxHpPU+4xen9L0Cy9gVAXzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aIIh6elelDH2K/SFI+kW5acugDvT7tpkS5v8nV+4XQc=; b=TDI5udlzU5lMcxbGvha4TRXExvT/GDlMYbN0OMitCj0wczE1j5AbqIpnvRgjmOhqsGNels3KkuBV0EHvpNX5GorajkhNTVSL5RmZZ9icsIzZ4Qwo5Ky4FiH6onesXcEUYw5MZBO+cPN8ij65E4yvVsrfpdZ5Nh6wcIGEoxm4qxhfS7fZIJdfebFt2x7MAkxfINS0uG+Nn3ikZIBv2P9HbDT/Kq4Bpw9Yqb3RFpLXW0aAyALWJ5zDXef+YMFE/Gt8EhG4d3kCo/LcBw0BYW1E2LJF4RBmYQ+6AI2/rFBr6MGlvXco9a6/6STrsJUFt/4vD+w1tgoXYUI3Aub5JgCrgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aIIh6elelDH2K/SFI+kW5acugDvT7tpkS5v8nV+4XQc=; b=Hi+KB+21SGxlVVB3T6jJqu6ZXJPlt1Xx5qQ7qJM1zGV06OY6XjYQ0bK5lpqOifXdEcRUgoT856zK1kFEYx2mcTPHW/pT01oaBSvpb/9m6d1JEdSdAJ0GUNCkffYWkdhkcfswqlYniBKQLnXX/LkkdQcfhL+xGnklQgRCP72LvDXekXzcEahCvNoHRKOgLQZvYq9Q8HH2YnA4XFVoL9iOJ+pOp9cxGsCFlfwyxboUKjKh21WVTVep5FuqQWeCeawkxP0Z2qoUf+zMX+ekhBOf7gar3ccE4EMWuOOa65BdR/sOmNe+UtX9wxFW/Xd2w08TrvGd4suyE/SCYy94Pvxr+w== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB3346.eurprd09.prod.outlook.com (2603:10a6:208:175::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.19; Sat, 27 Nov 2021 08:48:00 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c05b:e2ca:5b8a:56d2]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c05b:e2ca:5b8a:56d2%9]) with mapi id 15.20.4734.023; Sat, 27 Nov 2021 08:48:00 +0000 In-Reply-To: <83o86616m2.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 27 Nov 2021 00:59:30 -0500") X-TMN: [v8CgwmmPn4he7KtkpiUnQ64Qynn+Ni/k] X-ClientProxiedBy: GV3P280CA0019.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:b::17) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87pmqmrnlt.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by GV3P280CA0019.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Sat, 27 Nov 2021 08:47:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52b68ad3-17cf-4ee8-4859-08d9b1829dd3 X-MS-TrafficTypeDiagnostic: AM0PR09MB3346: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nUzuwPKd29+Ykw0FbuaN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FiP0b/96ZECe8PB2EfIIORm+9Nvcs0YqqOTcE6q/DvcvE8B4IZiYXX4N06Ck7FZemiA+HDxJfwdgdyVp7fgydzBRHy7IAeDPe4GKKSSZDXGKvdqtAlAz5ZWcXiodmpOFBrj5yFZFuaDHMHJQbRVU+mufUHasGjiQrmgbXUBjNQwuMwoSF76SVx3F14cZtNLuFk1X+/vP+Wt3c3E/riamNq8yWD2499KT3InCtnpNmkvBWrOIlrMUhe/XT3dspM38PofYbF30qaMU+tFK8EG0VYWICHHRIPVMzYqY6WNsYIusCv5jwtXWEdEQWImkYoom gL1Cybx+CidhXO2VdvycK4k6XbiOrvwaUNkS3aRoY1BUFYYJz4pW2ufQ+JOBoULu2ztY20CW/9k2TqZfrkjgE4ulObz3gJedoF X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 52b68ad3-17cf-4ee8-4859-08d9b1829dd3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Nov 2021 08:48:00.6089 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3346 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:220896 Archived-At: Eli Zaretskii writes: >> From: Arthur Miller >> Date: Fri, 26 Nov 2021 21:01:11 +0100 >> >> I am not sure if the title is descriptive enough, or even correct, but as seen >> from attached code and image, I am trying to align two strings in a center of >> each strings line. >> >> It works now when string-pixel-width correctly calculates pixel widths. However, >> I would prefer if I could just use :align-to center as a spec for a string as >> property. Currently we have to use space as a spacer as we used to use >> gif-spacers back in time. >> >> I am not sure about how semantics would work, there are several cases to >> consider, but generally if a string or a stretch of text in a string were given >> text property 'display '(:align-to center), then Emacs would align that stretch >> of text in the middle of the line that text occupies. > > I don't understand what exactly are you asking for. Is your problem > that you have to prepend some character to the string and put the > :align-to spec on that character? Because AFAIU that simple measure > should achieve your goal. You mean something like this: #+begin_src emacs-lisp (defun evc--time () (propertize (time-stamp-string " %H:%M") 'face evc--time-face 'display '(space :align-to center))) (defun evc--date () (propertize (concat " " (capitalize (time-stamp-string "%A")) ". " (capitalize (time-stamp-string "%B %d"))) 'face evc--date-face 'display '(space :align-to center))) (defun evc--update () (let ((time (evc--time)) (date (evc--date))) (when (frame-live-p evc--frame) (select-frame evc--frame)) (with-current-buffer evc--buffer (erase-buffer) (insert time "\n" date)))) #+end_src That "simple measure" does not achieve the goal of aligning involved strings to center; or I don't know understand how you mean. This does: #+begin_src emacs-lisp (defun evc--time () (propertize (time-stamp-string " %H:%M") 'face evc--time-face)) (defun evc--date () (propertize (concat (capitalize (time-stamp-string "%A")) ". " (capitalize (time-stamp-string "%B %d"))) 'face evc--date-face)) (let* ((tlen (* 0.5 (string-pixel-width time))) (dlen (* 0.5 (string-pixel-width date))) (spct (propertize " " 'display `(space :align-to (- center (,tlen))))) (spcd (propertize " " 'display `(space :align-to (- center (,dlen)))))) (insert spct time "\n" spcd date)) #+end_src > please show some simple code to explain your > requests. I hope above illustrates that it is not just to prepend a space, you have to calculate how much it should extend to. This has to be done for each line. Also, even if it would be just to prepend a spacer character, the goal is still to align text in center of a line, so why can't we just renderer to do it for us, instead of having such procedural way of telling it what to do. Why can we not just tell: (defun evc--time () (propertize (time-stamp-string " %H:%M") 'face evc--time-face 'display '(line :align-to center))) or something similar. Also what if the text is longer then visual line? Would it be possible for the rendering engine to center part of the tring with 'aligne-to center' property, and cull extensive part on sides that are outside. That is not acheavable with a spacer.