[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 00d8f08 12/54: counsel.el (counsel-org-tag): Now works in
From: |
Oleh Krehel |
Subject: |
[elpa] master 00d8f08 12/54: counsel.el (counsel-org-tag): Now works in agenda |
Date: |
Tue, 29 Sep 2015 14:09:50 +0000 |
branch: master
commit 00d8f08e2bb325465e1572c7b535227e981b9645
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-org-tag): Now works in agenda
* counsel.el (counsel-org--set-tags): New defun.
(counsel-org-tag-action): Update.
When on an agenda item, add/remove tags for that item.
When any agenda items are marked with "m", add selected tags to all
items, with no duplicates.
Fixed the bug of setting tags to "::" sometimes.
Fixed "C-M-j" not exiting.
Fixes #200
---
counsel.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/counsel.el b/counsel.el
index bcd99b7..b97efc9 100644
--- a/counsel.el
+++ b/counsel.el
@@ -806,22 +806,45 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
(t (error "Tags alignment failed")))
(org-move-to-column col)))
+(defun counsel-org--set-tags ()
+ (counsel-org-change-tags
+ (if counsel-org-tags
+ (format ":%s:"
+ (mapconcat #'identity counsel-org-tags ":"))
+ "")))
+
(defun counsel-org-tag-action (x)
(if (member x counsel-org-tags)
(progn
(setq counsel-org-tags (delete x counsel-org-tags)))
- (setq counsel-org-tags (append counsel-org-tags (list x)))
- (unless (member x ivy--all-candidates)
- (setq ivy--all-candidates (append ivy--all-candidates (list x)))))
+ (unless (equal x "")
+ (setq counsel-org-tags (append counsel-org-tags (list x)))
+ (unless (member x ivy--all-candidates)
+ (setq ivy--all-candidates (append ivy--all-candidates (list x))))))
(let ((prompt (counsel-org-tag-prompt)))
(setf (ivy-state-prompt ivy-last) prompt)
(setq ivy--prompt (concat "%-4d " prompt)))
- (cond ((memq this-command '(ivy-done ivy-alt-done))
- (counsel-org-change-tags
- (if counsel-org-tags
- (format ":%s:"
- (mapconcat #'identity counsel-org-tags ":"))
- "")))
+ (cond ((memq this-command '(ivy-done
+ ivy-alt-done
+ ivy-immediate-done))
+ (if (eq major-mode 'org-agenda-mode)
+ (if (null org-agenda-bulk-marked-entries)
+ (let ((hdmarker (or (org-get-at-bol 'org-hd-marker)
+ (org-agenda-error))))
+ (with-current-buffer (marker-buffer hdmarker)
+ (goto-char hdmarker)
+ (counsel-org--set-tags)))
+ (let ((add-tags (copy-sequence counsel-org-tags)))
+ (dolist (m org-agenda-bulk-marked-entries)
+ (with-current-buffer (marker-buffer m)
+ (save-excursion
+ (goto-char m)
+ (setq counsel-org-tags
+ (delete-dups
+ (append (split-string (org-get-tags-string) ":"
t)
+ add-tags)))
+ (counsel-org--set-tags))))))
+ (counsel-org--set-tags)))
((eq this-command 'ivy-call)
(delete-minibuffer-contents))))
@@ -847,15 +870,25 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
"Add or remove tags in org-mode."
(interactive)
(save-excursion
- (unless (org-at-heading-p)
- (org-back-to-heading t))
- (setq counsel-org-tags (split-string (org-get-tags-string) ":" t))
+ (if (eq major-mode 'org-agenda-mode)
+ (if org-agenda-bulk-marked-entries
+ (setq counsel-org-tags nil)
+ (let ((hdmarker (or (org-get-at-bol 'org-hd-marker)
+ (org-agenda-error))))
+ (with-current-buffer (marker-buffer hdmarker)
+ (goto-char hdmarker)
+ (setq counsel-org-tags
+ (split-string (org-get-tags-string) ":" t)))))
+ (unless (org-at-heading-p)
+ (org-back-to-heading t))
+ (setq counsel-org-tags (split-string (org-get-tags-string) ":" t)))
(let ((org-setting-tags t)
(org-last-tags-completion-table
(append org-tag-persistent-alist
(or org-tag-alist (org-get-buffer-tags))
(and
- org-complete-tags-always-offer-all-agenda-tags
+ (or org-complete-tags-always-offer-all-agenda-tags
+ (eq major-mode 'org-agenda-mode))
(org-global-tags-completion-table
(org-agenda-files))))))
(ivy-read (counsel-org-tag-prompt)
- [elpa] master b45d10c 43/54: Revert multiple frames workaround, (continued)
- [elpa] master b45d10c 43/54: Revert multiple frames workaround, Oleh Krehel, 2015/10/07
- [elpa] master 3ce7df8 49/54: Truncate minibuffer prompts longer than window-width, Oleh Krehel, 2015/10/07
- [elpa] master 78499dd 22/54: Add default values for minibuffer faces, Oleh Krehel, 2015/10/07
- [elpa] master dad8183 23/54: Make the minibuffer faces look nicer, Oleh Krehel, 2015/10/07
- [elpa] master 4b17d9a 27/54: Fix up the "foo ! bar" matching and highlighting, Oleh Krehel, 2015/10/07
- [elpa] master d3f1f2c 18/54: Add extra faces for minibuffer highlighting, Oleh Krehel, 2015/10/07
- [elpa] master 1bf45be 21/54: ivy.el (ivy--format-minibuffer-line): Fix nil regexp, Oleh Krehel, 2015/10/07
- [elpa] master e03d968 50/54: ivy.el (ivy--insert-prompt): Avoid negative length error, Oleh Krehel, 2015/10/07
- [elpa] master 7a2070b 45/54: Fix minibuffer collapse in text mode emacs, Oleh Krehel, 2015/10/07
- [elpa] master ba49407 53/54: counsel.el (counsel-ag-function): Improve for fancy faces, Oleh Krehel, 2015/10/07
- [elpa] master 00d8f08 12/54: counsel.el (counsel-org-tag): Now works in agenda,
Oleh Krehel <=
- [elpa] master 860e276 13/54: Add swiper-multi command, Oleh Krehel, 2015/10/07
- [elpa] master 5269b79 07/54: When initial input contains a plus, escape it, Oleh Krehel, 2015/10/07
- [elpa] master 59908cd 20/54: Make ivy-current blend correctly for fancy minibuffer, Oleh Krehel, 2015/10/07
- [elpa] master 5eac62d 26/54: Move swiper-minibuffer-faces to ivy.el, Oleh Krehel, 2015/10/07
- [elpa] master d374afe 31/54: Set truncate-lines in the minibuffer, Oleh Krehel, 2015/10/07
- [elpa] master a57ac0c 28/54: counsel.el (counsel-unicode-char): Add own history, Oleh Krehel, 2015/10/07
- [elpa] master 1319301 35/54: counsel.el (counsel-yank-pop-truncate): Add group, Oleh Krehel, 2015/10/07
- [elpa] master c4d33d3 36/54: ivy.el (ivy-format-function-default): Fix boundp bug, Oleh Krehel, 2015/10/07
- [elpa] master 7410d2d 29/54: ivy.el (ivy-format-function-default): Handle fringe-mode 0, Oleh Krehel, 2015/10/07
- [elpa] master a019441 41/54: Add autoloads to some important functions, Oleh Krehel, 2015/10/07