From 8e9ba476f8262a3e79bd30000ad943462983063e Mon Sep 17 00:00:00 2001 From: User Date: Thu, 9 Apr 2026 18:07:51 +0800 Subject: [PATCH] Config: fix ox-hugo path --- custom.el | 8 +++++++- init.el | 1 + lisp/init-org.el | 37 +++++++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/custom.el b/custom.el index a748ea5..c39d07f 100644 --- a/custom.el +++ b/custom.el @@ -8,7 +8,13 @@ '(ace-window benchmark-init cape cnfonts corfu crux drag-stuff eglot embark-consult everything exec-path-form-shell gcmh hungry-delete marginalia multiple-cursors orderless restart-emacs smart-mode-line solarized-theme vertico)) - '(safe-local-variable-values '((org-use-tag-inheritance))) + '(safe-local-variable-values + '((eval progn + (setq org-hugo-base-dir + (if (eq system-type 'windows-nt) "h:/emacs/hugo/this-is-my-blog/" + "~/org/hugo/this-is-my-blog/")) + (org-hugo-auto-export-mode)) + (org-use-tag-inheritance))) '(warning-suppress-log-types '((initialization)))) (custom-set-faces ;; custom-set-faces was added by Custom. diff --git a/init.el b/init.el index 226597d..da18eca 100644 --- a/init.el +++ b/init.el @@ -18,6 +18,7 @@ (require 'init-elpa) (require 'init-package) (require 'init-org) +(require 'init-org-refile) (require 'init-completion) (require 'init-window) (require 'init-dired) diff --git a/lisp/init-org.el b/lisp/init-org.el index c30feba..321536d 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -305,22 +305,33 @@ See `org-capture-templates' for more information." ":END:" "\n\n") ;Place the cursor here finally "\n"))) - - (add-to-list 'org-capture-templates - '("h" ;`org-capture' binding + h - "Hugo post" - entry - ;; It is assumed that below file is present in `org-directory' - ;; and that it has a "Blog Ideas" heading. It can even be a - ;; symlink pointing to the actual location of all-posts.org! - (file+headline "h:/emacs/hugo/this-is-my-blog/all-blog.org" "Blog Ideas") - (function org-hugo-new-subtree-post-capture-template)))) + (if *is-windows* + (add-to-list 'org-capture-templates + '("h" ;`org-capture' binding + h + "Hugo post" + entry + ;; It is assumed that below file is present in `org-directory' + ;; and that it has a "Blog Ideas" heading. It can even be a + ;; symlink pointing to the actual location of all-posts.org! + (file+headline "h:/emacs/hugo/this-is-my-blog/all-blog.org" "Blog Ideas") + (function org-hugo-new-subtree-post-capture-template))) + (add-to-list 'org-capture-templates + '("h" ;`org-capture' binding + h + "Hugo post" + entry + ;; It is assumed that below file is present in `org-directory' + ;; and that it has a "Blog Ideas" heading. It can even be a + ;; symlink pointing to the actual location of all-posts.org! + (file+headline "~/org/hugo/this-is-my-blog/all-blog.org" "Blog Ideas") + (function org-hugo-new-subtree-post-capture-template))))) ;; 快速部署 (defun my-blog-publish () "Publish blog , git add/commit/push , generate commit message." (interactive) - (let* ((blog-dir "h:/emacs/hugo/this-is-my-blog/") + (let* ((blog-dir (if *is-windows* + "h:/emacs/hugo/this-is-my-blog/" + "~/org/hugo/this-is-my-blog/")) (timestamp (format-time-string "%Y-%m-%d %H:%M:%S")) (default-directory blog-dir)) @@ -349,7 +360,9 @@ See `org-capture-templates' for more information." "Save and preview blog." (interactive) (save-buffer) - (let ((default-directory "h:/emacs/hugo/this-is-my-blog/")) + (let ((default-directory (if *is-windows* + "h:/emacs/hugo/this-is-my-blog/" + "~/org/hugo/this-is-my-blog/"))) ;; 启动 Hugo server (start-process "hugo-server" "*hugo-server*" "hugo" "server" "-D" "--bind" "0.0.0.0" "--port" "1313")