diff --git a/CHANGELOG.md b/CHANGELOG.md index 0642aa8..72ae124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. +## Unreleased +### Bugs fixed +* The autoloading logic was a bit wrong and would lead to `el-patch` + itself being loaded, just from activating the autoloads. This has + been fixed, so now activating the autoloads does just that, and + `el-patch` itself is only loaded when you actually use an autoloaded + function. + ## 3.1.1 (released 2025-08-15) ### Bugs fixed * Using `el-patch-literal` could result in incorrect patch generation diff --git a/el-patch-stub.el b/el-patch-stub.el index da1a905..0a229fd 100644 --- a/el-patch-stub.el +++ b/el-patch-stub.el @@ -28,7 +28,8 @@ This temporary replacement for the real functionality just takes care of the `declare' forms, and leaves everything else for later." - (unless (fboundp 'el-patch-deftype) + (when (autoloadp (symbol-function 'el-patch-deftype)) + (put 'el-patch-deftype 'orig-function (symbol-function 'el-patch-deftype)) (defmacro el-patch-deftype (type &rest kwargs) (let ((name (intern (format "el-patch-%S" type))) (props (plist-get kwargs :declare))) @@ -37,6 +38,13 @@ later." (put ',name 'doc-string-elt ',(alist-get 'doc-string props)) (put ',name 'lisp-indent-function ',(alist-get 'indent props))))))) +(defun el-patch--deftype-stub-teardown () + "Reset `el-patch-deftype' back to its original value, if needed. +This cleans up for `el-patch--deftype-stub-setup'." + (when-let ((orig (get 'el-patch-deftype 'orig-function))) + (fset 'el-patch-deftype orig) + (put 'el-patch-deftype 'orig-function nil))) + (provide 'el-patch-stub) ;; Local Variables: diff --git a/el-patch.el b/el-patch.el index 64a471f..e4ffa56 100644 --- a/el-patch.el +++ b/el-patch.el @@ -165,6 +165,7 @@ patch." ;;;; Internal variables +;;;###autoload (defvar el-patch-variant nil "Advanced variable for defining patch variants. This variable may be used to define multiple different patches @@ -884,6 +885,8 @@ DEFINITION is a list starting with `defun' or similar." :declare ((doc-string 3) (indent defun))) +;;;###autoload(el-patch--deftype-stub-teardown) + ;;;; Validating patches (defcustom el-patch-pre-validate-hook nil