diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-03-31 01:51:42 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-03-31 01:53:23 -0400 |
commit | fb38041b6bfceda7816b01c8b1e5084f7de4d4dd (patch) | |
tree | 62f7410f703e9c436f48e79f1cf9adc11d7af2ce /bog.el | |
parent | a4a0e8ce8400894d0c7bac5b4d64753f2a415b5e (diff) | |
download | bog-fb38041b6bfceda7816b01c8b1e5084f7de4d4dd.tar.gz |
Add agenda search functions
Diffstat (limited to 'bog.el')
-rw-r--r-- | bog.el | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -181,6 +181,17 @@ It should contain the placeholder \"%s\" for the query." :group 'bog :type 'string) +(defcustom bog-agenda-custom-command-key "b" + "Key to use for Bog notes search key in agenda dispatch. +If nil, a custom command will not be added to Org agenda +dispatch, but searching Bog notes through the agenda interface +will still be available through `bog-search-notes' and +`bog-search-notes-for-citekey'." + :group 'bog + :type '(choice + (const :tag "Don't display in agenda dispatch" nil) + (string :tag "Key for agenda dispatch"))) + ;;; General utilities @@ -533,6 +544,23 @@ level `bog-refile-maxlevel' are considered." (concat (file-name-as-directory bog-notes-directory) "*.org"))) +(defun bog-search-notes (&optional todo-only) + "Search notes using `org-search-view'. +With prefix argument TODO-ONLY, only TODO entries are searched." + (interactive "P") + (let ((lprops (nth 4 bog-agenda-custom-command))) + (put 'org-agenda-redo-command 'org-lprops lprops) + (org-let lprops '(org-search-view todo-only)))) + +(defun bog-search-notes-for-citekey (&optional todo-only) + "Search notes for citekey using `org-search-view'. +With prefix argument TODO-ONLY, only TODO entries are searched." + (interactive "P") + (let ((citekey (bog-citekey-from-notes)) + (lprops (nth 4 bog-agenda-custom-command))) + (put 'org-agenda-redo-command 'org-lprops lprops) + (org-let lprops '(org-search-view todo-only citekey)))) + ;;; Font-lock @@ -566,6 +594,8 @@ level `bog-refile-maxlevel' are considered." (define-key prefix-map "p" 'bog-find-citekey-pdf) (define-key prefix-map "r" 'bog-rename-staged-pdf-to-citekey) (define-key prefix-map "b" 'bog-find-citekey-bib) + (define-key prefix-map "s" 'bog-search-notes) + (define-key prefix-map "c" 'bog-search-notes-for-citekey) (define-key prefix-map "h" 'bog-goto-citekey-heading-in-buffer) (define-key prefix-map "H" 'bog-goto-citekey-heading-in-notes) (define-key prefix-map "w" 'bog-search-citekey-on-web) @@ -573,6 +603,11 @@ level `bog-refile-maxlevel' are considered." map) "Keymap for Bog.") +(defvar bog-agenda-custom-command + `(,(or bog-agenda-custom-command-key "b") "Search Bog notes" search "" + ((org-agenda-files (bog-notes-files)) + (org-agenda-text-search-extra-files nil)))) + ;;;###autoload (define-minor-mode bog-mode "Toggle Bog in this buffer. @@ -587,9 +622,15 @@ ARG is omitted or nil. :require 'bog (cond (bog-mode - (bog-add-fontlock)) + (bog-add-fontlock) + (when bog-agenda-custom-command-key + (add-to-list 'org-agenda-custom-commands + bog-agenda-custom-command))) (t - (bog-remove-fontlock)))) + (bog-remove-fontlock) + (when bog-agenda-custom-command + (setq org-agenda-custom-commands (delete bog-agenda-custom-command + org-agenda-custom-commands)))))) (provide 'bog) |