From 933816c190633fa1f2f0667ba105d1311572b3c6 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 20 May 2025 07:55:48 -0700 Subject: Autoload org-link handlers This ensures that the org-link handlers are loaded along with org-mode _without_ unnecessarily loading all of nov. --- nov.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/nov.el b/nov.el index db3aedd..f7d071d 100644 --- a/nov.el +++ b/nov.el @@ -1001,6 +1001,7 @@ See also `nov-bookmark-make-record'." ;;; Org interop +;;;###autoload (defun nov-org-link-follow (path) "Follow nov: link designated by PATH." (if (string-match "^\\(.*\\)::\\([0-9]+\\):\\([0-9]+\\)$" path) @@ -1010,6 +1011,7 @@ See also `nov-bookmark-make-record'." (nov--find-file file index point)) (error "Invalid nov.el link"))) +;;;###autoload (defun nov-org-link-store () "Store current EPUB location as nov: link." (when (and (eq major-mode 'nov-mode) nov-file-name) @@ -1034,15 +1036,17 @@ See also `nov-bookmark-make-record'." :publisher (alist-get 'publisher nov-metadata) :description description)))) -(cond - ((fboundp 'org-link-set-parameters) - (org-link-set-parameters - "nov" - :follow 'nov-org-link-follow - :store 'nov-org-link-store)) - ((fboundp 'org-add-link-type) - (org-add-link-type "nov" 'nov-org-link-follow) - (add-hook 'org-store-link-functions 'nov-org-link-store))) +;;;###autoload +(with-eval-after-load 'org + (cond + ((fboundp 'org-link-set-parameters) + (org-link-set-parameters + "nov" + :follow 'nov-org-link-follow + :store 'nov-org-link-store)) + ((fboundp 'org-add-link-type) + (org-add-link-type "nov" 'nov-org-link-follow) + (add-hook 'org-store-link-functions 'nov-org-link-store)))) ;;; Imenu interop -- cgit v1.2.3