At 13:58 +0800 on Friday 2022-04-22, Ihor Radchenko wrote:
>
> Attaching the updated patch.
> @@ -10301,10 +10301,7 @@ (defun org-agenda-show-new-time (marker stamp
> &optional prefix)
> (line-end-position)
> '(display nil))
> (org-move-to-column
> - (- (if (fboundp 'window-font-width)
^^^^^^^^^^^
> - (/ (window-width nil t) (window-font-width))
> - ;; Fall back to pre-9.3.3 behavior on Emacs <25.
> - (window-width))
> + (- (window-max-chars-per-line)
The fboundp version guard on window-font-width was added to Org recently:
commit 94837fc6b5ca204962f3ed992e30cd998d66a9fe
Author: Kyle Meyer <[email protected]>
Date: Sat May 1 15:48:11 2021 -0400
agenda: Fix org-agenda-show-new-time on Emacs 24
* lisp/org-agenda.el (org-agenda-show-new-time): Add fallback for when
window-font-width isn't available.
efbf96389 (org-agenda.el: Fix display of agenda new time, 2020-02-02)
reworked the column calculation to use window-font-width, but that
function isn't available until Emacs 25, and it's definition can't be
easily ported to org-compat.
Instead just use the old logic, which had been in place since v8.2.6,
when window-font-width isn't available.
Reported-by: Ihor Radchenko <[email protected]>
Link: https://orgmode.org/list/87y2d2mqik.fsf@localhost
If Org needs to support versions of Emacs before 25.1 then I assume
you need the same guard on every instance of
window-max-chars-per-line -- because window-max-chars-per-line was
added to Emacs at the same time as window-font-width:
commit 4a50af936e24b5f71df4079beb6dde82ed1955c2
Author: Titus von der Malsburg <[email protected]>
Date: Sat Mar 21 12:31:29 2015 +0200
Add new functions for computing default font dimensions
lisp/window.el (window-font-width, window-font-height)
(window-max-chars-per-line): New functions.
lisp/simple.el (default-font-height): Doc fix.
(default-font-width): New function.
etc/NEWS: Mention `default-font-width', `window-font-height',
`window-font-width', and `window-max-chars-per-line'.
[These functions were new in Emacs 25.1:
$ cat etc/NEWS.25 | grep -C 5 window-max-chars-per-line
*** New functions 'window-font-height' and 'window-font-width' return
the height and average width of characters in a specified face and
window. If FACE is remapped (see 'face-remapping-alist'), the
function returns the information for the remapped face.
*** A new function 'window-max-chars-per-line' returns the maximal
number of characters that can be displayed on one line. If a face
and/or window are provided, these values are used for the
calculation. This function is different from 'window-body-width' in
that it accounts for (i) continuation glyphs, (ii) the size of the
font, and (iii) the specified window.
]
Perhaps this calls for a new wrapper function in Org, an
org--window-max-chars-per-line that wraps window-max-chars-per-line
in an fboundp and falls back to window-width -- rather than clutter
up the code with the fboundp guard.
Regards,
N.