aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-12 06:07:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-12 06:07:20 -0500
commitfb39fe85378b58b77d2c5a7a6464b1b4aec0b85d (patch)
tree3192f0bcbee2740747d7cb649d791492d5d20cd8
parent1c5c8bd4df3bd4fd71fad13b2b57e670a4e74355 (diff)
downloaddotemacs-fb39fe85378b58b77d2c5a7a6464b1b4aec0b85d.tar.gz
dotemacs-fb39fe85378b58b77d2c5a7a6464b1b4aec0b85d.zip
fix(org): give the F8 agenda window 75% of the frame
The agenda buffer's `display-buffer-alist' rule used `(window-height . fit-window-to-buffer)', so a sparse agenda opened as a sliver a few lines tall. The rule now takes `(window-height . cj/org-agenda-window-height)', a defcustom defaulting to 0.75 (the fraction of the frame the agenda window gets), and the rule itself moved into `cj/--org-agenda-display-rule' so it's testable. New `test-org-agenda-config-display.el' checks that the configured fraction flows through, that it's no longer `fit-window-to-buffer', and (integration) that `display-buffer' produces a window near that size. `(use-package alert)' gained an `:if (or (not noninteractive) (require 'alert nil t))' guard: the batch test runner loads this module without `package-initialize', so the optional notification package may be installed but not yet on the load path, and the unconditional `:config' setq's would error.
-rw-r--r--modules/org-agenda-config.el20
-rw-r--r--tests/test-org-agenda-config-display.el49
2 files changed, 65 insertions, 4 deletions
diff --git a/modules/org-agenda-config.el b/modules/org-agenda-config.el
index 6c60e8dd..3b1e9456 100644
--- a/modules/org-agenda-config.el
+++ b/modules/org-agenda-config.el
@@ -46,6 +46,17 @@
(require 'system-lib)
(require 'cj-cache-lib)
+(defcustom cj/org-agenda-window-height 0.75
+ "Fraction of the selected frame used for the org agenda window."
+ :type 'number)
+
+(defun cj/--org-agenda-display-rule ()
+ "Return the display-buffer rule for the org agenda buffer."
+ `("\\*Org Agenda\\*"
+ (display-buffer-reuse-mode-window display-buffer-below-selected)
+ (dedicated . t)
+ (window-height . ,cj/org-agenda-window-height)))
+
;; Load debug functions if enabled
(when (or (eq cj/debug-modules t)
(memq 'org-agenda cj/debug-modules))
@@ -71,10 +82,7 @@
;; display the agenda from the bottom
(add-to-list 'display-buffer-alist
- '("\\*Org Agenda\\*"
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (dedicated . t)
- (window-height . fit-window-to-buffer)))
+ (cj/--org-agenda-display-rule))
;; reset s-left/right each time org-agenda is enabled
(add-hook 'org-agenda-mode-hook (lambda ()
@@ -335,6 +343,10 @@ This allows a line to show in an agenda without being scheduled or a deadline."
;; send libnotify notifications for agenda items
(use-package alert
+ ;; Batch tests load this module without package-initialize, so optional
+ ;; notification packages may be installed but not loadable yet.
+ :if (or (not noninteractive)
+ (require 'alert nil t))
:config
(setq alert-fade-time 10) ;; seconds to vanish alert
(setq alert-default-style 'libnotify)) ;; works well with dunst
diff --git a/tests/test-org-agenda-config-display.el b/tests/test-org-agenda-config-display.el
new file mode 100644
index 00000000..af4c7ea0
--- /dev/null
+++ b/tests/test-org-agenda-config-display.el
@@ -0,0 +1,49 @@
+;;; test-org-agenda-config-display.el --- Tests for org agenda display rule -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for the display-buffer rule used by the F8 org agenda view.
+
+;;; Code:
+
+(require 'ert)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'org-agenda-config)
+
+(ert-deftest test-org-agenda-config-display-rule-uses-configured-height ()
+ "Normal: the agenda display rule uses the configured frame fraction."
+ (let ((cj/org-agenda-window-height 0.75))
+ (should (equal (cdr (assoc 'window-height
+ (cddr (cj/--org-agenda-display-rule))))
+ 0.75))))
+
+(ert-deftest test-org-agenda-config-display-rule-does-not-fit-to-buffer ()
+ "Regression: F8 agenda should not shrink to fit compact agenda contents."
+ (let ((cj/org-agenda-window-height 0.75))
+ (should-not (eq (cdr (assoc 'window-height
+ (cddr (cj/--org-agenda-display-rule))))
+ 'fit-window-to-buffer))))
+
+(ert-deftest test-org-agenda-config-display-rule-creates-large-window ()
+ "Integration: the agenda rule creates a window near the configured height."
+ (let ((cj/org-agenda-window-height 0.75)
+ (display-buffer-alist (list (cj/--org-agenda-display-rule)))
+ (buffer (get-buffer-create "*Org Agenda*")))
+ (unwind-protect
+ (save-window-excursion
+ (delete-other-windows)
+ (with-current-buffer buffer
+ (erase-buffer)
+ (dotimes (_ 3)
+ (insert "agenda line\n")))
+ (let* ((before-height (window-total-height))
+ (window (display-buffer buffer))
+ (actual-ratio (/ (float (window-total-height window))
+ before-height)))
+ (should (= 2 (length (window-list))))
+ (should (> actual-ratio 0.65))
+ (should (< actual-ratio 0.85))))
+ (kill-buffer buffer))))
+
+(provide 'test-org-agenda-config-display)
+;;; test-org-agenda-config-display.el ends here