From 4a1d9eee4a103aa7e64b67559799f43d90ed5673 Mon Sep 17 00:00:00 2001 From: MitchMarq42 Date: Tue, 22 Nov 2022 06:42:19 -0900 Subject: [PATCH] Add hugo rebuild hook --- lisp/mitch-packages.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/mitch-packages.el b/lisp/mitch-packages.el index 59f72b0..9686cdb 100644 --- a/lisp/mitch-packages.el +++ b/lisp/mitch-packages.el @@ -648,7 +648,19 @@ See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode :diminish :hook (org-mode . org-pretty-table-mode)) (use-package ox-hugo - :after ox) + :after ox + :config + (defun hugo-dir-above (dir) + "Return path of Hugo project root above or at DIR. +Return nil if DIR is not in a hugo project at all." + (if (eq dir nil) nil + (if (file-exists-p (expand-file-name "config.toml" dir)) dir + (hugo-dir-above (file-name-directory (string-trim-right dir "/")))))) + (add-hook 'after-save-hook + (lambda () (let ((hugo-dir (hugo-dir-above default-directory))) + (if hugo-dir + (let ((default-directory hugo-dir)) + (shell-command "hugo"))))))) ;; fake indentation, other than the other fake indentation (use-package adaptive-wrap