stardiviner
7/22/2014 - 2:34 AM

init-my-functions.el


(defun my-func/open-and-switch-to-buffer (the-command the-buffer-name &optional whether-switch-to-buffer)
  "Open a `COMMAND', and switch to that `BUFFER' depend on `OPTION'.
Usage: (my-func/open-and-switch-to-buffer 'func-or-cmd 'buffer-name' t)"
  (interactive)
  (if (get-buffer the-buffer-name)
      (funcall the-command)
    (bury-buffer)
    (when whether-switch-to-buffer
      (switch-to-buffer the-buffer-name))))

(define-key my-org-prefix-map (kbd "o") (my-func/open-and-switch-to-buffer 'org-agenda-list "*Org Agenda*" t))