diff --git a/README.org b/README.org index da6361f..7fb0779 100644 --- a/README.org +++ b/README.org @@ -273,7 +273,79 @@ The [[info:emacs#Init File][init file (info)]] does not load the ~custom-file~ a (add-to-list 'initial-frame-alist '(width . 180))) #+end_src -** [[info:emacs#Faces][Text faces or look (info)]] +* [[info:emacs#Package Installation][Install the selected packages (info)]] +:PROPERTIES: +:CUSTOM_ID: sec:install-selected-packages +:END: + +[[info:emacs#Package Installation][Emacs installs packages]] from archives on the internet. This setup uses three +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)]]. +In addition, 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 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. +3. It ensures installation of [[https://github.com/quelpa/quelpa][quelpa]] before ensuring installation of [[https://github.com/sheijk/org-menu#readme][org-menu]]. +4. 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 + after the user has agreed to its prompt. +5. It defines a function to ensure the installation of packages in other source + blocks. This allows skipping installation in sections with a =:noexport:= + tag by disallowing tangling. +In case of normal Emacs usage, src_emacs-lisp{(package-list-packages)} refreshes +the contents of packages and allows to update packages to the latest version. + +#+caption[Install the selected packages]: +#+caption: Install the selected packages. +#+name: lst:install-selected-packages +#+begin_src emacs-lisp + (unless noninteractive + (unless (require 'no-littering nil 'noerror) + (unless (bound-and-true-p package-archive-contents) + (package-refresh-contents)) + ;; Install and require `no-littering'. + (package-install 'no-littering) + (require 'no-littering) + ;; Install and shadow `org'. + ;; https://emacs.stackexchange.com/a/45939 answers + ;; "How to install a package automatically that will shadow a built-in package?" + (defun shadow-built-in-package (pkg) + (when-let ((desc (or (when (package-desc-p pkg) pkg) + (cadr (assq pkg package-archive-contents))))) + (package-install desc 'dont-select))) + (shadow-built-in-package 'org) + ;; Install `quelpa'. + (unless (package-installed-p 'quelpa) + (package-install 'quelpa)) + ;; Install `org-menu'. + (when (fboundp 'quelpa) + (unless (package-installed-p 'org-menu) + ;; Neither GNU ELPA, nor MELPA provide this package. + (quelpa '(org-menu :repo "sheijk/org-menu" :fetcher github)))) + ;; Install the selected packages. + (package-install-selected-packages))) + + (defun ensure-package-installation (&rest packages) + "Ensure installation of all packages in PACKAGES." + (let ((ok t)) + (dolist (package packages) + (unless (package-installed-p package) + (package-install package)) + (if (package-installed-p package) + (when (bound-and-true-p package-selected-packages) + (cl-pushnew package package-selected-packages)) + (setq ok nil))) + ok)) +#+end_src + +* [[info:emacs#Faces][Text faces or look (info)]] :PROPERTIES: :CUSTOM_ID: sec:text-faces-or-look :END: @@ -361,7 +433,10 @@ However, in order to improve visibility, it relies on: "My face to show a here-document.")) #+end_src -** [[info:elisp#Advising Functions][Advising Functions (info)]] +* [[info:elisp#Advising Functions][Advising Functions (info)]] +:PROPERTIES: +:CUSTOM_ID: sec:advising-function +:END: #+caption[Tools for advising functions]: #+caption: Tools for advising functions. @@ -379,7 +454,7 @@ However, in order to improve visibility, it relies on: (advice-add symbol where function props))))) #+end_src -** [[info:emacs#Dired][Dired: directory editor as file manager (info)]] +* [[info:emacs#Dired][Dired: directory editor as file manager (info)]] :PROPERTIES: :CUSTOM_ID: sec:file-manager :END: @@ -494,7 +569,7 @@ by experienced Emacs users. (define-key dired-mode-map (kbd "Y") #'dired-rsync)) #+end_src -** [[info:elisp#Processes][Processes (info)]] +* [[info:elisp#Processes][Processes (info)]] :PROPERTIES: :CUSTOM_ID: sec:processes :END: @@ -515,65 +590,6 @@ output to =stdout=. (buffer-string)))) #+end_src -* [[info:emacs#Package Installation][Install the selected packages (info)]] -:PROPERTIES: -:CUSTOM_ID: sec:install-selected-packages -:END: - -[[info:emacs#Package Installation][Emacs installs packages]] from archives on the internet. This setup uses three -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)]]. -In addition, 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 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 ensures installation of [[https://github.com/quelpa/quelpa][quelpa]] before ensuring installation of [[https://github.com/sheijk/org-menu#readme][org-menu]]. -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 - after the user has agreed to its prompt. -4. It defines a function to ensure the installation of packages in other source - blocks. This allows skipping installation in sections with a =:noexport:= - tag by disallowing tangling. -In case of normal Emacs usage, src_emacs-lisp{(package-list-packages)} refreshes -the contents of packages and allows to update packages to the latest version. - -#+caption[Install the selected packages]: -#+caption: Install the selected packages. -#+name: lst:install-selected-packages -#+begin_src emacs-lisp - (unless (require 'no-littering nil 'noerror) - (package-refresh-contents) - (package-install 'no-littering) - (require 'no-littering)) - - (unless (package-installed-p 'quelpa) - (package-install 'quelpa)) - - (unless (package-installed-p 'org-menu) - ;; Neither GNU ELPA, nor MELPA provide this package. - (quelpa '(org-menu :repo "sheijk/org-menu" :fetcher github))) - - (unless noninteractive - (package-install-selected-packages)) - - (defun ensure-package-installation (&rest packages) - "Ensure installation of all packages in PACKAGES." - (let ((ok t)) - (dolist (package packages) - (unless (package-installed-p package) - (package-install package)) - (if (package-installed-p package) - (when (bound-and-true-p package-selected-packages) - (cl-pushnew package package-selected-packages)) - (setq ok nil))) - ok)) -#+end_src - * [[info:emacs#Help][Help (info)]] :PROPERTIES: :CUSTOM_ID: sec:help