Emacs: Switch to straight for package management.

This commit is contained in:
tastytea 2020-03-15 23:38:06 +01:00
parent 7fdc0b06ab
commit b24cde35d3
14 changed files with 84 additions and 112 deletions

View File

@ -33,7 +33,7 @@
;; Icon font (required by doom and others).
(use-package all-the-icons
:pin melpa ; We need > 3.2.0 for all-the-icons-ivy-rich (issue #4).
;; :pin melpa ; We need > 3.2.0 for all-the-icons-ivy-rich (issue #4).
:init (defun my/font-installed-p (font-name)
"Check if font with FONT-NAME is available."
(if (find-font (font-spec :name font-name))

View File

@ -1,6 +1,6 @@
;;; buffers.el --- Default settings for buffers. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-10T14:01:00+0100>
;; Time-stamp: <2020-03-15T14:28:55+0100>
;;; Commentary:
;; * Setup scratch buffer.
@ -11,7 +11,6 @@
;;; Code:
(use-package emacs
:ensure nil
:custom ((initial-scratch-message nil) ; Make scratch buffer empty,
(initial-major-mode 'gfm-mode)) ; and select mode.
:config (progn
@ -67,7 +66,7 @@
;; Dedicate windows to “purposes”.
(use-package window-purpose
:pin melpa ; We need > 1.7 <https://github.com/bmag/emacs-purpose/issues/158>
;; :pin melpa ; We need > 1.7 <https://github.com/bmag/emacs-purpose/issues/158>
:defer nil
:config (progn
(purpose-mode)
@ -98,7 +97,7 @@
;; Highlight which buffer is active by dimming the others.
(use-package dimmer
:pin melpa ; We need > 0.4.2 for configure-magit.
;; :pin melpa ; We need > 0.4.2 for configure-magit.
:config (progn
(dimmer-configure-which-key)
(dimmer-configure-magit)

View File

@ -1,6 +1,6 @@
;;; global-variables.el --- Set some global variables. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-13T11:17:28+0100>
;; Time-stamp: <2020-03-15T14:28:25+0100>
;;; Commentary:
;; * Banish customizations.
@ -14,7 +14,6 @@
;;; Code:
(use-package emacs
:ensure nil
:diminish abbrev-mode
:diminish auto-fill-function
;; Banish customizations to another file.

View File

@ -1,6 +1,6 @@
;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-10T13:42:34+0100>
;; Time-stamp: <2020-03-15T14:28:13+0100>
;;; Commentary:
;; * Setup mouse & keyboard behaviour.
@ -9,7 +9,6 @@
;;; Code:
(use-package emacs
:ensure nil
:custom ((mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line.
;; Paste text where the cursor is, not where the mouse is.
(mouse-yank-at-point t)

View File

@ -1,6 +1,6 @@
;;; package-management.el --- Initialize package management. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-11T16:10:53+0100>
;; Time-stamp: <2020-03-15T15:39:49+0100>
;;; Commentary:
;; * Set up package sources and their priorities.
@ -12,40 +12,50 @@
;;; Code:
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(setq package-archive-priorities '(("melpa-stable" . 30)
("gnu" . 20)
("melpa" . 10)))
(setq straight-repository-branch "develop")
(customize-set-variable
'straight-use-package-by-default t
"Makes use-package invoke straight.el to install the package.")
(customize-set-variable 'straight-cache-autoloads t
"Cache the autoloads of all packages in a single file.")
(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))
(add-hook 'after-init-hook #'straight-prune-build)
;; Workaround for 26.2 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341>.
(when (< emacs-major-version 27)
(defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
(when (< emacs-major-version 27)
(package-initialize))
;; Isolate package configurations.
(straight-use-package 'use-package)
;; Add path for custom packages.
(add-to-list 'load-path (concat user-emacs-directory "custom-packages/"))
(defun my/straight-pull-all-maybe ()
"Run `straight-pull-all' if 7 days have passed since the build cache was modified."
(let ((days 7))
(if (> (- (time-to-seconds)
(time-to-seconds
(file-attribute-modification-time
(file-attributes (expand-file-name "straight/build-cache.el"
user-emacs-directory)))))
(* 60 60 24 days))
(straight-pull-all))))
;; Install use-package if necessary.
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
;; Always install packages if they are not present.
(use-package use-package
:custom (use-package-always-ensure t))
;; Autocompile files on load.
(use-package auto-compile
:custom (load-prefer-newer t) ; Use uncompiled file if it is newer.
:config (auto-compile-on-load-mode))
;; ;; Autocompile files on load.
;; (use-package auto-compile
;; :custom (load-prefer-newer t) ; Use uncompiled file if it is newer.
;; :config (auto-compile-on-load-mode))
;; Tool for updating the GNU ELPA keyring.
(use-package gnu-elpa-keyring-update
@ -60,47 +70,5 @@
(if (> (- (time-to-seconds) my/keyring-last-access) (* 60 60 24 7))
(gnu-elpa-keyring-update)))
;; Update packages if at least 7 days have passed.
(use-package auto-package-update
:after (quelpa)
:demand t
:defines (quelpa-cache)
:custom ((auto-package-update-delete-old-versions t)
(auto-package-update-interval 7)
(auto-package-update-hide-results nil))
:config (progn
(auto-package-update-maybe)
(defvar my/tmp--package-activated-list nil)
(defun my/apu-delete-quelpa-packages ()
"Delete quelpa packages from `package-activated-list'."
(setq my/tmp--package-activated-list package-activated-list)
(dolist (package quelpa-cache)
(let ((package-name (car package)))
(setq package-activated-list
(delq package-name package-activated-list)))))
(defun my/apu-restore-quelpa-packages ()
"Restore quelpa packages to `package-activated-list'."
(if my/tmp--package-activated-list
(setq package-activated-list my/tmp--package-activated-list)
(message "Error: Could not restore `package-activated-list'."))
(setq my/tmp--package-activated-list nil)))
:hook ((auto-package-update-before . my/apu-delete-quelpa-packages)
(auto-package-update-after . my/apu-restore-quelpa-packages)))
;; Install Emacs packages directly from source.
(use-package quelpa
:demand t
:custom ((quelpa-self-upgrade-p nil)
(quelpa-update-melpa-p nil)
(quelpa-checkout-melpa-p nil)
(quelpa-upgrade-interval 7))
:hook (after-init . quelpa-upgrade-all-maybe))
;; Use :quelpa in use-package configurations.
(use-package quelpa-use-package
:after (use-package quelpa)
; Override `use-package-always-ensure' for quelpa-packages.
:config (quelpa-use-package-activate-advice))
(provide 'basics/package-management)
;;; package-management.el ends here

View File

@ -1,6 +1,6 @@
;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-10T23:26:19+0100>
;; Time-stamp: <2020-03-15T15:21:36+0100>
;;; Commentary:
;; * treemacs
@ -10,7 +10,7 @@
;; Directory tree.
(use-package treemacs
:pin melpa ; We need > 2.6 for lsp-treemacs.
;; :pin melpa ; We need > 2.6 for lsp-treemacs.
:demand t
:after (display-line-numbers)
:custom ((treemacs-project-follow-cleanup t) ; Collapse projects when leaving.
@ -26,8 +26,8 @@
:after (treemacs projectile))
(use-package treemacs-magit
:after (treemacs magit)
:pin melpa) ; Compatibility with treemacs-vcs.
;; :pin melpa ; See treemacs.
:after (treemacs magit))
;; Completion in many Emacs commands.
(use-package ivy

View File

@ -1,6 +1,6 @@
;;; server.el --- Set up network stuff.. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-02-27T06:05:32+0100>
;; Time-stamp: <2020-03-15T16:40:58+0100>
;;; Commentary:
@ -11,6 +11,7 @@
;; Edit remote files.
(unless slow-computer
(use-package tramp
:straight nil
:defer 5
:custom

View File

@ -1,6 +1,6 @@
;;; c++.el --- C++ settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-02-18T17:04:30+0100>
;; Time-stamp: <2020-03-15T14:29:24+0100>
;;; Commentary:
@ -11,7 +11,7 @@
(unless slow-computer
(use-package flycheck-clang-tidy
:pin melpa
;; :pin melpa
:after (flycheck projectile lsp-ui)
:if (executable-find "clang-tidy")
;; clang-tidy is built into clangd >= 9.
@ -126,7 +126,7 @@
;; Add #include directives for missing symbols.
(use-package clang-include-fixer
:ensure nil ; Installed by clang.
:straight nil ; Installed by clang.
:if (executable-find "clang-include-fixer")
:functions (clang-include-fixer--start clang-include-fixer--add-header)

View File

@ -1,6 +1,6 @@
;;; common.el --- Common programming settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-10T12:56:35+0100>
;; Time-stamp: <2020-03-15T14:29:38+0100>
;;; Commentary:
@ -9,7 +9,6 @@
(require 'basics/global-variables)
(use-package emacs
:ensure nil
:defines (compilation-mode-map)
:custom (compilation-scroll-output 'first-error)
:config (progn

View File

@ -9,7 +9,7 @@
;; Checker for the metadata in Emacs Lisp files.
(use-package flycheck-package
:after (flycheck)
:pin melpa
;; :pin melpa
:config (flycheck-package-setup))
(provide 'programming/elisp)

View File

@ -11,12 +11,12 @@
;; Git integration.
(use-package git-commit
:defer 5
:pin melpa
;; :pin melpa
)
(unless slow-computer
(use-package magit
:pin melpa
;; :pin melpa
:custom
(magit-diff-refine-hunk 'all) ; Show word-granularity differences.
@ -45,7 +45,7 @@
;; Use libgit rather than git.
(use-package magit-libgit
:pin melpa
;; :pin melpa
)
;; Show TODOs in magit-status.
@ -62,7 +62,7 @@
;; Work with Git forges from Magit.
(use-package forge
:pin melpa ; <https://github.com/magit/forge/issues/8>
;; :pin melpa ; <https://github.com/magit/forge/issues/8>
:after magit

View File

@ -1,6 +1,6 @@
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-08T07:34:25+0100>
;; Time-stamp: <2020-03-15T23:37:37+0100>
;;; Commentary:
@ -9,8 +9,6 @@
(require 'basics/global-variables)
(use-package emacs
:ensure nil
:custom
(require-final-newline t) ; Always add newline at end of file.
(fill-column 80) ; Documents are 80 chars wide by default.
@ -21,7 +19,7 @@
("C-S-r" . point-to-register) ; Store location of point in register.
("M-W" . copy-to-register) ; Store text in register.
("C-S-y" . insert-register) ; Insert text from register.
("C-<f7>" . list-registers) ; List all registers.
("M-<f7>" . list-registers) ; List all registers.
:hook
(text-mode . auto-fill-mode) ; Enable word-wrapping at fill-column.
@ -29,13 +27,16 @@
;; Quickly jump to next/previous register.
(use-package register-quicknav
:quelpa (register-quicknav
:fetcher git
:url "https://schlomp.space/tastytea/register-quicknav.git")
:straight (register-quicknav
:type git
:repo "https://schlomp.space/tastytea/register-quicknav.git"
:branch "main")
;; ^^^^^^^ See <https://github.com/raxod502/straight.el/issues/279>.
:custom (register-quicknav-buffer-only t)
:bind (("C-<f5>" . register-quicknav-prev-register)
("C-<f6>" . register-quicknav-next-register)
("M-r" . register-quicknav-clear-current-register))
:bind (("C-<f5>" . register-quicknav-prev-register)
("C-<f6>" . register-quicknav-next-register)
("C-<f7>" . register-quicknav-point-to-unused-register)
("C-S-<f7>" . register-quicknav-clear-current-register))
)
;; Save cursor position.
@ -175,7 +176,7 @@
:after (yasnippet)
:init
(defun my/autoinsert-yas-expand()
(defun my/autoinsert-yas-expand ()
"Replace text in yasnippet template."
(yas-minor-mode t)
(yas-expand-snippet (buffer-string) (point-min) (point-max)))

View File

@ -1,13 +1,13 @@
;;; latex.el --- Settings for LaTeX. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-02-18T17:18:01+0100>
;; Time-stamp: <2020-03-15T14:27:07+0100>
;;; Commentary:
;;; Code:
(use-package tex-site
:ensure auctex
:straight auctex
:if (executable-find "xetex")
:functions (TeX-revert-document-buffer)

16
init.el
View File

@ -1,6 +1,6 @@
;;; init.el --- tastytea's Emacs init file. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-13T11:23:01+0100>
;; Time-stamp: <2020-03-15T12:48:57+0100>
;;; Commentary:
;; Requires at least Emacs 26. Most of it will probably work with Emacs 24 and
@ -8,8 +8,13 @@
;;; Code:
;; Set garbage collection threshold to 20 MiB to speed up init.
(setq gc-cons-threshold (* 20 1024 1024))
;; early-init.el is automatically loaded in Emacs 27+.
(when (< emacs-major-version 27)
(require 'early-init (expand-file-name "early-init.el" user-emacs-directory)))
(customize-set-variable
'gc-cons-threshold (* 20 1024 1024)
"Set garbage collection threshold to 20 MiB to speed up init.")
;; Add path to init files.
(push (concat user-emacs-directory "init.d") load-path)
@ -38,8 +43,9 @@
(require 'net/server)
(require 'net/client)
;; Set garbage collection threshold to original value.
(setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value)))
(customize-set-variable 'gc-cons-threshold
(car (get 'gc-cons-threshold 'standard-value))
"Set garbage collection threshold to original value.")
(provide 'init)
;;; init.el ends here