[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate
From: |
N. Jackson |
Subject: |
Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width |
Date: |
Fri, 22 Apr 2022 04:42:54 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) |
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 <kyle@kyleam.com>
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 <yantar92@gmail.com>
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 <malsburg@posteo.de>
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.
- Re: [BUG] Off-by-one error in width of Agenda window? [9.5.2 (release_9.5.2-25-gaf6f12 @ /data/installs/snapshots/emacs-28.1/lisp/org/)], (continued)
- Re: [BUG] Off-by-one error in width of Agenda window? [9.5.2 (release_9.5.2-25-gaf6f12 @ /data/installs/snapshots/emacs-28.1/lisp/org/)], Ihor Radchenko, 2022/04/18
- Re: [BUG] Off-by-one error in width of Agenda window? [9.5.2 (release_9.5.2-25-gaf6f12 @ /data/installs/snapshots/emacs-28.1/lisp/org/)], N. Jackson, 2022/04/18
- Re: [BUG] Off-by-one error in width of Agenda window? [9.5.2 (release_9.5.2-25-gaf6f12 @ /data/installs/snapshots/emacs-28.1/lisp/org/)], Ihor Radchenko, 2022/04/18
- Re: [BUG] Off-by-one error in width of Agenda window?, N. Jackson, 2022/04/19
- Re: [BUG] Off-by-one error in width of Agenda window?, Ihor Radchenko, 2022/04/20
- Re: [BUG] Off-by-one error in width of Agenda window?, N. Jackson, 2022/04/20
- [PATCH] org-agenda: Use `window-max-chars-per-line' instead of `window-width', Ihor Radchenko, 2022/04/21
- Re: [PATCH] org-agenda: Use `window-max-chars-per-line' instead of `window-width', N. Jackson, 2022/04/21
- Re: [PATCH] org-agenda: Use `window-max-chars-per-line' instead of `window-width', N. Jackson, 2022/04/21
- [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width, Ihor Radchenko, 2022/04/22
- Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width,
N. Jackson <=
- Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width, Ihor Radchenko, 2022/04/22
- Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width, N. Jackson, 2022/04/22
- Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width, Ihor Radchenko, 2022/04/24
- Thank you Re: [PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width, N. Jackson, 2022/04/24
Re: [BUG] Off-by-one error in width of Agenda window? [9.5.2 (release_9.5.2-25-gaf6f12 @ /data/installs/snapshots/emacs-28.1/lisp/org/)], Tory S. Anderson, 2022/04/18