17

I've added a custom key for the org agenda to show all unscheduled TODO items following Sacha Chua:

(defun sacha/org-agenda-skip-scheduled ()
  (org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>"))

(setq org-agenda-custom-commands
   '(("u" "Unscheduled tasks" alltodo ""
      ((org-agenda-skip-function 'sacha/org-agenda-skip-scheduled)
       (org-agenda-overriding-header "Unscheduled TODO entries: ")))))

I can bring up this list with C-c a u, but I'd rather just bind it to a single key. Currently I have the simple:

(global-set-key (kbd "<f8>") 'org-todo-list)

but I would like this to use the above custom command. I've had a dig through the manual but I can't see how to do it.

rneatherway
  • 483
  • 3
  • 11

2 Answers2

15

You can do this by wrapping a call to org-agenda into a custom command and binding that to a key:

(defun org-agenda-show-unscheduled (&optional arg)
  (interactive "P")
  (org-agenda arg "u"))

(define-key org-mode-map (kbd "<f8>") 'org-agenda-show-unscheduled)
itsjeyd
  • 14,586
  • 3
  • 58
  • 87
2

I don't like creating an explicit function so I rolled my map within a lambda:

(define-key org-mode-map (kbd "<f8>") '(lambda (&optional arg) (interactive "P")(org-agenda arg "u")))
kshenoy
  • 211
  • 1
  • 11