"Rohit Patnaik" <quanti...@quanticle.net> writes:

> Currently =org-clock-string-limit= truncates rather crudely. It just does a
> =substring=, which results in the closing parenthesis of the clock string
> getting cut off. The attached patch seeks to improve this truncation behavior
> by trimming the headline such that the closing paren can be displayed. It also
> adds an ellipsis (…) to make it more obvious that the headline has been
> truncated.

Thanks for the patch!

> * lisp/org-clock.el (org-clock-get-clock-string): Move the headline truncation
> logic into `org-clock-get-clock-string`, which enables much nicer truncation
> behavior. Now, when the length of the time string and the headline exceeds
> `org-clock-string-limit`, org-clock truncates the headline, adds an ellipsis,
> and preserves the closing parenthesis. If `org-clock-string-limit` does not
> permit displaying a single character of the headline, we just display a
> (possibly truncated) time string.

This is a breaking change in a sense that `org-clock-get-clock-string'
might be used from Elisp, and we cannot frivolously change its return value.
I suggest adding an optional parameter &optional limit. Then,
`org-clock-update-mode-line' will pass LIMIT = org-clock-string-limit.

> +         (untruncated-length (+ 5 (length time-str)
> +                                (length org-clock-heading))))

Why "5"?
It is generally not future-proof to use unexplained constants in the
code.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>

Reply via email to