Hugo recompile on save
This commit is contained in:
parent
3c91283f03
commit
102c4d447f
@ -657,11 +657,19 @@ 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 "/"))))))
|
||||
(defun hugo-compile (dir)
|
||||
(let ((hugo-dir (hugo-dir-above dir)))
|
||||
(if hugo-dir
|
||||
(let* ((default-directory hugo-dir)
|
||||
(buffer (get-buffer-create "*hugo*")))
|
||||
(pop-to-buffer buffer)
|
||||
(compilation-mode)
|
||||
(if (zerop (let ((inhibit-read-only t))
|
||||
(call-process "sh" nil buffer t "-c" "hugo")))
|
||||
(message "Hugo re-generated!")
|
||||
(error "Hugo Failed, better change something!"))))))
|
||||
(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")))))))
|
||||
(lambda () (hugo-compile default-directory))))
|
||||
|
||||
;; fake indentation, other than the other fake indentation
|
||||
(use-package adaptive-wrap
|
||||
|
Loading…
Reference in New Issue
Block a user