Fall back to standard use of =package.el=

This commit is contained in:
Gerard Vermeulen 2021-12-06 18:35:33 +01:00
parent 4eaeaa43b3
commit 60b197c0b8
2 changed files with 33 additions and 58 deletions

2
.gitignore vendored
View File

@ -19,6 +19,6 @@ org-store-link
/_minted-README
/eln-cache
/elpa-*
/elpa
/quelpa
/var

View File

@ -112,16 +112,16 @@ Here follows a list of interesting Emacs configurations:
:CUSTOM_ID: sec:early-init-file
:END:
The configuration inhibits enabling of [[info:emacs#Packages][Emacs' package management system]] at
startup in order to get more control in the [[#sec:package-bootstrapping][Package Bootstrapping]] section.
Note: src_emacs-lisp[:exports code]{(find-function #'hack-local-variables)}
#+attr_latex: :options bgcolor=LightGoldenrodYellow
#+begin_src emacs-lisp :tangle early-init.el
;;; early-init.el --- user early-init file -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(setq package-enable-at-startup nil)
(setq-default load-prefer-newer t)
(setq load-prefer-newer t)
(require 'no-littering nil 'noerror)
(provide 'early-init)
;; Emacs looks for "Local variables:" after the last "?\n?\f".
@ -140,7 +140,7 @@ startup in order to get more control in the [[#sec:package-bootstrapping][Packag
The [[info:elisp#Quoting][quoting (info)]] and the [[info:elisp#Backquote][backquote (info)]] pages explain how to understand the
reader macros ~'~ (quote), ~`~ (backquote), ~,~ (substitute) and ~@,~ (splice)
in the ~custom-set-variable~ function call below. A tutorial of how to use those
reader macro's is the [[https://mullikine.github.io/posts/macro-tutorial/][didactic emacs-lisp macro example]].
reader macros is the [[https://mullikine.github.io/posts/macro-tutorial/][didactic emacs-lisp macro example]].
Because of the ~custom-set-variable~ function call, the [[info:emacs#Init File][init file (info)]] does
not load the ~custom-file~ as [[info:emacs#Saving Customizations][saving customizations (info)]] recommends.
@ -156,9 +156,7 @@ not load the ~custom-file~ as [[info:emacs#Saving Customizations][saving customi
'(after-save-hook #'executable-make-buffer-file-executable-if-script-p)
'(column-number-mode t)
'(cursor-type 'box)
`(custom-file
,(locate-user-emacs-file
(format "custom-%s.%s.el" emacs-major-version emacs-minor-version)))
`(custom-file ,(make-temp-file "emacs-custom-"))
'(epg-pinentry-mode 'loopback)
'(global-hl-line-mode t)
'(global-hl-line-sticky-flag t)
@ -175,9 +173,27 @@ not load the ~custom-file~ as [[info:emacs#Saving Customizations][saving customi
'(package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
`(package-user-dir
,(locate-user-emacs-file
(format "elpa-%s.%s" emacs-major-version emacs-minor-version)))
`(package-selected-packages
`(
,@(when (version< emacs-version "28.0")
'(org)) ; plain text thought organizer
anaconda-mode ; strangles python-mode
auctex ; Aalborg University Center TeX
blacken ; Black Python-code formatter client
citar ; bibliography handling
citeproc ; bibliography handling
company-anaconda ; complete anything in anaconda-mode
consult ; consult completing-read
eglot ; Emacs polyGLOT LSP client
embark ; act on any buffer selection
htmlize ; convert buffer contents to HTML
leuven-theme ; beautiful color theme
marginalia ; minibuffer margin notes
orderless ; Emacs completion style
pdf-tools ; interactive docview replacement
pyenv-mode ; Python environment selector
quelpa ; install Emacs packages from source
vertico)) ; VERTical Interactive Completion
'(python-indent-guess-indent-offset nil)
'(recentf-mode t)
'(save-place-mode t)
@ -223,13 +239,8 @@ archives:
Finally, the [[https://github.com/quelpa/quelpa][quelpa]] tool allows to fetch code from any source and build a
package on your computer before installation.
The output of the byte-compiler may change with each new Emacs release.
Therefore, in order to prevent collisions between different Emacs versions, the
package-user-directory has a suffix containing the major- and minor-version
numbers of Emacs.
The order of the next 1nd, 2nd, and 3rd package-bootstrapping blocks matters
because each of those blocks prepares Emacs for the next block.
The order of the next two package-bootstrapping blocks matters
because first block prepares Emacs for the second block.
If present, the package [[https://github.com/emacscollective/no-littering][no-littering]] helps to keep =~/.emacs.d= clean.
@ -247,14 +258,13 @@ list of packages.
#+attr_latex: :options bgcolor=LightGoldenrodYellow
#+begin_src emacs-lisp
;; The is the 1st package bootstrapping block.
(require 'package)
(package-initialize)
(unless (require 'no-littering nil 'noerror)
(package-refresh-contents)
(package-install 'no-littering)
(require 'no-littering))
(package-install-selected-packages)
(defun my-install-packages (packages)
"Ensure installation of all packages in PACKAGES."
(dolist (package packages)
@ -262,46 +272,11 @@ list of packages.
(package-install package))))
#+end_src
Install the basic packages and in case this is Emacs-27.2, upgrade [[https://orgmode.org/][Org Mode]] for
compatibility with Emacs-28.1. The [[info:elisp#Quoting][quoting (info)]] and the [[info:elisp#Backquote][backquote (info)]]
pages explain how to understand the reader macros ~'~ (quote), ~`~ (backquote),
~,~ (substitute) and ~@,~ (splice) in the definition of ~my-packages~ variable
below.
#+attr_latex: :options bgcolor=LightGoldenrodYellow
#+begin_src emacs-lisp
;; The is the 2nd package bootstrapping block.
(defvar my-packages
`(
,@(when (version< emacs-version "28.0")
'(org)) ; plain text thought organizer
anaconda-mode ; strangles python-mode
auctex ; Aalborg University Center TeX
blacken ; Black Python-code formatter client
citar ; bibliography handling
citeproc ; bibliography handling
company-anaconda ; complete anything in anaconda-mode
consult ; consult completing-read
eglot ; Emacs polyGLOT LSP client
embark ; act on any buffer selection
htmlize ; convert buffer contents to HTML
leuven-theme ; beautiful color theme
marginalia ; minibuffer margin notes
orderless ; Emacs completion style
pdf-tools ; interactive docview replacement
pyenv-mode ; Python environment selector
quelpa ; install Emacs packages from source
vertico) ; VERTical Interactive Completion
"List of packages required packages.")
(my-install-packages my-packages)
#+end_src
Facilitate installlation of the optional packages.
#+attr_latex: :options bgcolor=LightGoldenrodYellow
#+begin_src emacs-lisp
;; The is the 3rd package bootstrapping block.
;; The is the 2nd package bootstrapping block.
(defvar my-optional-packages
`(
,@(when (version< emacs-version "28.0")