From 1884828d22606dcf34c21dbe9152d3d749449fe1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 23 Aug 2020 22:25:25 -0400 Subject: [PATCH] Add :shadow parameter to package! For to make replacing built-in packages easier. --- core/core-packages.el | 18 ++++++++++++++++-- modules/lang/org/packages.el | 15 +++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index 309257a3d..e7883e8e2 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -188,10 +188,20 @@ processed." (error "Failed to read any packages")) (dolist (package doom-packages) (cl-destructuring-bind - (name &key recipe disable ignore &allow-other-keys) package + (name &key recipe disable ignore shadow &allow-other-keys) package (unless ignore (if disable (cl-pushnew name doom-disabled-packages) + (when shadow + (straight-override-recipe (cons shadow '(:local-repo nil))) + (let ((site-load-path (copy-sequence doom--initial-load-path)) + lib) + (while (setq + lib (locate-library (concat (symbol-name shadow) ".el") + nil site-load-path)) + (let ((lib (directory-file-name (file-name-directory lib)))) + (setq site-load-path (delete lib site-load-path) + load-path (delete lib load-path)))))) (when recipe (straight-override-recipe (cons name recipe))) (straight-register-package name))))))) @@ -389,7 +399,7 @@ ones." ;;; Module package macros (cl-defmacro package! - (name &rest plist &key built-in recipe ignore _type _pin _disable) + (name &rest plist &key built-in recipe ignore _type _pin _disable _shadow) "Declares a package and how to install it (if applicable). This macro is declarative and does not load nor install packages. It is used to @@ -426,6 +436,10 @@ Accepts the following properties: inform help commands like `doom/help-packages' that this is a built-in package. If set to 'prefer, the package will not be installed if it is already provided by Emacs. + :shadow PACKAGE + Informs Doom that this package is shadowing a built-in PACKAGE; the original + package will be removed from `load-path' to mitigate conflicts, and this new + package will satisfy any dependencies on PACKAGE in the future. Returns t if package is successfully registered, and nil if it was disabled elsewhere." diff --git a/modules/lang/org/packages.el b/modules/lang/org/packages.el index c0787c772..a4973fb1b 100644 --- a/modules/lang/org/packages.el +++ b/modules/lang/org/packages.el @@ -1,12 +1,6 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/org/packages.el -;; Prevent built-in Org from playing into the byte-compilation of -;; `org-plus-contrib'. -(when-let (orglib (locate-library "org" nil doom--initial-load-path)) - (setq load-path (delete (substring (file-name-directory orglib) 0 -1) - load-path))) - ;; HACK A necessary hack because org requires a compilation step after being ;; cloned, and during that compilation a org-version.el is generated with ;; these two functions, which return the output of a 'git describe ...' @@ -27,10 +21,11 @@ :recipe (:host github :repo "emacs-straight/org-mode" :files ("*.el" "lisp/*.el" "contrib/lisp/*.el")) - :pin "220f2b0d93a6927eb673978c0042a1d4673e86aa") -;; ...And prevent other packages from pulling org; org-plus-contrib satisfies -;; the dependency already: https://github.com/raxod502/straight.el/issues/352 -(package! org :recipe (:local-repo nil)) + :pin "220f2b0d93a6927eb673978c0042a1d4673e86aa" + ;; Prevents built-in Org from sneaking into the byte-compilation of + ;; `org-plus-contrib', and inform other packages that `org-mode' satisfies the + ;; `org' dependency: https://github.com/raxod502/straight.el/issues/352 + :shadow 'org) (package! avy) (package! htmlize :pin "49205105898ba8993b5253beec55d8bddd820a70")