General, minor refactors in doom core
This commit is contained in:
parent
dadd54604b
commit
99fc55f75c
4 changed files with 65 additions and 70 deletions
|
@ -88,16 +88,16 @@ declaration) or dependency thereof that hasn't already been."
|
||||||
(condition-case-unless-debug e
|
(condition-case-unless-debug e
|
||||||
(progn
|
(progn
|
||||||
(straight-use-package (intern package))
|
(straight-use-package (intern package))
|
||||||
(when-let* ((newcommit (cdr (assoc local-repo doom-pinned-packages)))
|
(when-let* ((target-ref (cdr (assoc local-repo doom-pinned-packages)))
|
||||||
(oldcommit (straight-vc-get-commit type local-repo)))
|
(ref (straight-vc-get-commit type local-repo)))
|
||||||
(unless (string-match-p (concat "^" newcommit) oldcommit)
|
(unless (doom--same-commit target-ref ref)
|
||||||
(unless (straight-vc-commit-present-p recipe newcommit)
|
(unless (straight-vc-commit-present-p recipe target-ref)
|
||||||
(straight-vc-fetch-from-remote recipe))
|
(straight-vc-fetch-from-remote recipe))
|
||||||
(if (straight-vc-commit-present-p recipe newcommit)
|
(if (straight-vc-commit-present-p recipe target-ref)
|
||||||
(progn
|
(progn
|
||||||
(print! (success "Checking out %s to %s")
|
(print! (success "Checking out %s to %s")
|
||||||
package (doom--abbrev-commit newcommit))
|
package (doom--abbrev-commit target-ref))
|
||||||
(straight-vc-check-out-commit recipe newcommit)
|
(straight-vc-check-out-commit recipe target-ref)
|
||||||
(straight-rebuild-package package t))
|
(straight-rebuild-package package t))
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(delete-directory (straight--repos-dir package) 'recursive))
|
(delete-directory (straight--repos-dir package) 'recursive))
|
||||||
|
@ -142,27 +142,26 @@ declaration) or dependency thereof that hasn't already been."
|
||||||
"Updates packages."
|
"Updates packages."
|
||||||
(straight--transaction-finalize)
|
(straight--transaction-finalize)
|
||||||
(print! (start "Updating packages (this may take a while)..."))
|
(print! (start "Updating packages (this may take a while)..."))
|
||||||
(let* ((straight--repos-dir (straight--repos-dir))
|
(let* ((repo-dir (straight--repos-dir))
|
||||||
(packages-to-rebuild (make-hash-table :test 'equal))
|
(packages-to-rebuild (make-hash-table :test 'equal))
|
||||||
(repos-to-rebuild (make-hash-table :test 'equal))
|
(repos-to-rebuild (make-hash-table :test 'equal))
|
||||||
(recipes (doom-package-recipe-list))
|
(recipes (doom-package-recipe-list))
|
||||||
(total (length recipes))
|
(total (length recipes))
|
||||||
(esc (if doom-debug-mode "" "\033[1A"))
|
(esc (unless doom-debug-mode "\033[1A"))
|
||||||
(i 0)
|
(i 0)
|
||||||
errors)
|
errors)
|
||||||
;; TODO Log this somewhere?
|
|
||||||
(doom-with-package-recipes recipes (recipe package type local-repo)
|
(doom-with-package-recipes recipes (recipe package type local-repo)
|
||||||
(cl-incf i)
|
(cl-incf i)
|
||||||
(print-group!
|
(print-group!
|
||||||
(unless (straight--repository-is-available-p recipe)
|
(unless (straight--repository-is-available-p recipe)
|
||||||
(print! (error "(%d/%d) Couldn't find local repo for %s!") i total package)
|
(print! (error "(%d/%d) Couldn't find local repo for %s") i total package)
|
||||||
(cl-return))
|
(cl-return))
|
||||||
(when (gethash local-repo repos-to-rebuild)
|
(when (gethash local-repo repos-to-rebuild)
|
||||||
(puthash package t packages-to-rebuild)
|
(puthash package t packages-to-rebuild)
|
||||||
(print! (success "(%d/%d) %s was updated indirectly (with %s)") i total package local-repo)
|
(print! (success "(%d/%d) %s was updated indirectly (with %s)") i total package local-repo)
|
||||||
(cl-return))
|
(cl-return))
|
||||||
(let ((default-directory (straight--repos-dir local-repo)))
|
(let ((default-directory (straight--repos-dir local-repo)))
|
||||||
(unless (file-in-directory-p default-directory straight--repos-dir)
|
(unless (file-in-directory-p default-directory repo-dir)
|
||||||
(print! (warn "(%d/%d) Skipping %s because it is local") i total package)
|
(print! (warn "(%d/%d) Skipping %s because it is local") i total package)
|
||||||
(cl-return))
|
(cl-return))
|
||||||
(condition-case-unless-debug e
|
(condition-case-unless-debug e
|
||||||
|
@ -180,7 +179,7 @@ declaration) or dependency thereof that hasn't already been."
|
||||||
(cl-return))))
|
(cl-return))))
|
||||||
|
|
||||||
((doom--same-commit-p target-ref ref)
|
((doom--same-commit-p target-ref ref)
|
||||||
(print! (success "\033[K(%d/%d) %s is up-to-date...%s") i total package esc)
|
(print! (info "\033[K(%d/%d) %s is up-to-date...%s") i total package esc)
|
||||||
(cl-return))
|
(cl-return))
|
||||||
|
|
||||||
((straight-vc-commit-present-p recipe target-ref)
|
((straight-vc-commit-present-p recipe target-ref)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;; core/cli/upgrade.el -*- lexical-binding: t; -*-
|
;;; core/cli/upgrade.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(defcli! (upgrade up)
|
(defcli! (upgrade up)
|
||||||
((force-p ["-f" "--force"] "Discard local changes to Doom and upgrade anyway")
|
((force-p ["-f" "--force"] "Discard local changes to Doom and packages, and upgrade anyway")
|
||||||
(packages-only-p ["-p" "--packages"] "Only upgrade packages, not Doom"))
|
(packages-only-p ["-p" "--packages"] "Only upgrade packages, not Doom"))
|
||||||
"Updates Doom and packages.
|
"Updates Doom and packages.
|
||||||
|
|
||||||
|
@ -14,16 +14,17 @@ following shell commands:
|
||||||
bin/doom refresh
|
bin/doom refresh
|
||||||
bin/doom update"
|
bin/doom update"
|
||||||
:bare t
|
:bare t
|
||||||
(if (delq
|
(let ((doom-auto-discard force-p))
|
||||||
nil (list
|
(if (delq
|
||||||
(unless packages-only-p
|
nil (list
|
||||||
(doom-cli-upgrade doom-auto-accept force-p))
|
(unless packages-only-p
|
||||||
(doom-cli-execute "refresh")
|
(doom-cli-upgrade doom-auto-accept doom-auto-discard))
|
||||||
(when (doom-cli-packages-update)
|
(doom-cli-execute "refresh")
|
||||||
(doom-cli-reload-package-autoloads)
|
(when (doom-cli-packages-update)
|
||||||
t)))
|
(doom-cli-reload-package-autoloads)
|
||||||
(print! (success "Done! Restart Emacs for changes to take effect."))
|
t)))
|
||||||
(print! "Nothing to do. Doom is up-to-date!")))
|
(print! (success "Done! Restart Emacs for changes to take effect."))
|
||||||
|
(print! "Nothing to do. Doom is up-to-date!"))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -150,19 +150,7 @@ necessary package metadata is initialized and available for them."
|
||||||
(when (or force-p (not doom-packages))
|
(when (or force-p (not doom-packages))
|
||||||
(doom-log "Initializing straight")
|
(doom-log "Initializing straight")
|
||||||
(setq doom-init-packages-p t)
|
(setq doom-init-packages-p t)
|
||||||
(unless (fboundp 'straight--reset-caches)
|
(doom-ensure-straight)
|
||||||
(doom-ensure-straight)
|
|
||||||
(require 'straight))
|
|
||||||
(straight--reset-caches)
|
|
||||||
(setq straight-recipe-repositories nil
|
|
||||||
straight-recipe-overrides nil)
|
|
||||||
(mapc #'straight-use-recipes doom-core-package-sources)
|
|
||||||
(straight-register-package
|
|
||||||
`(straight :type git :host github
|
|
||||||
:repo ,(format "%s/straight.el" straight-repository-user)
|
|
||||||
:files ("straight*.el")
|
|
||||||
:branch ,straight-repository-branch
|
|
||||||
:no-byte-compile t))
|
|
||||||
(mapc #'straight-use-package doom-core-packages)
|
(mapc #'straight-use-package doom-core-packages)
|
||||||
(doom-log "Initializing doom-packages")
|
(doom-log "Initializing doom-packages")
|
||||||
(setq doom-disabled-packages nil
|
(setq doom-disabled-packages nil
|
||||||
|
@ -199,24 +187,35 @@ necessary package metadata is initialized and available for them."
|
||||||
|
|
||||||
(defun doom-ensure-straight ()
|
(defun doom-ensure-straight ()
|
||||||
"Ensure `straight' is installed and was compiled with this version of Emacs."
|
"Ensure `straight' is installed and was compiled with this version of Emacs."
|
||||||
(defvar bootstrap-version)
|
(unless (fboundp 'straight--reset-caches)
|
||||||
(let* (;; Force straight to install into ~/.emacs.d/.local/straight instead of
|
(defvar bootstrap-version)
|
||||||
;; ~/.emacs.d/straight by pretending `doom-local-dir' is our .emacs.d.
|
(let* (;; Force straight to install into ~/.emacs.d/.local/straight instead of
|
||||||
(user-emacs-directory straight-base-dir)
|
;; ~/.emacs.d/straight by pretending `doom-local-dir' is our .emacs.d.
|
||||||
(bootstrap-file (doom-path straight-base-dir "straight/repos/straight.el/straight.el"))
|
(user-emacs-directory straight-base-dir)
|
||||||
(bootstrap-version 5))
|
(bootstrap-file (doom-path straight-base-dir "straight/repos/straight.el/straight.el"))
|
||||||
(make-directory (doom-path straight-base-dir "straight/build") 'parents)
|
(bootstrap-version 5))
|
||||||
(unless (featurep 'straight)
|
(make-directory (doom-path straight-base-dir "straight/build") 'parents)
|
||||||
(unless (or (require 'straight nil t)
|
(or (require 'straight nil t)
|
||||||
(file-readable-p bootstrap-file))
|
(file-readable-p bootstrap-file)
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
(url-retrieve-synchronously
|
(url-retrieve-synchronously
|
||||||
(format "https://raw.githubusercontent.com/raxod502/straight.el/%s/install.el"
|
(format "https://raw.githubusercontent.com/raxod502/straight.el/%s/install.el"
|
||||||
straight-repository-branch)
|
straight-repository-branch)
|
||||||
'silent 'inhibit-cookies)
|
'silent 'inhibit-cookies)
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(eval-print-last-sexp)))
|
(eval-print-last-sexp)))
|
||||||
(load bootstrap-file nil t))))
|
(load bootstrap-file nil t))
|
||||||
|
(require 'straight))
|
||||||
|
(straight--reset-caches)
|
||||||
|
(setq straight-recipe-repositories nil
|
||||||
|
straight-recipe-overrides nil)
|
||||||
|
(mapc #'straight-use-recipes doom-core-package-sources)
|
||||||
|
(straight-register-package
|
||||||
|
`(straight :type git :host github
|
||||||
|
:repo ,(format "%s/straight.el" straight-repository-user)
|
||||||
|
:files ("straight*.el")
|
||||||
|
:branch ,straight-repository-branch
|
||||||
|
:no-byte-compile t)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -244,7 +243,6 @@ Accepts the following properties:
|
||||||
:ignore FORM
|
:ignore FORM
|
||||||
Do not install this package.
|
Do not install this package.
|
||||||
:pin STR|nil
|
:pin STR|nil
|
||||||
(NOT IMPLEMENTED YET)
|
|
||||||
Pin this package to commit hash STR. Setting this to nil will unpin this
|
Pin this package to commit hash STR. Setting this to nil will unpin this
|
||||||
package if previously pinned.
|
package if previously pinned.
|
||||||
:built-in BOOL|'prefer
|
:built-in BOOL|'prefer
|
||||||
|
|
25
core/core.el
25
core/core.el
|
@ -34,8 +34,6 @@
|
||||||
;; Load the bare necessities
|
;; Load the bare necessities
|
||||||
(require 'core-lib)
|
(require 'core-lib)
|
||||||
|
|
||||||
(autoload 'doom-initialize-packages "core-packages")
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Global variables
|
;;; Global variables
|
||||||
|
@ -448,18 +446,17 @@ unreadable. Returns the names of envvars that were changed."
|
||||||
(point-max))))
|
(point-max))))
|
||||||
environment)))
|
environment)))
|
||||||
(when environment
|
(when environment
|
||||||
(setq-default
|
(setq process-environment
|
||||||
process-environment
|
(append (nreverse environment) process-environment)
|
||||||
(append (nreverse environment) process-environment)
|
exec-path
|
||||||
exec-path
|
(if (member "PATH" envvars)
|
||||||
(if (member "PATH" envvars)
|
(append (split-string (getenv "PATH") path-separator t)
|
||||||
(append (split-string (getenv "PATH") path-separator t)
|
(list exec-directory))
|
||||||
(list exec-directory))
|
exec-path)
|
||||||
exec-path)
|
shell-file-name
|
||||||
shell-file-name
|
(if (member "SHELL" envvars)
|
||||||
(if (member "SHELL" envvars)
|
(or (getenv "SHELL") shell-file-name)
|
||||||
(or (getenv "SHELL") shell-file-name)
|
shell-file-name))
|
||||||
shell-file-name))
|
|
||||||
envvars))))
|
envvars))))
|
||||||
|
|
||||||
(defun doom-initialize (&optional force-p noerror)
|
(defun doom-initialize (&optional force-p noerror)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue