Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2025-12-25 Mats Lidell <matsl@gnu.org>

* hywiki.el (hywiki--preparation-function, hywiki--completion-function)
(hywiki-org-make-publish-project-alist): Use prepare and complete
project attributes to control use of hywiki-org-export-function with
org-export-before-parsing-functions. (Used before as advice on
org-element--generate-copy-script now removed since it affected other
export project.)
(hywiki-org-export-function): Remove old stack guard since function is
now called in another context.

2025-12-24 Mats Lidell <matsl@gnu.org>

* hywiki.el (hywiki-reference-to-org-link): Refactor to handle pathname
Expand Down
22 changes: 15 additions & 7 deletions hywiki.el
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ where PATH is the un-resolvable reference."
:type 'string
:group 'hyperbole-hywiki)

(defun hywiki--preparation-function (_project-plist)
"Setup export hook functions."
(message "Hywiki export is in preparation.")
(add-hook 'org-export-before-parsing-functions #'hywiki-org-export-function))

(defun hywiki--completion-function (_project-plist)
"Remove export hook function."
(remove-hook 'org-export-before-parsing-functions #'hywiki-org-export-function)
(message "Hywiki export is completed."))

(defvar hywiki-org-publish-project-alist nil
"HyWiki-specific export properties added to `org-publish-project-alist'.")

Expand All @@ -432,6 +442,8 @@ where PATH is the un-resolvable reference."
hywiki-org-publish-project-alist
(list
"hywiki"
:preparation-function 'hywiki--preparation-function
:completion-function 'hywiki--completion-function
:auto-sitemap t
:base-directory (expand-file-name hywiki-directory)
:html-head (format
Expand Down Expand Up @@ -2831,12 +2843,11 @@ save and potentially set `hywiki--directory-mod-time' and
(org-publish-property :base-directory (hywiki-org-get-publish-project))))

(defun hywiki-org-export-function (&rest _)
"Add to `write-contents-functions' to convert HyWikiWord links to Org links.
This is done automatically by loading HyWiki."
"Convert HyWikiWord links to Org links and add title if missing.
Do not convert the index file."
(require 'org-element)
(when (and (derived-mode-p 'org-mode)
(not (string= (hywiki--sitemap-file) (buffer-file-name)))
(hyperb:stack-frame '(org-export-copy-buffer)))
(not (string= (hywiki--sitemap-file) (buffer-file-name))))
(hywiki-references-to-org-links)
(hywiki-org-maybe-add-title)))

Expand Down Expand Up @@ -3861,9 +3872,6 @@ This must be called within a `save-excursion' or it may move point."

(add-hook 'kill-buffer-hook 'hywiki-kill-buffer-hook)

(eval-after-load "org-element"
'(advice-add 'org-element--generate-copy-script :before #'hywiki-org-export-function))

;; Use for its side effects, setting variables
(eval-after-load "ox-publish" '(hywiki-org-get-publish-project))

Expand Down