1

I've noticed that my agenda views get squashed (line breaks) when my window/frame resizes, e.g. when I move the Emacs frame to a smaller monitor. Is there a way/hook to automatically reload my open agendas (I usually have a daily view and a custom agenda command open sticky) in the background when the frame resizes? I couldn't quite find the right thing in the help menu.

1 Answer 1

1

You can detect a size change when you move the frame from one monitor to another by using window-size-change-functions (see its doc string with C-h v window-size-change-functions). Here's a simple example that prints a message out when that happens:

(defun wscf (obj)
  (message (format "%S: size change" obj)))

(add-to-list 'window-size-change-functions #'wscf)

We define a function and then add it to the list. When the size changes, the functions in the list (in this case just wscf) are called. This function produces a message that looks something like this:

#<frame [email protected]: *Messages* 0x19c11b0>: size change

Now all you have to do is modify the function to do what you want, for example:

(defun wscf (obj)
  (org-agenda-redo 'all))

Now when the size changes, the new function is called which redoes the agenda. The argument to org-agenda-redo causes it to rebuild all agenda views (it can be anything non-nil, so t would work just as well).

1
  • Works like a charm, thank you! For other users interested: It does make it a bit stutter-y when you drag-resize a window, but is perfect for my use case (maximising, tiling window manager etc.).
    – Chillja
    Commented Sep 1, 2022 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.