From 0544650ea18a72842f46d7c0cea971f66fa7b0de Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 29 Apr 2025 22:05:46 +0200 Subject: [PATCH] Tidy emacs.el, update README --- emacs/README.md | 29 +++++++++++++++-------------- emacs/emacs.el | 48 +++++++++++++++++++++--------------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/emacs/README.md b/emacs/README.md index d028189..a888fbe 100644 --- a/emacs/README.md +++ b/emacs/README.md @@ -7,21 +7,22 @@ Just do it! It's a bit alien at first, but I didn't need much time to do all my editing in Emacs. I haven't learnt Emacs Lisp and I haven't adopted any large configuration package. -[My `emacs.el` right now is 130 lines](https://github.com/alexpdp7/alexpdp7/blob/4cbc783bbe406051bbcf88995316c9994518cbd9/emacs/emacs.el). -Perhaps when you read this, my current config will be much bigger.. -But I'm definitely happy today with my 130-line config. +Start with the following `.emacs`: + +``` +(fido-vertical-mode) +(which-key-mode) +``` -You can start without a configuration. -Whenever you can't do something, search Internet. -You will quickly learn the hotkeys you need the most. -Once you can search, undo, cut, copy, and paste, you can take your time with the rest. -Don't avoid the menus. -Sometimes it's just easier to hit F10 and find something in the menus. -You can also M-x to execute commands, like `indent-region`. +You can execute Emacs commands with `M-x` (alt-x). +`fido-vertical-mode` adds incremental search to `M-x` +You can learn many keybindings through the hints that the Emacs menu and `M-x` show. -Many other stuff is support for things I do: Vale, Rust, Python, Java, YAML, Puppet. -You probably need other plugins, and maybe you don't need them right now. +When you pause after pressing an incomplete shortcut, `which-key-mode` shows the next keys and shortcuts available. +By pressing `C-x` (control-x), `C-c`, or `C-h, you can see the global, mode, and help shortcuts respectively. -Maybe try out some of the large configurations, to learn what fancy stuff is available and add it as you become comfortable with the previous thing you configured. +[My `emacs.el` is about 120 lines](emacs.el). +Perhaps when you read this, my current config will be much bigger.. +But I'm definitely happy today with my 120-line config. -(Be sure to check [emacs.bash](https://github.com/alexpdp7/alexpdp7/blob/master/emacs/emacs.bash) for something you can source in your bash to keep Emacs running and prevent slow startup.) +Check [emacs.bash](https://github.com/alexpdp7/alexpdp7/blob/master/emacs/emacs.bash) for something you can source in your bash to keep Emacs running and prevent slow startup. diff --git a/emacs/emacs.el b/emacs/emacs.el index 981b079..e9307f0 100644 --- a/emacs/emacs.el +++ b/emacs/emacs.el @@ -3,13 +3,24 @@ ;; Nicer defaults (setq compilation-scroll-output t) -(setq column-number-mode t) ; in the mode line +(setq column-number-mode t) ; in the mode line (setq-default show-trailing-whitespace t) -(setq org-startup-folded t) +(global-whitespace-mode) +(setopt whitespace-style '(tab-mark)) (xterm-mouse-mode 1) -(save-place-mode t) - +(save-place-mode t) ; persists your position in files (setq custom-file "~/.emacs.d/disable-custom-variable-saving") +(load-theme 'modus-vivendi :no-confirm) ; colorblind-friendly theme +(fido-vertical-mode) ; nice completion for M-x +(which-key-mode) ; learn keyboard shortcuts +(global-completion-preview-mode 1) ; show things that you can tab-complete +(setq tab-always-indent 'complete) ; allow tab to complete +(setq text-mode-ispell-word-completion nil) ; but do not complete dictionary words + +(setq org-startup-folded t) + +;; This does not respect things in JSON mode; see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72808 ; M-x use set-variable js-indent-level to override :\ +(editorconfig-mode 1) ;; Do not spill temporary files everywhere ;; https://stackoverflow.com/a/18330742 @@ -18,15 +29,9 @@ (make-directory --backup-directory t)) (setq backup-directory-alist `(("." . ,--backup-directory))) -;; Colorblind friendly theme. -(load-theme 'modus-vivendi :no-confirm) - -(global-whitespace-mode) -(setopt whitespace-style '(tab-mark)) - +;; Configure the package manager. Some packages I use are not in the default repositories (require 'use-package-ensure) (setq use-package-always-ensure t) - (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) @@ -37,9 +42,6 @@ :config (xclip-mode 1)) -;; This does not respect things in JSON mode; see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72808 ; M-x use set-variable js-indent-level to override :\ -(editorconfig-mode 1) - ;; Fancy undo (use-package undo-tree :ensure t @@ -51,20 +53,10 @@ ;; https://www.reddit.com/r/emacs/comments/tejte0/undotree_bug_undotree_files_scattering_everywhere/?rdt=39892 (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))) -(fido-vertical-mode) - -;; learn keyboard shortcuts -(which-key-mode) - ;; for eglot snippet completion (use-package yasnippet :ensure t) - (yas-global-mode 1) -(global-completion-preview-mode 1) -(setq tab-always-indent 'complete) -(setq text-mode-ispell-word-completion nil) - ;; Rust support ;; rustic-enable-detached-file-support seems to be problematic :( (use-package rustic @@ -100,8 +92,10 @@ (use-package puppet-mode :ensure t) ;; Python notebooks -(use-package ein :ensure t) -(defvar ein:jupyter-default-notebook-directory (concat user-emacs-directory "ein")) +(use-package ein + :ensure t + :config + (defvar ein:jupyter-default-notebook-directory (concat user-emacs-directory "ein"))) (use-package ledger-mode :ensure t) @@ -110,7 +104,7 @@ (setq auto-mode-alist (append '(("\\.pl\\'" . prolog-mode)) auto-mode-alist)) - +;; the following is a bit fiddly, eglot requires some extra love to have extra flymake providers (use-package flymake-vale :vc (:url "https://github.com/tpeacock19/flymake-vale.git" :rev :newest) -- 2.47.3