[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master abdbfa7 273/348: counsel.el: Add counsel-org-agenda-headli
From: |
Oleh Krehel |
Subject: |
[elpa] master abdbfa7 273/348: counsel.el: Add counsel-org-agenda-headlines |
Date: |
Sat, 8 Apr 2017 11:04:13 -0400 (EDT) |
branch: master
commit abdbfa790074632800a449b190a8fc8d0770c738
Author: joe di castro <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el: Add counsel-org-agenda-headlines
Fixes #825
---
counsel.el | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/counsel.el b/counsel.el
index 8998314..68a7b17 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3058,6 +3058,67 @@ candidate."
:action #'counsel-command-history-action-eval
:caller 'counsel-command-history))
+;;** `counsel-org-agenda-headlines'
+(defvar org-odd-levels-only)
+(declare-function org-set-startup-visibility "org")
+(declare-function org-show-entry "org")
+(declare-function org-map-entries "org")
+(declare-function org-heading-components "org")
+
+(defun counsel-org-agenda-headlines-action-goto (headline)
+ "Go to the `org-mode' agenda HEADLINE."
+ (find-file (nth 1 headline))
+ (org-set-startup-visibility)
+ (goto-char (nth 2 headline))
+ (org-show-entry))
+
+(ivy-set-actions
+ 'counsel-org-agenda-headlines
+ '(("g" counsel-org-agenda-headlines-action-goto "goto headline")))
+
+(defvar counsel-org-agenda-headlines-history nil
+ "History for `counsel-org-agenda-headlines'.")
+
+(defun counsel-org-agenda-headlines--candidates ()
+ "Return a list of completion candidates for `counsel-org-agenda-headlines'."
+ (org-map-entries
+ (lambda ()
+ (let* ((components (org-heading-components))
+ (level (make-string
+ (if org-odd-levels-only
+ (nth 1 components)
+ (nth 0 components))
+ ?*))
+ (todo (nth 2 components))
+ (priority (nth 3 components))
+ (text (nth 4 components))
+ (tags (nth 5 components)))
+ (list
+ (mapconcat
+ 'identity
+ (cl-remove-if 'null
+ (list
+ level
+ todo
+ (if priority (format "[#%c]" priority))
+ text
+ tags))
+ " ")
+ (buffer-file-name) (point))))
+ nil
+ 'agenda))
+
+;;;###autoload
+(defun counsel-org-agenda-headlines ()
+ "Choose from headers of `org-mode' files in the agenda."
+ (interactive)
+ (let ((minibuffer-allow-text-properties t))
+ (ivy-read "Org headline: "
+ (counsel-org-agenda-headlines--candidates)
+ :action #'counsel-org-agenda-headlines-action-goto
+ :history 'counsel-org-agenda-headlines-history
+ :caller 'counsel-org-agenda-headlines)))
+
;** `counsel-mode'
(defvar counsel-mode-map
(let ((map (make-sparse-keymap)))
- [elpa] master aacba19 229/348: ivy.el (ivy--directory-done): Check if ivy-text is a proper dir, (continued)
- [elpa] master aacba19 229/348: ivy.el (ivy--directory-done): Check if ivy-text is a proper dir, Oleh Krehel, 2017/04/08
- [elpa] master b1f587d 233/348: ivy.el (ivy--directory-done): Fix "RET" on no input, Oleh Krehel, 2017/04/08
- [elpa] master 5190412 234/348: Add `counsel-rg`, Oleh Krehel, 2017/04/08
- [elpa] master 92f2be5 247/348: Fix typo in ivy-read docstring, Oleh Krehel, 2017/04/08
- [elpa] master b99f6de 238/348: ivy.el (ivy--directory-done): Fix when ivy-text exists, Oleh Krehel, 2017/04/08
- [elpa] master 0312d5e 259/348: Make counsel-ag support limiting in files., Oleh Krehel, 2017/04/08
- [elpa] master eddf427 261/348: counsel.el (counsel-ag): Fix byte-compile warning, Oleh Krehel, 2017/04/08
- [elpa] master bb4814a 262/348: Fix counsel-ag support limiting in files, Oleh Krehel, 2017/04/08
- [elpa] master 4232088 265/348: Don't claim `swiper' provides `ivy-mode', Oleh Krehel, 2017/04/08
- [elpa] master ee0d9e3 275/348: ivy.el (ivy--reset-state): Simplify, Oleh Krehel, 2017/04/08
- [elpa] master abdbfa7 273/348: counsel.el: Add counsel-org-agenda-headlines,
Oleh Krehel <=
- [elpa] master 482c3e9 279/348: counsel.el (counsel-ace-link): Use `cdr' for action., Oleh Krehel, 2017/04/08
- [elpa] master e4c248a 278/348: doc/ivy.org: Update package names in ELPA/MELPA, Oleh Krehel, 2017/04/08
- [elpa] master 6e6738c 294/348: counsel.el (counsel-git-grep-cmd-default): Use '%s' quoting, Oleh Krehel, 2017/04/08
- [elpa] master d4e5d79 290/348: counsel.el (counsel-package): Fix sorting issue, Oleh Krehel, 2017/04/08
- [elpa] master 15f89f7 295/348: ivy.el (ivy-minibuffer-map): Bind "C-v" and scroll-up-command, Oleh Krehel, 2017/04/08
- [elpa] master ab6561f 321/348: ivy.el: Use set-ivy-index instead of setq ivy--index, Oleh Krehel, 2017/04/08
- [elpa] master 45383fe 330/348: ivy-overlay.el (ivy-display-function-overlay): Put overlay at symbol start, Oleh Krehel, 2017/04/08
- [elpa] master 1d32ceb 332/348: counsel.el (counsel-irony): New command, Oleh Krehel, 2017/04/08
- [elpa] master ace01d5 347/348: ivy.el (ivy-immediate-done): Fix for rgrep, Oleh Krehel, 2017/04/08
- [elpa] master 2f5bfc0 144/348: counsel.el (counsel-dpkg): New command, Oleh Krehel, 2017/04/08