cp-org-capture: Allow placing project templates after general ones

A new variable `counsel-projectile-org-capture-templates-first-p` is
created.

Fixes #146
This commit is contained in:
Eric Danan 2020-02-14 14:50:43 +00:00
parent 47fcb4e0eb
commit b556ed8995

View file

@ -1059,6 +1059,11 @@ The format is the same as in `org-capture-templates-contexts'."
(string :tag " name"))) (string :tag " name")))
:group 'counsel-projectile) :group 'counsel-projectile)
(defcustom counsel-projectile-org-capture-templates-first-p t
"Non-nil if `counsel-projectile-org-capture' should display templates from `counsel-projectile-org-capture-templates' before those from `org-capture-templates'."
:type 'boolean
:group 'counsel-projectile)
(defvar counsel-projectile--org-capture-templates-backup nil (defvar counsel-projectile--org-capture-templates-backup nil
"Stores a backup of `org-capture-templates'.") "Stores a backup of `org-capture-templates'.")
@ -1094,6 +1099,8 @@ capture."
org-capture-templates-contexts)) org-capture-templates-contexts))
(org-capture-templates (org-capture-templates
(append (append
(unless counsel-projectile-org-capture-templates-first-p
org-capture-templates)
(when root (when root
(cl-loop (cl-loop
with replace-fun = `(lambda (string) with replace-fun = `(lambda (string)
@ -1118,7 +1125,8 @@ capture."
collect x) collect x)
else else
collect item))) collect item)))
org-capture-templates))) (when counsel-projectile-org-capture-templates-first-p
org-capture-templates))))
(ivy-add-actions (ivy-add-actions
'counsel-org-capture 'counsel-org-capture
counsel-projectile-org-capture-extra-actions) counsel-projectile-org-capture-extra-actions)