Try out straight

This commit is contained in:
David Morgan 2022-10-10 16:28:16 +01:00
parent 732d65be39
commit 82a42c2240
Signed by: djm
GPG Key ID: C171251002C200F2
14 changed files with 68 additions and 68 deletions

View File

@ -21,7 +21,8 @@
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(message "%s packages loaded in %0.1f seconds" (message "%s packages loaded in %0.1f seconds"
(length package-activated-list) ;;(length package-activated-list)
(hash-table-count straight--profile-cache)
(string-to-number (emacs-init-time))))) (string-to-number (emacs-init-time)))))
(add-hook 'after-init-hook #'(lambda () (add-hook 'after-init-hook #'(lambda ()

View File

@ -11,8 +11,7 @@
(setq dabbrev-case-fold-search t) (setq dabbrev-case-fold-search t)
(setq dabbrev-case-replace nil)) (setq dabbrev-case-replace nil))
(use-package hippie-expand (use-feature hippie-expand
:ensure nil
:init :init
(setq hippie-expand-try-functions-list (setq hippie-expand-try-functions-list
'(;yas-hippie-try-expand '(;yas-hippie-try-expand

View File

@ -2,8 +2,7 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(use-package dired (use-feature dired
:ensure nil
:config :config
(put 'dired-find-alternate-file 'disabled nil) (put 'dired-find-alternate-file 'disabled nil)
:custom :custom
@ -14,8 +13,7 @@
(dired-kill-when-opening-new-dired-buffer t) (dired-kill-when-opening-new-dired-buffer t)
(wdired-use-dired-vertical-movement 'sometimes)) (wdired-use-dired-vertical-movement 'sometimes))
(use-package dired-x (use-feature dired-x)
:ensure nil)
(use-package dired-subtree (use-package dired-subtree
:config :config

View File

@ -4,7 +4,6 @@
;;; Code: ;;; Code:
(use-package emacs (use-package emacs
:ensure nil
:bind :bind
("C-x \\" . align-regexp) ("C-x \\" . align-regexp)
("C-+" . text-scale-increase) ("C-+" . text-scale-increase)
@ -123,9 +122,8 @@
(undo-tree-history-directory-alist `((".*" . ,temporary-file-directory))) (undo-tree-history-directory-alist `((".*" . ,temporary-file-directory)))
(undo-tree-auto-save-history t)) (undo-tree-auto-save-history t))
(use-package abbrev (use-feature abbrev
:defer 5 :defer 5
:ensure nil
:diminish :diminish
:hook :hook
(text-mode . abbrev-mode) (text-mode . abbrev-mode)
@ -148,8 +146,7 @@
:bind :bind
("C-c ." . operate-on-number-at-point)) ("C-c ." . operate-on-number-at-point))
(use-package xref (use-feature xref
:ensure nil
:custom (xref-search-program 'ripgrep) :custom (xref-search-program 'ripgrep)
:config :config
(defun xref-find-references-other-window (identifier) (defun xref-find-references-other-window (identifier)

View File

@ -5,8 +5,7 @@
(require 'init-lisp) (require 'init-lisp)
(use-package eldoc (use-feature eldoc
:ensure nil
:diminish) :diminish)
(use-package elisp-slime-nav (use-package elisp-slime-nav

View File

@ -31,6 +31,8 @@
#'command-completion-default-include-p)) #'command-completion-default-include-p))
(use-package vertico (use-package vertico
:straight (vertico :files (:defaults "extensions/*")
:includes (vertico-directory vertico-repeat))
:init :init
(vertico-mode) (vertico-mode)
:custom (vertico-cycle t) :custom (vertico-cycle t)
@ -95,8 +97,7 @@ DEFS is a plist associating completion categories to commands."
("C-M-S-g" . minibuffer-really-quit) ("C-M-S-g" . minibuffer-really-quit)
(:map vertico-map ("M-RET" . minibuffer-force-complete-and-exit)))) (:map vertico-map ("M-RET" . minibuffer-force-complete-and-exit))))
(use-package vertico-directory (use-feature vertico-directory
:ensure nil
:after vertico :after vertico
:init :init
(defvar switching-project nil) (defvar switching-project nil)
@ -144,8 +145,7 @@ DEFS is a plist associating completion categories to commands."
;; Tidy shadowed file names ;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-package vertico-repeat (use-feature vertico-repeat
:ensure nil
:bind ("M-P" . vertico-repeat)) :bind ("M-P" . vertico-repeat))
(use-package consult (use-package consult

View File

@ -6,8 +6,7 @@
(column-number-mode t) (column-number-mode t)
;(size-indication-mode t) ; TODO ;(size-indication-mode t) ; TODO
(use-package which-func (use-feature which-func
:ensure nil
:config :config
(which-function-mode 1)) (which-function-mode 1))

View File

@ -2,55 +2,68 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
;; TODO - straight.el? (defvar initial-features features)
(require 'package)
(require 'url)
(setq package-archives '(("melpa" . "https://melpa.org/packages/") (setq package-archives '(("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/") ("melpa-stable" . "https://stable.melpa.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/") ("nongnu" . "https://elpa.nongnu.org/nongnu/")
("elpa" . "https://elpa.gnu.org/packages/"))) ("elpa" . "https://elpa.gnu.org/packages/")))
(setq package-pinned-packages '((cider . "melpa-stable")))
(package-initialize)
(unless package-archive-contents (setq straight-use-package-by-default t
(package-refresh-contents)) straight-vc-git-default-clone-depth 1
straight-check-for-modifications '(find-when-checking check-on-save)
use-package-always-defer t
package-native-compile t)
(setq package-native-compile t) (defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(unless (package-installed-p 'use-package) (straight-use-package 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t ;; https://github.com/radian-software/radian/blob/e3aad124c8e0cc870ed09da8b3a4905d01e49769/emacs/radian.el#L352
use-package-always-defer t) (defmacro use-feature (name &rest args)
"Like `use-package', but with `straight-use-package-by-default' disabled.
`NAME' and `ARGS' are as with `use-package'"
(declare (indent defun))
`(use-package ,name
:straight nil
,@args))
(use-feature straight-x
:commands (straight-x-fetch-all))
(use-package diminish) (use-package diminish)
(use-package epl (defun run-straight-lock-file-function (func)
:if noninteractive "Safely run straight lockfile-related function `FUNC'.
:demand t This will set `features' back the value it had before loading straight, to ensure
:config that everything loaded by `require' or `use-package' is re-loaded."
;; TODO make a copy of the built-in check for system packages work instead (setq features initial-features)
(defvar my/system-packages '(vterm)) (funcall func))
;; emacs -Q --batch -L "~/.emacs.d/lisp/" -l "init-packages.el" -f "my/upgrade-packages"
(defun my/upgrade-packages () (defun my/upgrade-packages ()
(interactive) "Upgrade all packages installed with straight."
(epl-refresh) (interactive)
(when-let ((upgrades (seq-filter (lambda (u) (straight-pull-recipe-repositories) ;; TODO is this needed?
(not (member (straight-x-fetch-all)
(epl-package-name (epl-upgrade-available u)) (straight-merge-all)
my/system-packages))) (straight-check-all)
(epl-find-upgrades)))) ;; Do this automatically, as we can always revert and thaw
;; TODO why doesn't this work? (run-straight-lock-file-function 'straight-freeze-versions))
;; (epl-upgrade (mapcar 'epl-upgrade-available upgrades)
(dolist (upgrade upgrades) (defun my/thaw-packages ()
(epl-package-install (epl-upgrade-available upgrade) 'force) "Restore all packages to the versions in the straight lockfile."
(epl-package-delete (epl-upgrade-installed upgrade)))) (interactive)
(message "Package upgrade finished.") (run-straight-lock-file-function 'straight-thaw-versions))
;; TODO does this help async native-comp to finish when called from the command line?
(sit-for 30)))
(provide 'init-packages) (provide 'init-packages)
;;; init-packages.el ends here ;;; init-packages.el ends here

View File

@ -5,7 +5,6 @@
(require 'subr-x) (require 'subr-x)
(use-package project (use-package project
:ensure nil
:config :config
(defun project--clojure-switch-to-test (filename project-root) (defun project--clojure-switch-to-test (filename project-root)
(let* ((project-src-file (string-remove-prefix project-root filename)) (let* ((project-src-file (string-remove-prefix project-root filename))

View File

@ -2,8 +2,7 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(use-package isearch (use-feature isearch
:ensure nil
:custom :custom
(search-whitespace-regexp ".*\\b") (search-whitespace-regexp ".*\\b")
(isearch-lax-whitespace t) (isearch-lax-whitespace t)

View File

@ -2,8 +2,7 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(use-package sql (use-feature sql
:ensure nil
:commands add-sql-connection :commands add-sql-connection
:config :config
;; partially inspired by https://dev.to/viglioni/emacs-as-sql-client-with-lsp-143l (but currently only works for postgres) ;; partially inspired by https://dev.to/viglioni/emacs-as-sql-client-with-lsp-143l (but currently only works for postgres)

View File

@ -2,9 +2,8 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(use-package tramp (use-feature tramp
:defer 5 :defer 5
:ensure nil
:custom :custom
(tramp-default-method "ssh") (tramp-default-method "ssh")
(vc-ignore-dir-regexp (vc-ignore-dir-regexp

View File

@ -56,8 +56,7 @@
("C-S-<left>" . buf-move-left) ("C-S-<left>" . buf-move-left)
("C-S-<right>" . buf-move-right))) ("C-S-<right>" . buf-move-right)))
(use-package uniquify (use-feature uniquify
:ensure nil
:custom :custom
(uniquify-buffer-name-style 'forward)) (uniquify-buffer-name-style 'forward))

View File

@ -3,8 +3,7 @@
;; Based on prelude-xml.el ;; Based on prelude-xml.el
;;; Code: ;;; Code:
(use-package nxml-mode (use-feature nxml-mode
:ensure nil
:config :config
(push '("<\\?xml" . nxml-mode) magic-mode-alist) (push '("<\\?xml" . nxml-mode) magic-mode-alist)
(add-to-list 'auto-mode-alist '("\\.pom\\'" . nxml-mode)) (add-to-list 'auto-mode-alist '("\\.pom\\'" . nxml-mode))