From 153d0ec7f0f86379e220c9bdf54c33b5a03f5932 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:28:09 -0400 Subject: [PATCH] Add saveplace --- README.md | 25 +++++++++++++++++++++++++ init.el | 29 ++++++----------------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index f3cd233..979a4e7 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,31 @@ Always begin your `pre-init.el`, `post-init.el`, `post-early-init.el`, and `pre- ## Frequently asked questions +### How to activate recentf, savehist, saveplace, and auto-revert? + +``` emacs-lisp +;; Auto-revert in Emacs is a feature that automatically updates the +;; contents of a buffer to reflect changes made to the underlying file +;; on disk. +(add-hook 'after-init-hook #'global-auto-revert-mode) + +;; recentf is an Emacs package that maintains a list of recently +;; accessed files, making it easier to reopen files you have worked on +;; recently. +(add-hook 'after-init-hook #'recentf-mode) + +;; savehist is an Emacs feature that preserves the minibuffer history between +;; sessions. It saves the history of inputs in the minibuffer, such as commands, +;; search strings, and other prompts, to a file. This allows users to retain +;; their minibuffer history across Emacs restarts. +(add-hook 'after-init-hook #'savehist-mode) + +;; save-place-mode enables Emacs to remember the last location within a file +;; upon reopening. This feature is particularly beneficial for resuming work at +;; the precise point where you previously left off. +(add-hook 'after-init-hook #'save-place-mode) +``` + ### Are post-early-init.el and pre-init.el the same file in terms of the logic? During the execution of `early-init.el` (and `pre-early-init.el` and `post-early-init.el`), Emacs has not yet loaded the graphical user interface (GUI). This file is used for configurations that need to be applied before the GUI is initialized, such as settings that affect the early stages of the Emacs startup process. diff --git a/init.el b/init.el index 308ef07..a974f6f 100644 --- a/init.el +++ b/init.el @@ -17,19 +17,6 @@ ;;; Load pre-init.el (minimal-emacs-load-user-init "pre-init.el") -;;; Variables -(defvar minimal-emacs-window-divider-mode-enabled t - "Non-nil to enable `window-divider-mode'.") - -(defvar minimal-emacs-recentf-enabled t - "Non-nil to enable `recentf'.") - -(defvar minimal-emacs-savehist-enabled t - "Non-nil to enable `savehist'.") - -(defvar minimal-emacs-saveplace-enabled t - "Non-nil to enable `saveplace'.") - ;;; package.el (require 'package) @@ -137,8 +124,7 @@ window-divider-default-places t window-divider-default-right-width 1) -(when minimal-emacs-window-divider-mode-enabled - (add-hook 'after-init-hook #'window-divider-mode)) +(add-hook 'after-init-hook #'window-divider-mode) ;;; Backup files @@ -192,24 +178,21 @@ (setq recentf-max-saved-items 300) ; default is 20 (setq recentf-auto-cleanup 'mode) -(when minimal-emacs-recentf-enabled - (add-hook 'after-init-hook #'recentf-mode)) - ;;; saveplace ;; `save-place-mode` enables Emacs to remember the last location within a file ;; upon reopening. This feature is particularly beneficial for resuming work at ;; the precise point where you previously left off. (setq save-place-file (expand-file-name "saveplace" user-emacs-directory)) (setq save-place-limit 600) -(when minimal-emacs-saveplace-enabled - (add-hook 'after-init-hook #'save-place-mode)) ;;; savehist +;; `savehist` is an Emacs feature that preserves the minibuffer history between +;; sessions. It saves the history of inputs in the minibuffer, such as commands, +;; search strings, and other prompts, to a file. This allows users to retain +;; their minibuffer history across Emacs restarts. +(setq history-length 300) (setq savehist-save-minibuffer-history t) ;; Default -(when minimal-emacs-savehist-enabled - (add-hook 'after-init-hook #'savehist-mode)) - ;;; Frames and windows ;; Resizing the Emacs frame can be costly when changing the font. Disable this