branch: master
commit 13d0c5096cd67d8398f145fbd30838858ce6f632
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-org-tag-agenda): New command
* counsel.el (counsel-org-tag-agenda): It's just a flet wrapper around
`org-agenda-set-tags', changing `org-set-tags' to `counsel-org-tag'.
(counsel-org-tag-action): Don't use `with-selected-window', since
`org-agenda-set-tags' will change the buffer for us.
Re #177
---
counsel.el | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/counsel.el b/counsel.el
index ce4087d..f771ab7 100644
--- a/counsel.el
+++ b/counsel.el
@@ -794,12 +794,11 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
(setf (ivy-state-prompt ivy-last) prompt)
(setq ivy--prompt (concat "%-4d " prompt)))
(cond ((memq this-command '(ivy-done ivy-alt-done))
- (with-selected-window (ivy-state-window ivy-last)
- (counsel-org-change-tags
- (if counsel-org-tags
- (format ":%s:"
- (mapconcat #'identity counsel-org-tags ":"))
- ""))))
+ (counsel-org-change-tags
+ (if counsel-org-tags
+ (format ":%s:"
+ (mapconcat #'identity counsel-org-tags ":"))
+ "")))
((eq this-command 'ivy-call)
(delete-minibuffer-contents))))
@@ -842,6 +841,18 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
:history 'org-tags-history
:action 'counsel-org-tag-action))))
+;;;###autoload
+(defun counsel-org-tag-agenda ()
+ "Set tags for the current agenda item."
+ (interactive)
+ (let ((store (symbol-function 'org-set-tags)))
+ (unwind-protect
+ (progn
+ (fset 'org-set-tags
+ (symbol-function 'counsel-org-tag))
+ (org-agenda-set-tags nil nil))
+ (fset 'org-set-tags store))))
+
(defun counsel-ag-function (string &optional _pred &rest _unused)
"Grep in the current directory for STRING."
(if (< (length string) 3)