Emacs Lisp Multi-Pair Find & Replace Commands

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

This page shows examples of multi-pair find & replace in emacs lisp.

You need the elisp library xah-replace-pairs.el at Emacs Lisp: Multi-Pair Find Replace: xah-replace-pairs.el.

CSS Compressor

Emacs Lisp: CSS Compressor

Escape/UnEscape Backslash

These are very useful when you do text processing in emacs lisp. For example, if you need to process HTML, just copy raw HTML text, paste in emacs, then press a button to escape quote characters, and now you are ready to put them inside elisp string.

Emacs Lisp: Escape Quotes

TeX Math Symbols to Unicode

Useful if you work with math a lot such as LaTeX.

(require 'xah-replace-pairs)

(defun xah-replace-greeks-to-symbols (φbegin φend)
  "Replace alpha to α etc in current line or selection.
Version 2015-04-28"
   (if (use-region-p)
       (list (region-beginning) (region-end))
     (list (line-beginning-position) (line-end-position))))
     ["alpha" "α"]
     ["beta" "β"]
     ["gamma" "γ"]
     ["theta" "θ"]
     ["lambda" "λ"]
     ["delta" "δ"]
     ["epsilon" "φ"]
     ["omega" "ω"]
     ["Pi" "π"])))

You might need to modify it to include backslash, add more symbols, or change conversion direction.

Curly Quote Fixes

The following is useful when you want to normalize the style of punctuation in essay or novel.

Emacs: Convert Straight/Curly Quotes

Emacs Lisp: Convert Unicode Chars to ASCII

Emacs Lisp: Convert Unicode Chars to ASCII (Zap Gremlins)

Change {Round, Square, Curly} Brackets

Emacs: Change Brackets () {} [] in Region

Convert Punctuation Between English/Chinese Forms

Emacs Lisp: Convert Punctuation Between English/Chinese Forms

Convert Latin Alphabet to Unicode Gothic-style Characters

𝔗𝔥𝔬𝔲 𝔖𝔥𝔞𝔩𝔱 𝔘𝔰𝔢 𝔈𝔪𝔞𝔠𝔰 𝔏𝔦𝔰𝔭 Convert Latin Alphabet to Gothic

Make HTML Table

Another different use, but essentially same technique of find & replace, is to convert a plain text table into a HTML table. See: Emacs Lisp: How to Write a make-html-table Command.

Emacs ♥

Like it? Buy Xah Emacs Tutorial.