jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.42k stars 260 forks source link

function opposite of use-package-always-ensure? #1043

Closed sg-qwt closed 1 year ago

sg-qwt commented 1 year ago

Hi there,

Wondering if there's any variable setup can do the exact opposite of use-package-always-ensure?

Use case: I'm using other methods to manage elisp packages, thus I want to completely prevent use-package from downloading packages on its own, even if I accidentally copied some use-package snippet from online with :ensure t.

I only use use-package to manage configs this case. Something like use-package-always-no-install maybe?

Thanks!

conao3 commented 1 year ago

:ensure is handled by use-package-handler/:ensure function. So, you can re-define this function as an empty function, :ensure should be a no-meaning keyword.

demo

(use-package neoemacs :ensure t)
;;=> (error "Package 'neoemacs' is unavailable")

(defalias 'use-package-handler/:ensure 'ignore)
;;=> use-package-handler/:ensure

(use-package neoemacs :ensure t)
;;=> nil

hope this helps.

sg-qwt commented 1 year ago

:ensure is handled by use-package-handler/:ensure function. So, you can re-define this function as an empty function, :ensure should be a no-meaning keyword.

demo

(use-package neoemacs :ensure t)
;;=> (error "Package 'neoemacs' is unavailable")

(defalias 'use-package-handler/:ensure 'ignore)
;;=> use-package-handler/:ensure

(use-package neoemacs :ensure t)
;;=> nil

hope this helps.

That would do the trick. Thanks for this! Appreciated!