* [PATCH] org-clock: Add a trailing space to the mode line string
@ 2023-03-02 14:14 Rudolf Adamkovič
2023-03-02 16:56 ` Max Nikulin
0 siblings, 1 reply; 10+ messages in thread
From: Rudolf Adamkovič @ 2023-03-02 14:14 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Rudolf Adamkovič
* lisp/org-clock.el (org-clock-get-clock-string): End the mode line
string with a space character to make it play well with other mode
line strings which traditionally end with a space character. For
reference, see the mode line string of the Display Time mode.
---
lisp/org-clock.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index d46458536..0154c9a0c 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))))
--
2.39.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-02 14:14 [PATCH] org-clock: Add a trailing space to the mode line string Rudolf Adamkovič
@ 2023-03-02 16:56 ` Max Nikulin
2023-03-03 16:00 ` Ihor Radchenko
0 siblings, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2023-03-02 16:56 UTC (permalink / raw)
To: emacs-orgmode
On 02/03/2023 21:14, Rudolf Adamkovič wrote:
> +++ 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)
Previous discussion of spaces in mode-line:
Ihor Radchenko to emacs-orgmode… Re: Weird gap in agenda mode-line. Sun,
14 Nov 2021 15:52:31 +0800.
https://list.orgmode.org/87k0hbdvi8.fsf@localhost
It seems agenda components use leading spaces but no trailing ones. I am
not familiar with mode line formatting, so it may be a false alarm.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-02 16:56 ` Max Nikulin
@ 2023-03-03 16:00 ` Ihor Radchenko
2023-03-03 21:03 ` Rudolf Adamkovič
0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-03-03 16:00 UTC (permalink / raw)
To: Max Nikulin, Rudolf Adamkovič; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> On 02/03/2023 21:14, Rudolf Adamkovič wrote:
>> +++ 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)
>
> Previous discussion of spaces in mode-line:
>
> Ihor Radchenko to emacs-orgmode… Re: Weird gap in agenda mode-line. Sun,
> 14 Nov 2021 15:52:31 +0800.
> https://list.orgmode.org/87k0hbdvi8.fsf@localhost
>
> It seems agenda components use leading spaces but no trailing ones. I am
> not familiar with mode line formatting, so it may be a false alarm.
It is because they are a part of mode string. Leading space is a
convention for minor modes.
M-x display-time-mode does the opposite - trailing space.
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?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-03 16:00 ` Ihor Radchenko
@ 2023-03-03 21:03 ` Rudolf Adamkovič
2023-03-04 2:30 ` Max Nikulin
2023-03-05 12:22 ` Ihor Radchenko
0 siblings, 2 replies; 10+ messages in thread
From: Rudolf Adamkovič @ 2023-03-03 21:03 UTC (permalink / raw)
To: Ihor Radchenko, Max Nikulin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
Ihor Radchenko <yantar92@posteo.net> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-clock-Add-a-trailing-space-to-the-mode-line-stri.patch --]
[-- Type: text/x-patch, Size: 2911 bytes --]
From 29aca1a54a68aae1f2b38c3a7885f7ee2f155b24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
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
+ "<before> [0:00] (Heading) <after> "
+ (org-test-with-temp-text
+ "* Heading"
+ (org-clock-in)
+ (prog1 (concat "<before> "
+ (org-clock-get-clock-string)
+ "<after> ")
+ (org-clock-out)))))
+ ;; Test the variant with effort.
+ (should
+ (equal
+ "<before> [0:00/1:00] (Heading) <after> "
+ (org-test-with-temp-text
+ "* Heading
+:PROPERTIES:
+:EFFORT: 1h
+:END:"
+ (org-clock-in)
+ (prog1 (concat "<before> "
+ (org-clock-get-clock-string)
+ "<after> ")
+ (org-clock-out))))))
+
(provide 'test-org-clock)
;;; test-org-clock.el end here
--
2.39.2
[-- Attachment #3: Type: text/plain, Size: 246 bytes --]
--
"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č <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-03 21:03 ` Rudolf Adamkovič
@ 2023-03-04 2:30 ` Max Nikulin
2023-03-04 21:14 ` Rudolf Adamkovič
2023-03-05 12:22 ` Ihor Radchenko
1 sibling, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2023-03-04 2:30 UTC (permalink / raw)
To: emacs-orgmode
On 04/03/2023 04:03, Rudolf Adamkovič wrote:
> +(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."
nitpick
(info "(elisp) Documentation Tips")
https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html
> To make a hyperlink to Info documentation, write the single-quoted name
> of the Info node (or anchor), preceded by ‘info node’, ‘Info node’,
> ‘info anchor’ or ‘Info anchor’. The Info file name defaults to ‘emacs’.
> For example,
>
> See Info node `Font Lock' and Info node `(elisp)Font Lock Basics'.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-04 2:30 ` Max Nikulin
@ 2023-03-04 21:14 ` Rudolf Adamkovič
0 siblings, 0 replies; 10+ messages in thread
From: Rudolf Adamkovič @ 2023-03-04 21:14 UTC (permalink / raw)
To: Max Nikulin, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 214 bytes --]
Max Nikulin <manikulin@gmail.com> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-clock-Add-a-trailing-space-to-the-mode-line-stri.patch --]
[-- Type: text/x-patch, Size: 2877 bytes --]
From 60c86cf1991e5437084b3efb28f0866c5a50ca6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
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
+ "<before> [0:00] (Heading) <after> "
+ (org-test-with-temp-text
+ "* Heading"
+ (org-clock-in)
+ (prog1 (concat "<before> "
+ (org-clock-get-clock-string)
+ "<after> ")
+ (org-clock-out)))))
+ ;; Test the variant with effort.
+ (should
+ (equal
+ "<before> [0:00/1:00] (Heading) <after> "
+ (org-test-with-temp-text
+ "* Heading
+:PROPERTIES:
+:EFFORT: 1h
+:END:"
+ (org-clock-in)
+ (prog1 (concat "<before> "
+ (org-clock-get-clock-string)
+ "<after> ")
+ (org-clock-out))))))
+
(provide 'test-org-clock)
;;; test-org-clock.el end here
--
2.39.2
[-- Attachment #3: Type: text/plain, Size: 208 bytes --]
--
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-03 21:03 ` Rudolf Adamkovič
2023-03-04 2:30 ` Max Nikulin
@ 2023-03-05 12:22 ` Ihor Radchenko
2023-03-05 19:45 ` Rudolf Adamkovič
1 sibling, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-03-05 12:22 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Max Nikulin, emacs-orgmode
Rudolf Adamkovič <salutis@me.com> writes:
> 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
>
Thanks!
Applied, onto bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-05 12:22 ` Ihor Radchenko
@ 2023-03-05 19:45 ` Rudolf Adamkovič
2023-03-07 13:05 ` Ihor Radchenko
0 siblings, 1 reply; 10+ messages in thread
From: Rudolf Adamkovič @ 2023-03-05 19:45 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
> Thanks!
> Applied, onto bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c
Why not the one with the correct Info link, as per Max's excellent nitpick?
Rudy
--
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-05 19:45 ` Rudolf Adamkovič
@ 2023-03-07 13:05 ` Ihor Radchenko
2023-03-07 21:17 ` Rudolf Adamkovič
0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-03-07 13:05 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Max Nikulin, emacs-orgmode
Rudolf Adamkovič <salutis@me.com> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> Thanks!
>> Applied, onto bugfix.
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c
>
> Why not the one with the correct Info link, as per Max's excellent nitpick?
Because I missed it.
Now, added the info link.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c0a9c9ede
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] org-clock: Add a trailing space to the mode line string
2023-03-07 13:05 ` Ihor Radchenko
@ 2023-03-07 21:17 ` Rudolf Adamkovič
0 siblings, 0 replies; 10+ messages in thread
From: Rudolf Adamkovič @ 2023-03-07 21:17 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
> Because I missed it.
Gotcha! (Just wanted to make sure I understand.)
> Now, added the info link.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c0a9c9ede
Thank you!
Rudy
--
"Genius is 1% inspiration and 99% perspiration."
-- Thomas Alva Edison, 1932
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-03-07 21:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-02 14:14 [PATCH] org-clock: Add a trailing space to the mode line string Rudolf Adamkovič
2023-03-02 16:56 ` Max Nikulin
2023-03-03 16:00 ` Ihor Radchenko
2023-03-03 21:03 ` Rudolf Adamkovič
2023-03-04 2:30 ` Max Nikulin
2023-03-04 21:14 ` Rudolf Adamkovič
2023-03-05 12:22 ` Ihor Radchenko
2023-03-05 19:45 ` Rudolf Adamkovič
2023-03-07 13:05 ` Ihor Radchenko
2023-03-07 21:17 ` Rudolf Adamkovič
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).