From 90ef5dfd2b76c22d3e78c0a25c82625a1bf11125 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 6 Dec 2014 01:45:28 -0800 Subject: [PATCH] add socks proxy, finish helm-org-agenda-files-headings --- init.el | 8 ++++---- load.d/helm-org-headlines.el | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/init.el b/init.el index fe29bdd6..77d457f0 100644 --- a/init.el +++ b/init.el @@ -818,7 +818,8 @@ The current directory is assumed to be the project's root otherwise." :bind (("M-y" . helm-show-kill-ring) ("M-x" . helm-M-x) ("C-x C-i" . helm-imenu) - ("C-h a" . helm-apropos)) + ("C-h a" . helm-apropos) + ("C-c C-h" . helm-org-agenda-files-headings)) :init (progn (require 'helm) @@ -1240,9 +1241,8 @@ The current directory is assumed to be the project's root otherwise." (if (eq appropriate-theme current-theme) nil (progn - (disable-all-themes) - (load-theme appropriate-theme t) - (setq current-theme appropriate-theme))))) + (disable-and-load-theme appropriate-theme t) + (setq current-theme appropriate-theme))))) (defun disable-all-themes () (interactive) diff --git a/load.d/helm-org-headlines.el b/load.d/helm-org-headlines.el index 9790c2f2..6bcdc8a0 100644 --- a/load.d/helm-org-headlines.el +++ b/load.d/helm-org-headlines.el @@ -1,27 +1,37 @@ -(defun helm-org-agenda-files-headlines (&optional min-depth max-depth) +(defun helm-org-agenda-files-headings (&optional min-depth max-depth) (interactive) - (helm :sources (helm-source-org-headlines-for-files org-agenda-files))) + (helm :sources (helm-source-org-headings-for-files org-agenda-files min-depth max-depth))) (defun helm-org-goto-marker (marker) (switch-to-buffer (marker-buffer marker)) (goto-char (marker-position marker)) (org-show-entry)) - -(defun helm-source-org-headlines-for-files (filenames &optional min-depth max-depth) +(defun helm-source-org-headings-for-files (filenames &optional min-depth max-depth) (unless min-depth (setq min-depth 1)) (unless max-depth (setq max-depth 8)) - (helm-build-sync-source "Org Headlines" + (helm-build-sync-source "Org Headings" :candidates (helm-org-get-candidates filenames min-depth max-depth) :action 'helm-org-goto-marker :action-transformer (lambda (actions candidate) '(("Go to line" . helm-org-goto-marker) - ("Refile to this headline" . helm-org-headline-refile) - ("Insert link to this headline" - . helm-org-headline-insert-link-to-headline))))) + ("Refile to this heading" . helm-org-heading-refile) + ("Insert link to this heading" + . helm-org-insert-link-to-heading-at-marker))))) -(defun helm-org-headline-refile (marker) +(defun helm-org-insert-link-to-heading-at-marker (marker) + (with-current-buffer (marker-buffer marker) + (goto-char (marker-position marker)) + (let ((heading-name (nth 4 (org-heading-components))) + (file-name buffer-file-name)) + (message heading-name) + (message file-name) + (with-helm-current-buffer + (org-insert-link + file-name (concat "file:" file-name "::*"heading-name)))))) + +(defun helm-org-heading-refile (marker) (with-helm-current-buffer (org-cut-subtree)) (let ((target-level (with-current-buffer (marker-buffer marker)