radian-software/el-patch

Autoloading a patch

haji-ali opened this issue · 4 comments

Is there a way to define a patch, have it disabled by default and load the patch only when it is enabled for the first time?
In other words, I would like to be able to "autoload" the patch just like my functions are "autoloaded".

You can use with-eval-after-load or use-package, as outlined in the README. Do either of those work for you?

Thanks. As far as I understood from the readme, the method outlined there defines and enables a patch as soon as the package is loaded, isn't that correct?

I am looking for a way to define a patch with an autoload directive (just like a function is defined with ;;;###autoload comment). Then at some point, I want to enable that patch which would then evaluate it.

The scenario I have is that I have many patches for many packages. I want to define those patches and enable them selectively later on. Also, I autoload my function definitions to speed up my startup time, so I want my patches to be similarly autloaded.

I am sorry if my explanation is clumsy, I am not expert in package management/emacs loading so I might be misunderstanding something or confusing fundamental issues.

When you autoload a function, it just means that calling the function loads the package, at which point every function in the package is defined. That's the same as what happens with el-patch in the scenario I described. Emacs does not have a concept of autoloading anything more granular than a package.

Oh I see. That makes sense.

I also now understand that el-patch does not have a patch management system (where patches can be enabled/disabled). So I will have to call el-patch-defun and el-patch-unpatch to add/remove patches accordingly.

Thanks for explaining.