commit bbb2a6f753d87689ce5f0f0882be2ba52a52596f
parent 0c47000725f9ee5412293086bb85410269085347
Author: Alex Balgavy <alex@balgavy.eu>
Date: Thu, 30 Dec 2021 12:07:58 +0100
emacs: some more config changes
Diffstat:
3 files changed, 59 insertions(+), 31 deletions(-)
diff --git a/emacs/config.org b/emacs/config.org
@@ -61,24 +61,6 @@ Garbage-collect on focus-out, Emacs /should/ feel snappier.
(add-hook 'focus-out-hook #'garbage-collect)
#+end_src
-* Package management
-** Repositories (MELPA & Org)
-
-Set up packages:
-
-#+begin_src emacs-lisp
- (require 'package)
- (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
- (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/"))
-#+end_src
-
-Refresh packages async:
-
-#+begin_src emacs-lisp
- (package-initialize)
- (package-refresh-contents t)
-#+end_src
-
* Packages
** exec-path-from-shell (macOS)
In macOS, the path is not set correctly in the GUI app. This fixes it.
@@ -341,7 +323,21 @@ I want to highlight TODO keywords in comments:
("FIXME" . "#caa000")))
(global-hl-todo-mode t))
#+end_src
+** undo-tree
+Sometimes it's better to look at undo history as a tree:
+
+#+begin_src emacs-lisp
+ (use-package undo-tree
+ :config
+ (global-undo-tree-mode))
+#+end_src
+
* Interface
+** Start debugger on error
+#+begin_src emacs-lisp
+ (toggle-debug-on-error t)
+#+end_src
+
** Messages
Hide some messages I don't need.
@@ -356,8 +352,21 @@ Highlight the current line:
#+begin_src emacs-lisp
(global-hl-line-mode)
- (show-paren-mode 1)
#+end_src
+*** Matching parentheses
+Don't add a delay to show matching parenthesis.
+Must come before show-paren-mode enable.
+
+#+begin_src emacs-lisp
+ (setq show-paren-delay 0)
+#+end_src
+
+Show matching parentheses:
+
+#+begin_src emacs-lisp
+ (show-paren-mode t)
+#+end_src
+
*** Cursor
The default box cursor isn't really accurate, because the cursor is actually between letters, not on a letter.
@@ -476,15 +485,17 @@ And a way to toggle those side windows:
#+begin_src emacs-lisp
(global-set-key (kbd "C-c w") (lambda () (interactive) (window-toggle-side-windows)))
#+end_src
-
-* File locations
+* Emacs file locations
** Auto-Save files
By default, auto-save files ("#file#") are placed in the same directory as the file itself.
I want to put this all in some unified place:
#+begin_src emacs-lisp
- (setq auto-save-file-name-transforms
- `((".*" "~/.local/share/emacs/saves/" t)))
+ (let ((saves-directory "~/.local/share/emacs/saves/"))
+ (unless (file-directory-p saves-directory)
+ (make-directory saves-directory))
+ (setq auto-save-file-name-transforms
+ `((".*" ,saves-directory t))))
#+end_src
** Backup files
@@ -492,8 +503,11 @@ By default, backup files (those with a tilde) are saved in the same directory as
This setting puts them in ~/.local/share/emacs/backups.
#+begin_src emacs-lisp
- (setq backup-directory-alist '(("." . "~/.local/share/emacs/backups")))
- (setq backup-by-copying t)
+ (let ((backups-directory "~/.local/share/emacs/backups"))
+ (unless (file-directory-p backups-directory)
+ (make-directory backups-directory))
+ (setq backup-directory-alist `(("." . ,backups-directory)))
+ (setq backup-by-copying t))
#+end_src
** Custom settings file
@@ -523,20 +537,20 @@ Luckily there's already a function for that, I just need to call it in a hook:
#+begin_src emacs-lisp
(add-hook 'before-save-hook 'delete-trailing-whitespace)
#+end_src
-** Auto-formatting
+** Formatting & indentation
Disable fill mode in Markdown
#+begin_src emacs-lisp
(add-hook 'markdown-mode-hook (lambda () (auto-fill-mode 0) (flyspell-mode 1)))
#+end_src
-A tab is 8 spaces:
+Show a tab as 8 spaces:
#+begin_src emacs-lisp
(setq-default tab-width 8)
#+end_src
-Never insert tabs with indentation:
+Never insert tabs with indentation by default:
#+begin_src emacs-lisp
(setq-default indent-tabs-mode nil)
@@ -614,7 +628,7 @@ It's more useful for me to be able to delete up to a character instead of to and
#+begin_src emacs-lisp
(global-set-key (kbd "M-z") 'zap-up-to-char)
#+end_src
-** Expand
+** Expansion/completion
Use hippie expand instead of dabbrev-expand:
#+begin_src emacs-lisp
@@ -688,6 +702,14 @@ Bind C-M-S-F to the old functionality of M-f (stop at end of word)
(global-set-key (kbd "C-x r I") 'string-insert-rectangle)
(global-set-key (kbd "C-x r R") 'replace-rectangle)
#+end_src
+** End sentences with one space
+Emacs uses the rather old-fashioned convention of treating a period followed by double spaces as end of sentence. However, it is more common these days to end sentences with a period followed by a single space.
+
+Let a period followed by a single space be treated as end of sentence:
+
+#+begin_src emacs-lisp
+ (setq sentence-end-double-space nil)
+#+end_src
* Org mode
** Yank URL
diff --git a/emacs/custom.el b/emacs/custom.el
@@ -21,7 +21,7 @@
'(objed-cursor-color "#ff6c6b")
'(package-hidden-regexps '("^I"))
'(package-selected-packages
- '(csv-mode hl-todo org-noter org-ref virtualenvwrapper elpy pdf-tools diminish company-lean counsel rainbow-mode edit-indirect expand-region elpher sr-speedbar 2048-game vterm notmuch magit lean-mode markdown-mode anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets exec-path-from-shell))
+ '(undo-tree csv-mode hl-todo org-noter org-ref virtualenvwrapper elpy pdf-tools diminish company-lean counsel rainbow-mode edit-indirect expand-region elpher sr-speedbar 2048-game vterm notmuch magit lean-mode markdown-mode anki-connect anki-editor doom-themes all-the-icons use-package-ensure which-key use-package org-bullets exec-path-from-shell))
'(pdf-view-midnight-colors (cons "#bbc2cf" "#282c34"))
'(rustic-ansi-faces
["#282c34" "#ff6c6b" "#98be65" "#ECBE7B" "#51afef" "#c678dd" "#46D9FF" "#bbc2cf"])
diff --git a/emacs/init.el b/emacs/init.el
@@ -21,9 +21,15 @@
(eql system-type 'darwin))
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
+;; Set up packages
+(require 'package)
+(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
+(package-initialize)
+(unless package-archive-contents
+ (package-refresh-contents))
+
;; Install and load use-package
(unless (package-installed-p 'use-package)
- (package-refresh-contents t)
(package-install 'use-package))
(eval-when-compile (require 'use-package))