diff --git a/README.org b/README.org index 2cbd821..3f98afa 100644 --- a/README.org +++ b/README.org @@ -1237,6 +1237,60 @@ sub makeglossaries { (sort (cl-remove-duplicates result)))) #+end_src +* [[info:emacs#Saving Emacs Sessions][Saving Emacs sessions (info)]] +:PROPERTIES: +:CUSTOM_ID: sec:desktop +:END: + +Listing [[lst:desktop-setup][setup desktop]] makes Emacs save its state between closing its session to +opening the next session. This setup relies on =desktop-save-mode= in case of +overlapping functionality of =desktop-save-mode= and =savehist-mode=. Listing +[[lst:prune-file-name-history]] prunes non-existing files from =file-name-history=, +which is under Emacs control but neither =desktop-save-mode= nor +=savehist-mode=. + +NOTE: The src_emacs-lisp{(describe-function 'savehist-mode)} documentation +explains why it is best to turn on =savehist-mode= in =user-init-file=. + +BUG: Adding ~kill-ring~ to ~savehist-additional-variables~ does not save +~kill-ring~ from an Emacs session to the next session, contrary to the +src_emacs-lisp{(describe-variable 'savehist-additional-variables)} +documentation. + +#+caption[Setup =desktop= to save Emacs sessions]: +#+caption: Setup =desktop= to save Emacs sessions. +#+name: lst:desktop-setup +#+begin_src emacs-lisp -n :results silent +(with-eval-after-load 'emacs + ;; GAV: I fail to implement the idea of ChatGPT on how to reload + ;; `eww' pages automatically while restoring the desktop (idea is to + ;; add save and restore handlers to `desktop-buffer-mode-handlers'). + ;; GAV: (setopt eww-restore-desktop t) fails and starts hesitantly. + ;; GAV: I fail to code a function for setting the + ;; `desktop-buffers-not-to-save-function' option. + (setopt desktop-buffers-not-to-save + (rx bos (or "*Apropos" "compilation*")) + desktop-modes-not-to-save + '(emacs-lisp-mode image-mode tags-table-mode)) + + (desktop-save-mode t)) +#+end_src + +#+caption[Prune non-existing files from =file-name-history=]: +#+caption: Prune non-existing files from =file-name-history=. +#+name: lst:prune-file-name-history +#+begin_src emacs-lisp -n :results silent +(defun prune-file-name-history () + "Prune non-existing files from `file-name-history'." + (interactive) + (let ((old (length file-name-history)) ok) + (dolist (name file-name-history) + (when (file-exists-p name) + (push name ok))) + (setq file-name-history (nreverse ok)) + (message "Pruned `file-name-history' from `%S' to `%S' files" + old (length file-name-history)))) +#+end_src * Completion :PROPERTIES: @@ -1265,14 +1319,6 @@ NOTE: Play with =vertico-buffer-mode=, =vertico-flat-mode=, =vertico-grid-mode=, =vertico-indexed-mode=, =vertico-mouse-mode= (not easy to use with my trackpad), =vertico-reverse-mode=. -NOTE: The src_emacs-lisp{(describe-function 'savehist-mode)} documentation -explains why it is best to turn on =savehist-mode= in =user-init-file=. - -BUG: Adding ~kill-ring~ to ~savehist-additional-variables~ does not save -~kill-ring~ from an Emacs session to the next session, contrary to the -src_emacs-lisp{(describe-variable 'savehist-additional-variables)} -documentation. - #+caption[Setup =vertico-mode=]: #+caption: Setup =vertico-mode=. #+name: lst:setup-vertico-mode @@ -1285,22 +1331,6 @@ documentation. (vertico-mode +1)) #+end_src -#+caption[Prune non-existing files from =file-name-history=]: -#+caption: Prune non-existing files from =file-name-history=. -#+name: lst:prune-file-name-history -#+begin_src emacs-lisp -n :results silent -(defun prune-file-name-history () - "Prune non-existing files from `file-name-history'." - (interactive) - (let ((old (length file-name-history)) ok) - (dolist (name file-name-history) - (when (file-exists-p name) - (push name ok))) - (setq file-name-history (nreverse ok)) - (message "Pruned `file-name-history' from `%S' to `%S' files" - old (length file-name-history)))) -#+end_src - #+attr_latex: :booktabs yes :float table #+caption[Vertico key map bindings]: #+caption: Vertico key map bindings. @@ -3737,33 +3767,6 @@ Return \"Front Matter\" when current page is above the first headline." (add-to-list 'which-func-functions 'which-func-pdf-view-function) #+end_src -* [[info:emacs#Saving Emacs Sessions][Saving Emacs sessions (info)]] -:PROPERTIES: -:CUSTOM_ID: sec:desktop -:END: - -Listing [[lst:desktop-setup][setup desktop]] makes Emacs save its state between closing its session to -opening the next session. - -#+caption[Setup =desktop= to save Emacs sessions]: -#+caption: Setup =desktop= to save Emacs sessions. -#+name: lst:desktop-setup -#+begin_src emacs-lisp -n :results silent -(with-eval-after-load 'emacs - ;; GAV: I fail to implement the idea of ChatGPT on how to reload - ;; `eww' pages automatically while restoring the desktop (idea is to - ;; add save and restore handlers to `desktop-buffer-mode-handlers'). - ;; GAV: (setopt eww-restore-desktop t) fails and starts hesitantly. - ;; GAV: I fail to code a function for setting the - ;; `desktop-buffers-not-to-save-function' option. - (setopt desktop-buffers-not-to-save - (rx bos (or "*Apropos" "compilation*")) - desktop-modes-not-to-save - '(emacs-lisp-mode image-mode tags-table-mode)) - - (desktop-save-mode t)) -#+end_src - * Programming Tools :PROPERTIES: :CUSTOM_ID: sec:programming-tools