about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--+commands.el8
-rw-r--r--config.el59
2 files changed, 67 insertions, 0 deletions
diff --git a/+commands.el b/+commands.el
index 9b4a685e1c8c..4025a9504a42 100644
--- a/+commands.el
+++ b/+commands.el
@@ -115,6 +115,14 @@
 ;; Org-mode
 (ex! "cap"         #'+org-capture/dwim)
 
+(ex! "arev" #'generate-alembic-migration)
+
+(evil-define-command evil-alembic-upgrade (&optional revision)
+  (interactive "<a>")
+  (alembic-upgrade revision))
+
+(ex! "aup" #'evil-alembic-upgrade)
+
 ;; Elixir
 (add-hook! elixir-mode
   (ex! "AV" #'alchemist-project-toggle-file-and-tests-other-window)
diff --git a/config.el b/config.el
index 04f1ea704eeb..20df1d0ebf5b 100644
--- a/config.el
+++ b/config.el
@@ -923,4 +923,63 @@
 
 (def-package! ob-async)
 
+(def-package! org-recent-headings
+  :after (org)
+  :config
+  (map! :n "SPC n r" #'org-recent-headings-ivy))
+
+(def-package! org-sticky-header
+  :after (org)
+  :hook (org-mode-hook . org-sticky-header-mode)
+  :config
+  (setq-default org-sticky-header-heading-star "●"))
+
 (enable-theme 'grfn-solarized-light)
+
+;;; word-char
+(add-hook! prog-mode
+  (modify-syntax-entry ?_ "w"))
+
+(add-hook! lisp-mode
+  (modify-syntax-entry ?- "w"))
+
+(after! flycheck
+  (put 'flycheck-python-pylint-executable 'safe-local-variable (lambda (_) t)))
+
+(defvar alembic-command "alembic"
+  "Command to execute when running alembic")
+
+(defvar alembic-dir-fun (lambda () default-directory)
+  "Reference to a function whose return value will be used as the directory to
+  run Alembic in")
+
+(comment
+ (+grfn/extract-alembic-migration-name
+   "Generating
+/home/griffin/code/urb/grid/backend/src/grid/migrations/versions/15fb1b518507_test.py
+... done"))
+
+(defun +grfn/extract-alembic-migration-name (output)
+  (string-match (rx (0+ anything) "Generating "
+                    (group (one-or-more (not (syntax whitespace))))
+                    " ... done"
+                    (0+ anything))
+                output)
+  (match-string-no-properties 1 output))
+
+(defun generate-alembic-migration (msg)
+  (interactive "sMessage: ")
+  (let* ((default-directory (funcall alembic-dir-fun))
+         (out (shell-command-to-string
+               (format "%s revision -m \"%s\""
+                       alembic-command
+                       msg)))
+         (migration-name (+grfn/extract-alembic-migration-name out)))
+    (find-file-other-window migration-name)))
+
+(defun alembic-upgrade (&optional revision)
+  (let ((default-directory (funcall alembic-dir-fun)))
+    (message
+     (shell-command-to-string (format "%s upgrade %s"
+                                      alembic-command
+                                      (or revision "head"))))))