0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 19:37:52 +00:00

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
This commit is contained in:
Ihor Radchenko 2022-04-21 13:18:39 +08:00
parent 96529e933b
commit 81a2fe4f0b
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -3925,7 +3925,7 @@ FILTER-ALIST is an alist of filters we need to apply when
(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 @@ to search again: (0)[ALL]"))
(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 @@ When optional argument LINE is non-nil, align tags only on the
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 @@ When called programmatically, FORCE-DIRECTION can be `set', `up',
(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