EDIT: The solution was simple but "bonus points" for anyone that can explain why my method didn't work.
ORIG: I would like an org-mode-custom-command to display an agenda which is only made from the current buffer.
The following snippet shows the kind of view that I want.
(setq org-agenda-custom-commands
'(("b" "Buffer summary"
((todo "TODO" ((org-agenda-files '("~/.agenda/notes.org"))))))))
But, I don't want to specify a filename, rather I want to use the current buffer. Here is my stab at it.
(setq org-agenda-custom-commands
'(("b" "Buffer summary"
((todo "TODO" ((org-agenda-files (buffer-file-name))))))))
When I open an org-buffer and run this agenda command the result is just a pretty much blank agenda view. I presume it's because buffer-file-name is being evaluated at point later than when I press the agenda view...?
I'm still beginning to learn elisp, so don't hesitate to point out the obvious. Thank-you.
EDIT:
Following a suggestion in the comments.
(setq org-agenda-custom-commands
'(("b" "Buffer summary"
((todo "TODO" ((org-agenda-files (list (buffer-file-name)))))))))
I receive a backtrace.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
file-directory-p(nil)
...etc...
For me, the most obvious is NOT to create an extra agenda view, and simply call any existing view on that buffer only (limit the view to the current buffer with a call such as C-c a < a
, where <
limits on the current buffer).
If you still want to make an extra agenda view for the current buffer, I'm not sure whether that's possible with all commands. For sure, calling occur-tree
will work on the current buffer. Not sure about todo
and the like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With