Commit c0507bd226ec

Vincent Demeester <vincent@sbr.pm>
2016-06-29 19:16:37
Update some org-capture stuff
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent b497509
Changed files (1)
.emacs.d
.emacs.d/emacs.org
@@ -1625,6 +1625,22 @@
      (define-key vde/org-map "r" 'org-capture)
    #+END_SRC
 
+   And define some useful function… Mainly add support for allowing
+   prompt input in templates (see [[http://storax.github.io/blog/2016/05/02/org-capture-tricks/][org-capture-tricks]]).
+
+   #+BEGIN_SRC emacs-lisp
+     (defvar oc-capture-prmt-history nil
+       "History of prompt answers for org capture.")
+     (defun oc/prmt (prompt variable)
+       "PROMPT for string, save it to VARIABLE and insert it."
+       (make-local-variable variable)
+       (set variable (read-string (concat prompt ": ") nil oc-capture-prmt-history)))
+     (defun oc/inc (what text &rest fmtvars)
+       "Ask user to include WHAT.  If user agrees return TEXT."
+       (when (y-or-n-p (concat "Include " what "?"))
+         (apply 'format text fmtvars)))
+   #+END_SRC
+
    Setup captures templates..
 
    #+BEGIN_SRC emacs-lisp
@@ -1633,11 +1649,14 @@
              ("t" "Inbox list item" entry
               (file+headline (expand-file-name org-main-file org-todos-directory) "Inbox")
               "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
+             ("d" "Docker task" entry
+              (file+headline (expand-file-name org-main-file org-todos-directory) "Tasks")
+              "* TODO gh:docker/%(oc/prmt \"project\" 'd-prj)#%(oc/prmt \"issue/pr\" 'd-issue) %?%(oc/inc \"feature content\" \" [/]\n- [ ] Implementation\n- [ ] Tests\n- [ ] Docs\")")
              ("z" "Zenika Inbox list item" entry
               (file+headline (expand-file-name org-zenika-file org-todos-directory) "Inbox")
               "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
              ("j" "Journal entry" plain
-              (file+datetree+prompt (exand-file-name org-journal-file org-root-directory))
+              (file+datetree+prompt (expand-file-name org-journal-file org-root-directory))
               "%K - %a\n%i\n%?\n")
              ;; other entries
              ))