about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-06-23T14·25-0400
committerglittershark <grfn@gws.fyi>2020-06-23T14·25+0000
commit9ead20ef9f860cd0eb3acc4397499109db99fb95 (patch)
tree9c89833a349e2ccc0a1983bb243715c609530e30
parent368e8d1eddb8cd95ded7b2f78e4805c67d28ff91 (diff)
feat(g/emacs): Add template for work org files r/1068
This includes an attempt at making this work with auto-insert, but that
didn't seem to have any effect - can just call it manually now

Change-Id: I0eac267b7d3387efd84a2dd0d32b1364fa06f328
Reviewed-on: https://cl.tvl.fyi/c/depot/+/563
Reviewed-by: glittershark <grfn@gws.fyi>
-rw-r--r--users/glittershark/emacs.d/org-config.el22
-rw-r--r--users/glittershark/emacs.d/utils.el13
2 files changed, 35 insertions, 0 deletions
diff --git a/users/glittershark/emacs.d/org-config.el b/users/glittershark/emacs.d/org-config.el
index 2624cf4aad49..634d76476d66 100644
--- a/users/glittershark/emacs.d/org-config.el
+++ b/users/glittershark/emacs.d/org-config.el
@@ -92,3 +92,25 @@
  org-enforce-todo-dependencies nil
 
  org-babel-clojure-backend 'cider)
+
+(defun +grfn/insert-work-template ()
+  (interactive)
+  (goto-char (point-min))
+  (forward-line)
+  (insert "#+TODO: TODO(t) NEXT(n) ACTIVE(a) | DONE(d) PR(p) RUNNING(r) TESTING(D)
+#+TODO: BLOCKED(b) BACKLOG(l) PROPOSED(o) | CANCELLED(c)
+#+FILETAGS: @work
+#+FILETAGS: @work
+#+PROPERTY: Effort_ALL 0 4:00 8:00 12:00 20:00 32:00
+#+PROPERTY: ESTIMATE_ALL 0 1 2 3 5 8
+#+PROPERTY: STORY-TYPE_ALL Feature Bug Chore
+#+PROPERTY: NOBLOCKING t
+#+COLUMNS: %TODO %40ITEM(Task) %17EFFORT(Estimated){:} %CLOCKSUM(Time Spent) %17STORY-TYPE(Type) %TAGS"))
+
+(defun +grfn/insert-org-template ()
+  (interactive)
+  (pcase (buffer-file-name)
+    ((s-contains "/work/") (+grfn/insert-work-template))))
+
+;;; TODO: this doesn't work?
+(define-auto-insert "\\.org?$" #'grfn/insert-org-template t)
diff --git a/users/glittershark/emacs.d/utils.el b/users/glittershark/emacs.d/utils.el
index d6d1d5722b5f..c595b46ce258 100644
--- a/users/glittershark/emacs.d/utils.el
+++ b/users/glittershark/emacs.d/utils.el
@@ -90,3 +90,16 @@ Returns nil if the regex did not match, non-nil otherwise"
         ,@body
         (evil-indent beg (+ (line-end-position) 1))))
      (goto-line-char orig-line-char)))
+
+(pcase-defmacro s-starts-with (prefix)
+  `(pred (s-starts-with-p ,prefix)))
+
+(pcase-defmacro s-contains (needle &optional ignore-case)
+  `(pred (s-contains-p ,needle
+                       ,@(when ignore-case (list ignore-case)))))
+
+(comment
+ (pcase "foo"
+   ((s-contains "bar") 1)
+   ((s-contains "o") 2))
+ )