search and replace for elisp.

By Hal Canary, 2004-02-18 13:56:59 (link)
#computers-code

When mutt is told to gpg sign an email, it will use Quoted-Printable Content-Transfer-Encoding, which will replace " \n" with "=20\n", an escape sequence of some sort. (ASCII " " is 0x20.)

I'd rather replace " \n" with "\n" anyways. Here's some elisp code to do just that:

;; ~/.emacs ;;
(defun hal1 () (interactive)
  (auto-mega-replace  " \n" "\n"))
(defun auto-mega-replace (arg1 arg2)
  (save-excursion
    (beginning-of-buffer)
    (while (search-forward arg1)
      (beginning-of-buffer)
      (perform-replace arg1 arg2
        nil nil nil)
      (beginning-of-buffer))))

[edited 2003-02-20]


(back)