From 1f57ae3a742341e21da6c88d908ae8e2cc4382ab Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Wed, 17 May 2023 16:55:19 +0200 Subject: [PATCH] Use `package-install-upgrade-build-in' to upgrade Org --- README.org | 78 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/README.org b/README.org index 849082d..e7d4d03 100644 --- a/README.org +++ b/README.org @@ -199,13 +199,9 @@ that *Emacs is a self-documenting editor.* :END: The =user-init-file= header requires =cl-lib= and sets Emacs options. It -consists of two parts in listing [[lst:1st-setopt-call]], and [[lst:2nd-setopt-call]] in -order to limit the length of the listings for exporting to LaTeX. - -The [[info:elisp#Quoting][quoting (info)]] and the [[info:elisp#Backquote][backquote (info)]] pages explain how to understand the -~'~ (quote), ~`~ (backquote), ~,~ (substitute) and ~@,~ (splice) in in listing -[[lst:1st-setopt-call]] and [[lst:2nd-setopt-call]]. A tutorial of how to use those -reader macros is the [[https://mullikine.github.io/posts/macro-tutorial/][didactic emacs-lisp macro example]]. +consists of three parts in listing [[lst:1st-setopt-call]], [[lst:2nd-setopt-call]], and +[[lst:2nd-setopt-call]] in order to limit the length of the listings for exporting +to LaTeX. The [[info:emacs#Init File][init file (info)]] does not load the ~custom-file~ in spite of the recommendation of [[info:emacs#Saving Customizations][saving customizations (info)]]. @@ -264,8 +260,8 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf (add-to-list 'initial-frame-alist '(width . 180))) #+end_src -#+caption[Set the second set of Emacs options]: -#+caption: Set the second set of Emacs options. +#+caption[Set the second set of Emacs options: pin packages to archives]: +#+caption: Set the second set of Emacs options: pin packages to archives. #+name: lst:2nd-setopt-call #+begin_src emacs-lisp -n :results silent (setopt @@ -276,16 +272,17 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf ("melpa" . "https://melpa.org/packages/") ("melpa-stable" . "https://stable.melpa.org/packages/") ("nongnu" . "https://elpa.nongnu.org/nongnu/")) - ;; Pin packages to GNU ELPA for info or stability. + package-install-upgrade-built-in t + ;; Pin packages to GNU ELPA for info for stability. package-pinned-packages '((auctex . "gnu") (compat . "gnu") (consult . "gnu-devel") (embark . "gnu-devel") (embark-consult . "gnu-devel") + (eldoc . "nongnu") (engrave-faces . "gnu-devel") (hyperbole . "gnu-devel") (marginalia . "gnu-devel") - (org . "gnu-devel") (osm . "gnu-devel") (parsebib . "melpa-stable") (queue . "gnu") @@ -293,10 +290,38 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf (spinner . "gnu") (xr . "gnu") (vertico . "gnu-devel")) - package-selected-packages '(async ; asynchroneous processing - debbugs ; access the GNU bug tracker - no-littering ; keep `user-emacs-directory' clean - org)) + package-selected-packages '(async debbugs no-littering)) +#+end_src + +#+caption[Set the third set of Emacs options: upgrade build in Org]: +#+caption: Set the third set of Emacs options: upgrade build in Org. +#+name: lst:3rd-setopt-call +#+begin_src emacs-lisp +;; Enable `package-install-upgrade-build-in' to upgrade Org. +;; Disable upgrading other packages by pinning them to "nongnu". +(setopt package-install-upgrade-built-in t + package-pinned-packages + (cl-union '((bind-key . "nongnu") + (eglot . "nongnu") + (erc . "nongnu") + (external-completion . "nongnu") + (faceup . "nongnu") + (jsonrpc . "nongnu") + (let-alist . "nongnu") + (map . "nongnu") + (ntlm . "nongnu") + (org . "gnu-devel") ; Upgrade! + (python . "nongnu") + (project . "nongnu") + (seq . "nongnu") + (soap-client . "nongnu") + (so-long . "nongnu") + (svg . "nongnu") + (use-package . "nongnu") + (use-package-ensure-system-package . "nongnu") + (verilog-mode . "nongnu") + (xref . "nongnu")) + package-pinned-packages :key #'car)) #+end_src * [[info:emacs#Package Installation][Install the selected packages (info)]] @@ -304,18 +329,20 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf :CUSTOM_ID: sec:install-selected-packages :END: -[[info:emacs#Package Installation][Emacs installs packages]] from archives on the internet. This setup uses three +[[info:emacs#Package Installation][Emacs installs packages]] from archives on the internet. This setup uses five archives: -1. The [[https://elpa.gnu.org/][GNU Emacs Lisp Package Archive]] -2. The [[https://elpa.nongnu.org/][NonGNU Emacs Lisp Package Archive]]. -3. The [[https://melpa.org/#/][Milkypostman's Emacs Lisp Package Archive (MELPA)]] with its official +1. The [[https://elpa.gnu.org/][GNU Emacs Lisp Package Archive]]. +2. The [[https://elpa.gnu.org/devel/index.html][Development Emacs Lisp Package Archive]]. +3. The [[https://elpa.nongnu.org/][NonGNU Emacs Lisp Package Archive]]. +4. The [[https://melpa.org/#/][Milkypostman's Emacs Lisp Package Archive (MELPA)]] with its official [[https://www.mirrorservice.org/sites/melpa.org/packages/][mirror]] in case [[https://downforeveryoneorjustme.com/melpa.org][is Melpa.org down?]] tells [[https://melpa.org/#/][MELPA]] is down for everyone. +5. The [[https://stable.melpa.org/#/getting-started][Stable Milkypostman's Emacs Lisp Package Archive]]. + The code in listing [[lst:install-selected-packages]] assumes that the package system is in a *virgin* state if the package [[https://github.com/emacscollective/no-littering][no-littering]] is not present: 1. It installs and loads [[https://github.com/emacscollective/no-littering][no-littering]] after ensuring refreshing of the contents of available packages. -2. It installs [[https://elpa.gnu.org/devel/org.html][Org (GNU-devel ELPA archive)]] early to shadow the built-in package - while preventing collisions between the snapshot and built-in packages. +2. It upgrades the build in Org package. 3. It calls src_emacs-lisp{(package-install-selected-packages)} to check the installation status of all packages in src_emacs-lisp{package-selected-packages} and to install the missing packages @@ -337,14 +364,7 @@ the contents of packages and allows to update packages to the latest version. ;; Install and require `no-littering'. (package-install 'no-littering) (require 'no-littering) - ;; Stolen from (find-function-other-window 'eglot-upgrade-eglot): - (defun shadow-builtin-by-install (pkg) - (unless (bound-and-true-p package-archive-contents) - (package-refresh-contents)) - (package-install (cadr (assoc pkg package-archive-contents)))) - ;; Shadow built-in `org' by installing `org'. - ;; Note (package-reinstall 'org) deletes the shadowing `org'. - (shadow-builtin-by-install 'org) + (package-upgrade 'org) ;; Install the selected packages. (package-install-selected-packages)))