New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org agenda from the command line #4504

Closed
mbrgm opened this Issue Jan 8, 2016 · 9 comments

Comments

Projects
None yet
5 participants
@mbrgm

mbrgm commented Jan 8, 2016

I was trying to get my org agenda from the command line using emacs -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a")', but all I got was an empty agenda... I suspect this has to do with the async start, but I'm not sure about that. is there something to pay attention to when trying to run cli commands in combination with spacemacs?

@duerrp

This comment has been minimized.

Contributor

duerrp commented Jan 25, 2016

Your command works for me. Do you have org-agenda-files set?

@mbrgm

This comment has been minimized.

mbrgm commented Jan 25, 2016

Here's what I have in my .spacemacs:

(defun dotspacemacs/user-config ()
...
  (setq org-agenda-files (quote ("~/.deft/")))
...
)

When I include the setq with the command line call to org-batch-agenda, it works fine, i.e. /usr/local/bin/emacs -q --batch --eval '(progn (setq org-agenda-files (quote ("~/.deft/"))) (org-batch-agenda "a"))' 2> /dev/null -- but why is the .spacemacs config not being used?

@halvorlu

This comment has been minimized.

halvorlu commented Jul 15, 2016

It seems that dotspacemacs/user-config is called by emacs-startup-hook (see core/core-spacemacs.el). This hook is not called when running emacs in batch mode, see e.g. here. You can run the hook explicitly,

emacs -l ~/.emacs.d/init.el --eval "(run-hooks 'emacs-startup-hook)" --eval '(org-batch-agenda "a")'

This seems to work for me at least.

@concretevitamin

This comment has been minimized.

concretevitamin commented May 3, 2018

@halvorlu It doesn't seem to work for me:

~ » emacs -batch -l ~/.emacs.d/init.el -eval '(org-batch-agenda "a" org-agenda-span 7)'                                                                                                                 255 ↵

Loading /Users/me/.emacs.d/core/core-versions.el (source)...
Loading /Users/me/.emacs.d/core/core-load-paths.el (source)...
Symbol's value as variable is void: user-emacs-directory
@halvorlu

This comment has been minimized.

halvorlu commented May 3, 2018

Did you try to run the emacs-startup-hook by including --eval "(run-hooks 'emacs-startup-hook)"?

@concretevitamin

This comment has been minimized.

concretevitamin commented May 3, 2018

@halvorlu Yes. Using /Applications/Emacs.app/Contents/MacOS/Emacs, which is 25+, solved the issue for me.

@ghost

This comment has been minimized.

ghost commented Jun 22, 2018

@halvorlu What about org-agenda-batch-csv? I tried

#!/bin/bash
emacs -batch -l ~/.emacs.d/init.el --eval "(run-hooks 'emacs-startup-hook)" --eval '(org-batch-agenda-csv "a")' # 2> /dev/null

but it won't return anything. If I try the same function in emacs scratch buffer and use eval-buffer I only get the agenda but no csv.

@halvorlu

This comment has been minimized.

halvorlu commented Jun 23, 2018

I haven't tried org-batch-agenda-csv, so I'm not sure what could be the cause...

@mbrgm

This comment has been minimized.

mbrgm commented Jul 4, 2018

I switched to plain Emacs from Spacemacs in the meantime, so this is "resolved" for me.

@mbrgm mbrgm closed this Jul 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment