Now showing
Emacs: abbreviations with abbrev-mode (quick text expansion)
About this film
In this ~27 minute video, I explain how to use the built-in abbrev-mode to define “abbreviations” for quick-yet-powerful text expansion. I cover the most simple scenario and then go into more technical implementations: (i) to use a function instead of a predetermined text, and (ii) to expand what counts as an abbreviation so as to use characters that are not word constituents. Here is a variant of what I had in my scratch buffer: ```elisp ;;; Simple abbreviations ;; Abbrevs are grouped into “tables”. The most specific table ;; overrides the more general one in case of a conflict. (define-abbrev global-abbrev-table “metest” “a global abbrev for demo purposes”) (define-abbrev text-mode-abbrev-table “metest” “text-mode abbrev expansion here”) (define-abbrev org-mode-abbrev-table “metest” “org-mode abbrev”) ;; `abbrev-mode’ is buffer-local (abbrev-mode 1) ; so this is WRONG ;; The following is the correct way to enable the buffer-local minor ;; mode where you want it. Remember the inheritence of major modes. ;; ;; Parent modes: prog-mode' (programming), text-mode’ (prose). (add-hook ‘text-mode-hook ‘abbrev-mode) ;;; Abbreviations that expand into some text by calling a function. (defun…
Directors & creators
Protesilaos Stavrou
More from this pool