From: "Rudolf Adamkovič" <salutis@me.com>
To: Ihor Radchenko <yantar92@posteo.net>, Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-clock: Add a trailing space to the mode line string
Date: Fri, 03 Mar 2023 22:03:38 +0100 [thread overview]
Message-ID: <m2fsalh7it.fsf@me.com> (raw)
In-Reply-To: <87r0u54ygh.fsf@localhost>
[-- 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
next prev parent reply other threads:[~2023-03-03 21:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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č [this message]
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č
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2fsalh7it.fsf@me.com \
--to=salutis@me.com \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).