简体   繁体   中英

Agenda view of the current buffer

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 Cc 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.

...The agenda view usually shows the information collected from all the agenda files For more info , first make sure that file you are trying to make agenda-viwable or trackable, by activating it via an org command Cc [ (org-agenda-file-to-front)

you can test the current buffe name by (message (buffer-file-name))

Normally, I use my agenda view from various files, but I can track different agendas eg done, on-progress, fixed, bug, just by using hot-keys Here is mine:

(setq org-agenda-custom-commands '( ("x" agenda) ("y" agenda*) ("o" todo "ONPROGRESS") ("n" tags-todo "+TIPS") ("d" todo "DONE") ("p" todo "PENDING") ("b" todo "BUG") ("f" todo "FIXED") ;("F" todo-tree "FIXED") )) So if I want to view eg done stuffs Cc ad this will show me all done lists regardless of which file they came.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM