[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max
From: |
Ihor Radchenko |
Subject: |
[PATCH v2] org-agenda: Use `window-max-chars-per-line' to calculate max text width |
Date: |
Fri, 22 Apr 2022 13:58:18 +0800 |
"N. Jackson" <nljlistbox2@gmail.com> writes:
> (- (window-text-width))
> ^^^^^^^^^^^^^^^^^
>
> Changing window-text-width to window-max-chars-per-line fixes the
> problem here and seems like the right thing to do.
Sounds reasonable.
Attaching the updated patch.
Best,
Ihor
>From 5251305db6032a4a10f337fe13c519cee6d0fb94 Mon Sep 17 00:00:00 2001
Message-Id:
<5251305db6032a4a10f337fe13c519cee6d0fb94.1650606943.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Thu, 21 Apr 2022 13:18:39 +0800
Subject: [PATCH] org-agenda: Use `window-max-chars-per-line' to calculate max
text width
* lisp/org-agenda.el (org-agenda-prepare):
(org-todo-list):
(org-agenda-align-tags):
(org-agenda-show-new-time): Calculate the maximum number of chars
fitting into window via `window-max-chars-per-line' instead of
`window-with' or `window-text-with'. The latter functions can return
larger number when fringes are disabled [1].
[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19395
Reported in https://orgmode.org/list/87czhdqi9p.fsf_-_@moondust.localdomain
---
lisp/org-agenda.el | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index a09b53563..0f656a6ad 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3925,7 +3925,7 @@ (defun org-agenda-prepare (&optional name)
(insert "\n"
(if (stringp org-agenda-block-separator)
org-agenda-block-separator
- (make-string (window-width) org-agenda-block-separator))
+ (make-string (window-max-chars-per-line)
org-agenda-block-separator))
"\n"))
(narrow-to-region (point) (point-max)))
(setq org-done-keywords-for-agenda nil)
@@ -4944,7 +4944,7 @@ (defun org-todo-list (&optional arg)
(let ((n 0))
(dolist (k kwds)
(let ((s (format "(%d)%s" (cl-incf n) k)))
- (when (> (+ (current-column) (string-width s) 1)
(window-width))
+ (when (> (+ (current-column) (string-width s) 1)
(window-max-chars-per-line))
(insert "\n "))
(insert " " s))))
(insert "\n"))
@@ -10032,8 +10032,8 @@ (defun org-agenda-align-tags (&optional line)
current line."
(let ((inhibit-read-only t)
(org-agenda-tags-column (if (eq 'auto org-agenda-tags-column)
- (- (window-text-width))
- org-agenda-tags-column))
+ (- (window-max-chars-per-line))
+ org-agenda-tags-column))
(end (and line (line-end-position)))
l c)
(save-excursion
@@ -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)
(length stamp))
t)
(add-text-properties
--
2.35.1
- [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? [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 <=
- 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/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