They say he is not held back by knowledge

Silly shrug emoji for emacs abbreviations

Emacs has abbrev mode (see the help in emacs and the Abbrevs section) that allows you to set abbrevations that replace words you type. You might, for instance, what to correct teh to the as that's a typo that you always make so you can tell abbrev to do that.

teh<Ctrl-x a g>the<CR>

That would tell abbrev add-global-abbrev for teh to the. You can also use <Ctrl-x a l> for local, which just does it for the mode you are in.

For me I wanted to insert the shrug emoji ascii art – “¯\(ツ)/¯” when I type shrug so I did the following.

¯\\_(ツ)_/¯<Ctrl-x a g>shrug

You can also add an extra i in there. <Ctrl-x a i g> That's inverse so you can do the definition backward. I just cut and pasted the string in a buffer.

Now when I type shrug in emacs it creates an emoji every time. I don't know how annoying that will become but I might add an 8 before the def so I need to add 8shurg to get it as per more examples below.

Anyway here is my ~/.emacs.d/abbrev_defs.el config file with a few other gems that I forgot where there...

It's quite interesting how much of this stuff just works out the box. The keyboard shortcuts can seem cryptic though the which-key package can help there.

Also note that there is the command unexpand-abbrev that can just undo the last abbreviation.

;;-*-coding: utf-8;-*-
(define-abbrev-table 'global-abbrev-table
  '(
    ("8Delta" "Δ" nil :count 0)
    ("8Omega" "Ω" nil :count 0)
    ("8Sigma" "Σ" nil :count 0)
    ("8accent" "´" nil :count 0)
    ("8almost" "≈" nil :count 0)
    ("8alpha" "α" nil :count 0)
    ("8beta" "β" nil :count 0)
    ("8bull" "∙" nil :count 0)
    ("8cels" "℃" nil :count 0)
    ("8copy" "©" nil :count 0)
    ("8deg" "°" nil :count 0)
    ("8delta" "δ" nil :count 0)
    ("8down" "↓" nil :count 0)
    ("8eur" "€" nil :count 0)
    ("8gamma" "γ" nil :count 0)
    ("8in" "∈" nil :count 0)
    ("8inf" "∞" nil :count 0)
    ("8ksi" "ξ" nil :count 0)
    ("8lambda" "λ" nil :count 0)
    ("8ldquo" "«" nil :count 0)
    ("8left" "←" nil :count 0)
    ("8mdash" "—" nil :count 0)
    ("8mdot" "·" nil :count 0)
    ("8mu" "µ" nil :count 0)
    ("8ndash" "–" nil :count 0)
    ("8nin" "∉" nil :count 0)
    ("8not" "¬" nil :count 0)
    ("8nu" "ν" nil :count 0)
    ("8omega" "ω" nil :count 0)
    ("8para" "§" nil :count 0)
    ("8phi" "φ" nil :count 0)
    ("8pi" "π" nil :count 0)
    ("8plusmin" "±" nil :count 0)
    ("8pound" "£" nil :count 0)
    ("8psi" "ψ" nil :count 0)
    ("8range" "÷" nil :count 0)
    ("8rdquo" "»" nil :count 0)
    ("8reg" "®" nil :count 0)
    ("8right" "→" nil :count 0)
    ("8sigma" "σ" nil :count 0)
    ("8sup1" "¹" nil :count 0)
    ("8sup2" "²" nil :count 0)
    ("8sup3" "³" nil :count 0)
    ("8tau" "τ" nil :count 0)
    ("8theta" "θ" nil :count 0)
    ("8tm" "™" nil :count 0)
    ("8up" "↑" nil :count 0)
    ("shrug" "¯\\_(ツ)_/¯" nil :count 1)
   ))