]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-org-tag-agenda): New command
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 28 Jul 2015 16:04:49 +0000 (18:04 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 28 Jul 2015 16:05:55 +0000 (18:05 +0200)
* 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

index ce4087d3e9b1132a60bc7d4c499b047cf8a73f90..f771ab789a2fde8cc1b761bfeeca526496eb381a 100644 (file)
@@ -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)