diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-01-11 22:58:11 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-01-11 22:58:11 -0500 |
commit | 818f80db9e4898ecd64d90299194f61751ab9080 (patch) | |
tree | e6bd047669143e3366b13ab3f69f43465d0e97c0 /bog.el | |
parent | 705f6b3943c885b680b5f95f535ffc52cbc46c12 (diff) | |
download | bog-818f80db9e4898ecd64d90299194f61751ab9080.tar.gz |
Decouple Bog search from Org agenda
Previously, using bog-search-notes and bog-search-notes-for-citekey
clobbered the existing agenda buffer. Make these commands output to a
Bog-specific buffer and take care to restore org-lprops after executing.
Unfortunately, this still relies heavily on Org agenda internals, but I
don't see an obvious way around this.
Diffstat (limited to 'bog.el')
-rw-r--r-- | bog.el | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -831,16 +831,32 @@ level `bog-refile-maxlevel' are considered." (-map #'car nodir-files)) nodir-files)))) +(defmacro bog--with-search-lprops (&rest body) + "Execute BODY with Bog-related agenda values. +Restore the `org-lprops' property value for +`org-agenda-redo-command' after executing BODY." + (declare (indent 0)) + `(let ((org-lprops (get 'org-agenda-redo-command 'org-lprops)) + (bog-lprops '((org-agenda-buffer-name "*Bog search*") + (org-agenda-files (bog-notes)) + org-agenda-text-search-extra-files + org-agenda-sticky))) + (put 'org-agenda-redo-command 'org-lprops bog-lprops) + (org-let bog-lprops ,@body) + (use-local-map (let ((map (make-sparse-keymap))) + (set-keymap-parent map org-agenda-mode-map) + (define-key map "r" 'bog-agenda-redo) + map)) + (put 'org-agenda-redo-command 'org-lprops org-lprops))) + (defun bog-search-notes (&optional todo-only string) "Search notes using `org-search-view'. With prefix argument TODO-ONLY, search only TODO entries. If STRING is non-nil, use it as the search term (instead of prompting for one)." (interactive "P") - (let ((lprops '((org-agenda-files (bog-notes)) - (org-agenda-text-search-extra-files nil)))) - (put 'org-agenda-redo-command 'org-lprops lprops) - (org-let lprops '(org-search-view todo-only string)))) + (bog--with-search-lprops + '(org-search-view todo-only string))) (defun bog-search-notes-for-citekey (&optional todo-only) "Search notes for citekey using `org-search-view'. @@ -854,6 +870,11 @@ not found, prompt with citekeys present in any note file." (bog-search-notes todo-only (bog-citekey-from-surroundings-or-all nil))) +(defun bog-agenda-redo (&optional all) + (interactive "P") + (bog--with-search-lprops + '(org-agenda-redo all))) + (defun bog-sort-topic-headings-in-buffer (&optional sorting-type) "Sort topic headings in this buffer. SORTING-TYPE is a character passed to `org-sort-entries'. If |