(save-window-excursion
(helm-org-goto-marker marker)
(if (derived-mode-p 'org-agenda-mode) (org-agenda-clock-in) (org-clock-in))
t))
(defun my/helm-org-clock-in-and-goto (marker)
(helm-org-goto-marker marker)
(if (derived-mode-p 'org-agenda-mode) (org-agenda-clock-in) (org-clock-in)))
(cl-defun mlm/helm-source-org-headings-for-files (filenames
&optional (min-depth 1) (max-depth 8))
(helm-build-sync-source "Org Headings"
:candidates (helm-org-get-candidates filenames min-depth max-depth)
:persistent-help "Go to line (keeping session); <f1> Go to line; <f2> Refile to this heading; <f3> Clock In; <f4> Clock in and Goto; <f5> Insert link to this heading"
:action '(("Go to line" . helm-org-goto-marker)
("Refile to this heading" . helm-org-heading-refile)
("Clock in" . my/helm-org-clock-in)
("Clock in and Go to" . my/helm-org-clock-in-and-goto)
("Insert link to this heading" . helm-org-insert-link-to-heading-at-marker))))
(defun mlm/helm-org-agenda-files-headings ()
(interactive)
(helm :sources (mlm/helm-source-org-headings-for-files (org-agenda-files))
:candidate-number-limit 99999
:buffer "*helm org headings*"))
(global-set-key (kbd "C-x c o") 'mlm/helm-org-agenda-files-headings)