How can I show the Org-mode agenda on Emacs start-up?
Asked Answered
M

7

27

I would like the Org-mode agenda to automatically show what I have to do today when I open Emacs. The org-agenda command is interactive, so it doesn't seem to work well for this purpose.

Is there a way to show the Org-mode agenda on Emacs start-up?

Thanks,

Conor

Musty answered 6/1, 2010 at 2:4 Comment(0)
U
29

You can use after-init-hook to run a piece of code after initialization has finished. To run (org-agenda-list) after init, use:

(add-hook 'after-init-hook 'org-agenda-list)
Uncaredfor answered 6/1, 2010 at 4:28 Comment(6)
That's the ticket. kwatford's answer below was also very helpful, but I couldn't add '(org-agenda-list 1) as the argument for my .emacs file. If someone could clear this up, I'd be delighted.Musty
(add-hook 'after-init-hook '(lambda () (org-agenda-list 1)))Gleeson
This works but how can I focus on the "Org Agenda" buffer on startup? (I'm using tabbar)Tardif
OK, I figured that out. Adding an answer.Brita
To make this work with emacsclient you can use a focus-in-hook instead of the after-init-hook. In order to show your agenda items you should set your agenda-file/directory before setting the hook, (setq org-agenda-files (quote ("agenda-directory")))Nerin
The server-after-make-frame-hook works perfectly if you use emacsclient.Penates
B
10

This works for me (in .emacs):

(setq inhibit-splash-screen t)
(org-agenda-list)
(delete-other-windows)

Without the first line, the splash screen "covered" the agenda; without the third one, the scratch buffer remained visible.

Brita answered 28/9, 2012 at 16:38 Comment(2)
For emacsclient, we can use emacsclient -t --eval "(org-agenda-list)" "(delete-other-windows)" Make it as function or alias.Disjuncture
This would limit other usages of the editor wouldn't it, what happens if you ask emacs to open with a file?Loo
L
5

One alternative to the hook is to set the initial-buffer-choice variable. This is particularly useful if there are multiple buffers or a number of functions on the hook. The function on this variable needs to return a buffer. Naively this might be:

(setq initial-buffer-choice (lambda ()
    (org-agenda-list 1)
    (get-buffer "*Org Agenda*")))    
Loo answered 8/9, 2015 at 21:27 Comment(2)
this one still shows the scratch buffer. (emacs 26.1)Motherwell
@Motherwell isn't this desirable. Then emacs will behave well when presented with other arguments.Loo
H
3

Try (org-agenda-list). If you just want today, (org-agenda-list 1).

And of course, apropos is your friend. C-h C-a org-agenda (or whatever command) will show you useful info on that command.

Hesitate answered 6/1, 2010 at 2:44 Comment(0)
G
2

I have a bash alias to start emacs with the Agenda open:

alias org='/usr/bin/emacs --funcall org-agenda-list &'

Enjoy.

Governor answered 8/1, 2010 at 20:45 Comment(1)
This is the best answer to get emacsclient working with agenda view in emacs 30: Ubunt startup applications: run daemon in 'Startup Applications Pref as this: /usr/bin/emacs-snapshot -daemon --funcall org-agenda-list & then Set a hot key (Win + G): emacsclient-snapshot -c -n --eval '(org-agenda-list)'Chesty
M
1

It is not exactly at startup, but I keep Emacs running so I need a different approach

(require 'midnight)
(midnight-delay-set 'midnight-delay "7:30am")
(add-hook 'midnight-hook 'org-agenda-list)

Credits to https://mcmap.net/q/406398/-how-to-periodically-run-a-task-within-emacs

Marrs answered 6/5, 2020 at 14:56 Comment(0)
P
0

You can use the server-after-make-frame-hook to run any command when the emacs daemon creates a client-

(use-hook 'server-after-make-frame-hook 'org-agenda-list)

This works perfectly for me because whenever I open emacsclient, org agenda appears which is exactly what I wanted.

You can also look at the following hooks if they suit your needs more- https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html

Penates answered 21/8, 2023 at 15:19 Comment(3)
It throws an error using the emacs 30.0.50 version; any update on how to make agenda view appear on startup using the emacslient?Chesty
Can you mention the error you were getting?Penates
I no longer have this error on Emacs 30.0.50.Chesty

© 2022 - 2025 — McMap. All rights reserved.