diff --git a/README.md b/README.md index 817f780..52efbf9 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [The `counsel-projectile-ag` command](#the-counsel-projectile-ag-command) - [The `counsel-projectile-rg` command](#the-counsel-projectile-rg-command) - [The `counsel-projectile-org-capture` command](#the-counsel-projectile-org-capture-command) + - [The `counsel-projectile-org-agenda` command](#the-counsel-projectile-org-agenda-command) - [Configuration](#configuration) - [Enabling counsel-projectile mode when emacs starts](#enabling-counsel-projectile-mode-when-emacs-starts) - [Customizing action lists](#customizing-action-lists) @@ -71,7 +72,8 @@ New commands: | :------------------- | :------------------------------- | :-------------------------------------------------- | | C-c p SPC | `counsel-projectile` | Jump to a project buffer or file, or switch project | | C-c p s r | `counsel-projectile-rg` | Search project with rg | -| C-c p O | `counsel-projectile-org-capture` | Org-capture into project | +| C-c p O c | `counsel-projectile-org-capture` | Org-capture into project | +| C-c p O a | `counsel-projectile-org-capture` | Open project agenda | ## The `counsel-projectile` command Default key binding: C-c p SPC. @@ -169,9 +171,13 @@ Default key binding: C-c p s r. This command is similar to `counsel-projectile-grep` (see above) but uses `rg` (ripgrep) instead of `grep`. ## The `counsel-projectile-org-capture` command -Default key binding: C-c p O. +Default key binding: C-c p O c. This command lets you capture something (a note, todo item, ...) into the current project using org-mode's `org-capture` (actually `counsel-org-capture`) command. Like `org-capture`, it first lets you select a capture template then file the newly captured information. By default, there is a single template storing the captured information into file `notes.org` in the project root directory, under headline `Tasks`. +## The `counsel-projectile-org-agenda` command +Default key binding: C-c p O a. + +This command opens the current projects agenda. It simply calls `org-agenda` after filtering out all agenda files that do not belong to the current project. # Configuration ## Enabling counsel-projectile mode when emacs starts To automatically enable counsel-projectile mode when emacs starts, you can either use the Customize interface to toggle on the variable `counsel-projectile-mode` and save your customization, or add `(counsel-projectile-mode)` to your init file. diff --git a/counsel-projectile.el b/counsel-projectile.el index 187a263..0015a49 100644 --- a/counsel-projectile.el +++ b/counsel-projectile.el @@ -945,6 +945,25 @@ capture." (with-current-buffer (or from-buffer (current-buffer)) (counsel-org-capture)))) +;;;; counsel-projectile-org-agenda + +;;;###autoload +(defun counsel-projectile-org-agenda (&optional arg org-keys restriction) + "Open project agenda. + +This command simply calls `org-agenda' after filtering out all +agenda files that do not belong to the current project. + +Optional arguments ARG, ORG-KEYS, and RESTRICTION are as in +`org-agenda'." + (interactive "P") + (let* ((root (projectile-project-root)) + (org-agenda-files + (cl-remove-if-not (lambda (file) + (string-prefix-p root file)) + (org-agenda-files t 'ifmode)))) + (org-agenda arg org-keys restriction))) + ;;;; counsel-projectile-switch-project (defcustom counsel-projectile-sort-projects nil @@ -1002,8 +1021,10 @@ candidates list of `counsel-projectile-switch-project'." "invoke eshell from project root") ("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root") - ("O" counsel-projectile-switch-project-action-org-capture - "org-capture into project")) + ("Oc" counsel-projectile-switch-project-action-org-capture + "capture into project") + ("Oa" counsel-projectile-switch-project-action-org-capture + "open project agenda")) 'counsel-projectile) (defun counsel-projectile-switch-project-by-name (project) @@ -1318,7 +1339,8 @@ If not inside a project, call `counsel-projectile-switch-project'." (let ((map (make-sparse-keymap))) (set-keymap-parent map projectile-command-map) (define-key map (kbd "s r") 'counsel-projectile-rg) - (define-key map (kbd "O") 'counsel-projectile-org-capture) + (define-key map (kbd "O c") 'counsel-projectile-org-capture) + (define-key map (kbd "O a") 'counsel-projectile-org-agenda) (define-key map (kbd "SPC") 'counsel-projectile) map) "Keymap for Counesl-Projectile commands after `projectile-keymap-prefix'.")