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