From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ALMlIvFgAmQbUAEAbAwnHQ (envelope-from ) for ; Fri, 03 Mar 2023 22:04:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id GH5CIvFgAmRy0AAAauVa8A (envelope-from ) for ; Fri, 03 Mar 2023 22:04:49 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2B1EE1E9E1 for ; Fri, 3 Mar 2023 22:04:48 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYCZC-0007IA-Ad; Fri, 03 Mar 2023 16:03:50 -0500 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 1pYCZB-0007GQ-Er for emacs-orgmode@gnu.org; Fri, 03 Mar 2023 16:03:49 -0500 Received: from mr85p00im-zteg06021601.me.com ([17.58.23.187]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYCZ9-0001TV-IN for emacs-orgmode@gnu.org; Fri, 03 Mar 2023 16:03:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1677877422; bh=BMBS+7ddbK06JlXhuR/JLD3hRZZbPYpD9d7Zr0QQccY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=aR43hjPuRFFq+fN+xSp9vbBSTl9cB3AyCoHKVKM414SlyNtjmfKv59tmwksEBKWYD epvVGwxXiHho98IIwTIZNG3aq+4GIE2ryVdCniUWZDkKVOoNBXgamXA/wu3VEt8clr hgIkkNQCWkjLcuHaliJtP6SJM8LTlfEyOBkPnVkLEONgO3KxzTmvIybvGFAAPPuKCR OGxnVJtyZaxC6oIAv16LkaeoQjX6L7hQsaNz/ytB64tXG5QJORLAIhdFKaPGioZnM1 Dr4zAqEE0b3WqnqAx5j6V5wc6XrvyPiR0FFOxz/TlyxVpZ5uiVvnqCPwBIZld+UUr8 o5FthBEi5/H5Q== Received: from Rudolfs-MacBook-Air.local (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021601.me.com (Postfix) with ESMTPSA id 60BC33058B1C; Fri, 3 Mar 2023 21:03:41 +0000 (UTC) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: Ihor Radchenko , Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org-clock: Add a trailing space to the mode line string In-Reply-To: <87r0u54ygh.fsf@localhost> References: <20230302141443.7842-1-salutis@me.com> <87r0u54ygh.fsf@localhost> Date: Fri, 03 Mar 2023 22:03:38 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Proofpoint-ORIG-GUID: qFCxRzmfERYIVAK9p8xGV0TVelefVFLT X-Proofpoint-GUID: qFCxRzmfERYIVAK9p8xGV0TVelefVFLT X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.0.605.474.0000000_definitions?= =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2020-01-23?= =?UTF-8?Q?=5F02_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2303030178 Received-SPF: pass client-ip=17.58.23.187; envelope-from=salutis@me.com; helo=mr85p00im-zteg06021601.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677877488; a=rsa-sha256; cv=none; b=qzv3e4qwgMSwTdDs6/eJ7/wUDU+OWL/CVWQoHY5t3dQLP/eBUzM5HTrO0KWMNJ0aUk13ls fup3Q/cGJsGxYQBljB68QhVYY9nyGu6kCtjQUSFsWP9RRjC+ohC87Nt47IbyA7t5BMT0xM jcG+OPHEWk84FpxZW15Zle+0gMtIwei8rMZvfxylid6/+C2wVChsUuIm+an2C1k9iFejFL sOBtdp1Ltm4SLsWEkdObHd6bQ37NGRLrZRKKCaHreLITSoKkvrfZBA/2Ittqbt8oa/dAO7 Cq817gomrWIXWB7ZwnaQ40437ifHvtAOBoo3h5oANQdHt+iGlp8tXXOiaKAoUg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=aR43hjPu; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677877488; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=BMBS+7ddbK06JlXhuR/JLD3hRZZbPYpD9d7Zr0QQccY=; b=QCYRrwx1Z6jslLzjAPeBhar8l3LY128lFkOuxeJw+K5h/Aq9xkWMUx+PETiCRAZBaBtMPA +Y7g71yOXJEmzlHvZl51Hb4wl9BWZ1ex0eaiI72c3mw76PArHoAGf+3Q6vRmouBq/DMw8S myMqeqbYogH7EUIobMNoRPFahWkTquXtIaQvdhnCqTo4dsyRsdXt/ch26wgu3HJEAZLDeX c+uEXebuPB6Cm4zIMwyLqFeQX0k7t3ccV/xE+QVOJ63isGZYRZq5hKzLS8SAobzSeatOlH j+rvAEaUaOAiExCKdIvHA2F+gqrd44gG0kfrGmdpuBlq00UcL3oJrp/3n8r2Sg== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -5.00 X-Spam-Score: -5.00 X-Migadu-Queue-Id: 2B1EE1E9E1 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=aR43hjPu; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=me.com X-TUID: UhpKLhgAr/iX --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Rudolf, I am OK with the patch, but could you please add a comment > explaining why trailing space, so that people do not wonder in future? Please see the attached patch, revised as follows: - no leading space in the mode line element to make it completely correct - a clear explanation (with a citation) to avoid pointless discussions - two new automated tests to avoid future regressions - a clearer commit message Rudy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-clock-Add-a-trailing-space-to-the-mode-line-stri.patch >From 29aca1a54a68aae1f2b38c3a7885f7ee2f155b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= Date: Thu, 2 Mar 2023 15:06:19 +0100 Subject: [PATCH] org-clock: Add a trailing space to the mode line string * lisp/org-clock.el (org-clock-get-clock-string): End the mode line element in a space, instead of beginning with space, to make it play well with other mode line strings, which typically end a space. For reference, see the mode line string of the Display Time mode. --- lisp/org-clock.el | 4 ++-- testing/lisp/test-org-clock.el | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index d46458536..a300df8ff 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -728,9 +728,9 @@ If not, show simply the clocked time like 01:50." 'org-mode-line-clock-overrun 'org-mode-line-clock))) (effort-str (org-duration-from-minutes effort-in-minutes))) - (format (propertize " [%s/%s] (%s)" 'face 'org-mode-line-clock) + (format (propertize "[%s/%s] (%s) " 'face 'org-mode-line-clock) work-done-str effort-str org-clock-heading)) - (format (propertize " [%s] (%s)" 'face 'org-mode-line-clock) + (format (propertize "[%s] (%s) " 'face 'org-mode-line-clock) (org-duration-from-minutes clocked-time) org-clock-heading)))) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index f732e471a..a1ca9e25b 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -1276,5 +1276,40 @@ CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] => 1:00" (test-org-clock-clocktable-contents (format ":hidefiles t :scope (lambda () (list %S))" the-file)))))))) +;;; Mode line + +(ert-deftest test-org-clock/mode-line () + "Test mode line string ends in a space. + +\"Elements that are added to [the mode line] should normally end +in a space (to ensure that consecutive 'global-mode-string' +elements display properly)\" per Emacs manual, Section 24.4.4 +Variables Used in the Mode Line." + ;; Test the variant without effort. + (should + (equal + " [0:00] (Heading) " + (org-test-with-temp-text + "* Heading" + (org-clock-in) + (prog1 (concat " " + (org-clock-get-clock-string) + " ") + (org-clock-out))))) + ;; Test the variant with effort. + (should + (equal + " [0:00/1:00] (Heading) " + (org-test-with-temp-text + "* Heading +:PROPERTIES: +:EFFORT: 1h +:END:" + (org-clock-in) + (prog1 (concat " " + (org-clock-get-clock-string) + " ") + (org-clock-out)))))) + (provide 'test-org-clock) ;;; test-org-clock.el end here -- 2.39.2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 "One can begin to reason only when a clear picture has been formed in the imagination." -- Walter Warwick Sawyer, Mathematician's Delight, 1943 Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia --=-=-=--