Max Nikulin writes:
> nitpick
>
> [...]
>
>> To make a hyperlink to Info documentation, [...]
That is a good nitpick, thank you!
Fixed in the attached patch (along with indentation).
Rudy
>From 60c86cf1991e5437084b3efb28f0866c5a50ca6b 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..239634cb9 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 the Info node `(elisp)Mode Line
+Variables'."
+ ;; 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
--
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966
Rudolf Adamkovič [he/him]
Studenohorská 25
84103 Bratislava
Slovakia