+;;; Package management
+
+;; No package.el (for emacs 26 and before, uncomment the following)
+;; Not necessary when using straight.el
+;; (C-h v straight-package-neutering-mode RET)
+
+(when (and
+ (not (featurep 'straight))
+ (version< emacs-version "27"))
+ (setq package-enable-at-startup nil)
+ ;; (package-initialize)
+ )
+
+;; for emacs 27 and later, we use early-init.el. see
+;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
+
+;; straight.el
+
+;; Main engine start...
+
+(setq straight-repository-branch "develop"
+ straight-check-for-modifications '(check-on-save find-when-checking))
+
+(defun b/bootstrap-straight ()
+ (defvar bootstrap-version)
+ (let ((bootstrap-file
+ (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
+ (bootstrap-version 5))
+ (unless (file-exists-p bootstrap-file)
+ (with-current-buffer
+ (url-retrieve-synchronously
+ "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
+ 'silent 'inhibit-cookies)
+ (goto-char (point-max))
+ (eval-print-last-sexp)))
+ (load bootstrap-file nil 'nomessage)))
+
+;; Solid rocket booster ignition...
+
+(b/bootstrap-straight)
+
+;; We have lift off!
+
+(setq straight-use-package-by-default t)
+
+(defmacro use-feature (name &rest args)
+ "Like `use-package', but with `straight-use-package-by-default' disabled."
+ (declare (indent 1))
+ `(use-package ,name
+ :straight nil
+ ,@args))
+
+(with-eval-after-load 'use-package-core
+ (let ((upflk (car use-package-font-lock-keywords)))
+ (font-lock-add-keywords
+ 'emacs-lisp-mode
+ `((,(replace-regexp-in-string
+ "use-package" "use-feature"
+ (car upflk))
+ ,@(cdr upflk))))))
+
+(with-eval-after-load 'recentf
+ (add-to-list 'recentf-exclude
+ (expand-file-name "~/.emacs.d/straight/build/")))
+
+(defun b/reload-init ()
+ "Reload init.el."
+ (interactive)
+ (setq b/file-name-handler-alist file-name-handler-alist)
+ (load user-init-file nil 'nomessage)
+ (b/post-init))
+
+;; use-package
+(straight-use-package 'use-package)
+