Emacs

by Jochem Kossen on

english, tech

While every now and then I try out other text editors, GNU Emacs is where my home appears to be. This page marks the entrypoint of my collection of notes on it.

init.el

I like to configure my init.el with use-package. It consists of a bunch of use-package declarations such as the following:

 1  (use-package org
 2    :ensure nil
 3    :bind
 4    ("C-c a" . org-agenda)
 5    ("C-c c" . org-capture)
 6    :config
 7    (setopt
 8     org-startup-indented nil
 9     org-pretty-entities t
10     org-use-sub-superscripts nil
11     ;; ... more options
12     )
13    :hook
14    ;; (org-mode . variable-pitch-mode)
15    (org-mode . visual-line-mode)
16    (org-capture-mode . delete-other-windows))

A couple of notes

  • :ensure nil is for packages coming with emacs, so these don't need to be pulled from the elpa or melpa archives.
  • I use setopt instead of setq. setopt validates types and ensures setter functions associated to the option are executed. This makes setopt slower, but safer. Your mileage may vary. setopt has been available since Emacs 29.

org-mode

Prevent accidental deletions of folded text

I often use Ctrl-k, excuse me, C-k, to delete lines. When doing that on folded text, org-mode by default removes all text in the fold. So, after a couple of times of having deleted more text than I'd like to admit, I came across these protective options that work like a boss:

1  (setopt
2   ;; prevent edits of collapsed text
3   org-fold-catch-invisible-edits 'smart
4   ;; prevent accidental deletion of collapsed tree with C-k
5   org-ctrl-k-protect-subtree t)

Some less desctructive options

1  (setopt
2   org-pretty-entities t            ;; render UTF-8 character instead of showing the character code
3   org-startup-with-inline-images t ;; show images by default
4   org-image-actual-width t         ;; don't scale an inlined image by default
5   org-image-max-width 'window      ;; but do cap the scale at the size of the window
6   org-image-align 'center          ;; show images in the center of the window
7   )

visual-line-mode

See https://www.gnu.org/software/emacs/manual/html_node/emacs/Visual-Line-Mode.html

1  (use-package org
2    ;; ...
3    :hook
4    (org-mode . visual-line-mode))

mu4e

When replying to a message sent to one of my alternative e-mail addresses, I noticed mu4e set the From address to my default e-mail address.

Turns out you need to let mu know about your alternative addresses by specifying the --my-address option for each of your e-mail addresses:

1  jochem@xiug ~ % mu init --maildir=~/Maildir.personal --my-address=primary@jkossen.nl --my-address=alternative1@jkossen.nl --my-address=alternative2@jkossen.nl
2  jochem@xiug ~ % mu index
3  indexing maildir /Users/jochem/Maildir.personal -> store /Users/jochem/.cache/mu/xapian
4  / indexing messages; checked: 2019; updated/new: 2019; cleaned-up: 0
5  jochem@xiug ~ %

Meta

Tags: emacs, orgmode, gnu, texteditor, plaintext, software

Permalink: https://jkossen.nl/emacs/