Compare commits

...

4 Commits

Author SHA1 Message Date
Gerard Vermeulen
88b8ef8000 Ensure to define functions before calling them 2023-01-10 19:04:39 +01:00
Gerard Vermeulen
54363c2bdc Backport Emacs-29.1 functionality to Emacs-28.2 2023-01-10 19:03:26 +01:00
Gerard Vermeulen
3a91dfffb2 Compare `emacs-version' with "29.0.0" instead of "28.9.9" 2023-01-10 07:38:07 +01:00
Gerard Vermeulen
3aa5ed013c Remove removed `consult-apropos' 2023-01-10 07:34:20 +01:00

View File

@ -196,8 +196,9 @@ that *Emacs is a self-documenting editor.*
:CUSTOM_ID: sec:init-file-header
:END:
The =user-init-file= header requires =cl-lib= and customizes Emacs variables.
It consists of four parts in listing [[lst:1st-custom-set-variables-call]],
The =user-init-file= header requires =cl-lib=, backports new functions in
Emacs-29.1 to Emacs-28.2, and customizes Emacs variables. It consists of five
parts in listing [[lst:backport-header]], [[lst:1st-custom-set-variables-call]],
[[lst:2nd-custom-set-variables-call]], [[lst:3rd-custom-set-variables-call]], and
[[lst:4th-custom-set-variables-call]] in order to limit the length of the listings
for exporting to LaTeX.
@ -213,15 +214,49 @@ example]].
The [[info:emacs#Init File][init file (info)]] does not load the ~custom-file~ as [[info:emacs#Saving Customizations][saving customizations
(info)]] recommends because of the ~custom-set-variables~ function calls.
#+caption[Customize the first set of Emacs variables]:
#+caption: Customize the first set of Emacs variables.
#+name: lst:1st-custom-set-variables-call
#+caption[Header with backport of Emacs-29.1 functionality]:
#+caption: Header with backport of Emacs-29.1 functionality.
#+name: lst:backport-header
#+begin_src emacs-lisp
;;; init.el --- user init file -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(require 'cl-lib)
(when (version< emacs-version "29.0.0")
(defmacro setopt (&rest pairs)
"Set VARIABLE/VALUE pairs, and return the final VALUE.
This is like `setq', but is meant for user options instead of
plain variables. This means that `setopt' will execute any
`custom-set' form associated with VARIABLE.
\(fn [VARIABLE VALUE]...)"
(declare (debug setq))
(unless (zerop (mod (length pairs) 2))
(error "PAIRS must have an even number of variable/value members"))
(let ((expr nil))
(while pairs
(unless (symbolp (car pairs))
(error "Attempting to set a non-symbol: %s" (car pairs)))
(push `(setopt--set ',(car pairs) ,(cadr pairs))
expr)
(setq pairs (cddr pairs)))
(macroexp-progn (nreverse expr))))
(defun setopt--set (variable value)
(custom-load-symbol variable)
;; Check that the type is correct.
(when-let ((type (get variable 'custom-type)))
(unless (widget-apply (widget-convert type) :match value)
(warn "Value `%S' does not match type %s" value type)))
(put variable 'custom-check-value (list value))
(funcall (or (get variable 'custom-set) #'set-default) variable value)))
#+end_src
#+caption[Customize the first set of Emacs variables]:
#+caption: Customize the first set of Emacs variables.
#+name: lst:1st-custom-set-variables-call
#+begin_src emacs-lisp
(custom-set-variables
'(after-save-hook #'executable-make-buffer-file-executable-if-script-p)
'(column-number-mode t)
@ -259,7 +294,7 @@ The [[info:emacs#Init File][init file (info)]] does not load the ~custom-file~ a
`,(delq nil `((auctex . "gnu")
(compat . "gnu")
(consult . "gnu-devel")
,(when (version< emacs-version "28.9.9")
,(when (version< emacs-version "29.0.0")
'(eglot . "gnu-devel"))
(embark . "gnu-devel")
(embark-consult . "gnu-devel")
@ -365,9 +400,6 @@ the contents of packages and allows to update packages to the latest version.
(package-install desc 'dont-select)))
;; Shadow built-in `org' by installing `org'.
(shadow-builtin-by-install 'org)
;; Shadow built-in `python' by installing `python'.
(when (version< emacs-version "28.9.9")
(shadow-builtin-by-install 'python))
;; Install the selected packages.
(package-install-selected-packages)))
@ -1438,7 +1470,6 @@ function [[info:elisp#Minibuffer Completion][completing-read]]. Listing [[lst:c
|-----------------------------+----------------------+---------------------|
| command | key map | keys |
|-----------------------------+----------------------+---------------------|
| consult-apropos | help-map | {{{kbd(<help> a)}}} |
| consult-bookmark | ctl-x-r-keymap | {{{kbd(C-x r b)}}} |
| consult-buffer-other-frame | ctl-x-5-keymap | {{{kbd(C-x 5 b)}}} |
| consult-buffer-other-window | ctl-x-4-keymap | {{{kbd(C-x 4 b)}}} |
@ -2095,7 +2126,10 @@ follows a list detailing and motivating each listing:
,(when (fboundp 'maxima-mode) '(maxima . t))
(org . t)
(perl . t)
(python . t)
;; The next two functions are not bound during bootstrap.
,(when (and (fboundp 'choose-common-python-interpreter)
(fboundp 'choose-common-python-linter))
'(python . t))
(shell . t))))
'(org-export-backends '(ascii beamer html icalendar latex odt texinfo))
'(org-file-apps '((auto-mode . emacs)
@ -2346,7 +2380,7 @@ else:
unicode=true,
urlcolor=blue,
}\n")
`,(if (version< emacs-version "28.9.9")
`,(if (version< emacs-version "29.0.0")
'(org-latex-listings 'minted)
'(org-latex-src-block-backend 'minted))
'(org-latex-minted-langs '((cc "c++")
@ -3947,7 +3981,7 @@ mode independent [[https://github.com/joaotavora/eglot][Eglot]] configuration:
#+name: lst:minimal-eglot-setup
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(when (version< emacs-version "28.9.9")
(when (version< emacs-version "29.0.0")
(ensure-package-installation 'eglot))
;; Replace `nil' with `t' for debugging.
@ -4297,10 +4331,7 @@ src_emacs-lisp{(describe-function 'inferior-emacs-lisp-mode)}.
#+name: lst:setup-ielm
#+begin_src emacs-lisp
(with-eval-after-load 'ielm
(if (version< "29.0.0" emacs-version)
(setopt ielm-dynamic-return nil)
(custom-set-variables
'(ielm-dynamic-return nil))))
(setopt ielm-dynamic-return nil))
#+end_src
** [[https://fennel-lang.org/][Fennel Programming]]
@ -4463,18 +4494,6 @@ rules which make [[https://flake8.pycqa.org/en/latest/][flake8]] or [[https://py
Finally, listing [[lst:flake8-nocolor][flake8-nocolor]] and [[lst:ruff-nocolor][ruff-nocolor]] pipe the =stdout= output of the
[[https://pypi.org/project/flake8/][flake8]] and [[https://pypi.org/project/ruff/][ruff]] executables through =cat= to remove escape sequences.
#+caption[Setup Python mode]:
#+caption: Setup Python mode.
#+name: lst:setup-python-mode
#+begin_src emacs-lisp
(with-eval-after-load 'python
(custom-set-variables
'(python-indent-guess-indent-offset nil)
'(python-shell-completion-native-disabled-interpreters '("ipython3" "pypy")))
(choose-common-python-interpreter 'python)
(choose-common-python-linter 'ruff-nocolor))
#+end_src
#+caption[Choose a common Python interpreter]:
#+caption: Choose a common Python interpreter for =ob-python= and =python-mode=.
#+name: lst:choose-common-python-interpreter
@ -4556,6 +4575,18 @@ Finally, listing [[lst:flake8-nocolor][flake8-nocolor]] and [[lst:ruff-nocolor][
python-check-command python-flymake-command))))
#+end_src
#+caption[Setup Python mode]:
#+caption: Setup Python mode.
#+name: lst:setup-python-mode
#+begin_src emacs-lisp
(with-eval-after-load 'python
(custom-set-variables
'(python-indent-guess-indent-offset nil)
'(python-shell-completion-native-disabled-interpreters '("ipython3" "pypy")))
(choose-common-python-interpreter 'python)
(choose-common-python-linter 'ruff-nocolor))
#+end_src
#+caption[Access =pyenv=]:
#+caption: Access =pyenv=.
#+name: lst:access-pyenv