Created
November 7, 2010 14:55
-
-
Save valpackett/666161 to your computer and use it in GitHub Desktop.
Coda-like swapping in Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun coda-swap (expr) | |
(interactive "sExpr: ") | |
(query-replace-regexp | |
(replace-regexp-in-string "$[1-2]" "\\\\([0-9a-zA-Z]*\\\\)" expr) | |
(replace-regexp-in-string "$[1-2]" (lambda (m) (if (equal m "$1") "\\\\2" "\\\\1")) expr))) | |
;; Example: | |
; enter | |
; width="$1" height="$2" | |
; and it will replace | |
; width="240" height="320" | |
; with | |
; width="320" height="240" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment