diff options
| author | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-01 16:05:07 +1100 |
|---|---|---|
| committer | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-01 16:05:07 +1100 |
| commit | 1638d7f40932aed8c634220810a47d639732f35d (patch) | |
| tree | a08c77b724244f7333d4a00c9e61389935ae2d59 | |
| parent | d14177e3e58bb24b17909db861e43528ec9be132 (diff) | |
Fix org-agenda refresh advice arguments
| -rw-r--r-- | config.org | 61 |
1 files changed, 32 insertions, 29 deletions
@@ -137,20 +137,28 @@ This section sets the visual defaults: theme, fonts, and frame behavior. 'fixed-pitch-serif nil :family ss/font-family :weight ss/font-weight)) + (defun ss/apply-gui-defaults (&optional frame) + "Apply GUI defaults to FRAME. +If FRAME is nil, use the selected frame." + (let ((target-frame (or frame (selected-frame)))) + (when (display-graphic-p target-frame) + (with-selected-frame target-frame + (ss/apply-frame-size target-frame) + (ss/disable-menu-bar) + (tool-bar-mode -1) + (scroll-bar-mode -1) + (tooltip-mode -1) + (when (find-font (font-spec :name ss/font-family)) + (ss/apply-font-faces)))))) + (defun ss/disable-menu-bar () "Disable the menu bar for the current frame/session." (menu-bar-mode -1)) - (add-hook 'after-make-frame-functions #'ss/apply-frame-size) + (add-hook 'after-make-frame-functions #'ss/apply-gui-defaults) (when (display-graphic-p) - (ss/apply-frame-size) - (ss/disable-menu-bar) - (tool-bar-mode -1) - (scroll-bar-mode -1) - (tooltip-mode -1) - (when (find-font (font-spec :name ss/font-family)) - (ss/apply-font-faces))) + (ss/apply-gui-defaults)) (unless (display-graphic-p) (add-hook 'emacs-startup-hook #'ss/disable-menu-bar)) @@ -188,22 +196,16 @@ This section sets the visual defaults: theme, fonts, and frame behavior. display-time-default-load-average nil) (display-time-mode 1)) - ;; Customize modeline appearance - white background with line only on top - (set-face-attribute 'mode-line nil - :background "white" - :foreground "black" - :overline "gray50" - :underline nil - :box nil) - - (set-face-attribute 'mode-line-inactive nil - :background "gray95" - :foreground "gray40" - :overline "gray30" - :underline nil - :box nil) - - ;; Customize the modeline format with padding and right-aligned time + (defun ss/mode-line-right-align () + "Return a spacer that right-aligns `mode-line-misc-info'." + (propertize + " " + 'display + `((space :align-to + (- right + ,(+ 2 (string-width (format-mode-line mode-line-misc-info)))))))) + + ;; Keep the theme's faces, but make the right edge alignment dynamic. (setq-default mode-line-format (list ;; Left padding @@ -222,7 +224,7 @@ This section sets the visual defaults: theme, fonts, and frame behavior. " " mode-line-modes ;; Right-align from here - '(:eval (propertize " " 'display '((space :align-to (- right 22))))) + '(:eval (ss/mode-line-right-align)) mode-line-misc-info ;; Right padding " " @@ -420,6 +422,7 @@ If PROMPTS is empty, rely on `denote-prompts'." (target (expand-file-name subdirectory root)) (existing (file-directory-p target))) (make-directory target t) + (ss/refresh-org-agenda-files) (message "%s note directory: %s" (if existing "Using existing" "Created") target))) @@ -446,8 +449,9 @@ This ensures `org-agenda-file-regexp' and `org-agenda' are available." nil)) ss/org-agenda-directories)))) - (defun ss/refresh-org-agenda-files () - "Refresh `org-agenda-files' from the current PARA directories." + (defun ss/refresh-org-agenda-files (&rest _) + "Refresh `org-agenda-files' from the current PARA directories. +Ignore any arguments passed by advice wrappers." (setq org-agenda-files (ss/org-agenda-files))) (defun ss/daily-note-path (&optional time) @@ -482,7 +486,6 @@ Return the path to the note." "Refresh agenda files and invoke `org-agenda'." (interactive) (ss/ensure-org-agenda-loaded) - (ss/refresh-org-agenda-files) (call-interactively #'org-agenda)) :bind (("C-c a" . ss/open-agenda) ("C-c c" . org-capture) @@ -497,7 +500,7 @@ Return the path to the note." (font-lock-flush) (font-lock-ensure))) (ss/refresh-org-agenda-files) - (add-hook 'org-capture-after-finalize-hook #'ss/refresh-org-agenda-files) + (advice-add 'org-agenda :before #'ss/refresh-org-agenda-files) (ss/ensure-org-note-directories)) #+end_src |
