view elpa/yasnippet-0.9.1/snippets/emacs-lisp-mode/x-find-replace.yasnippet @ 141:ee4b6191b61e

packages: update yasnippet and deps
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 20 Apr 2016 13:40:19 -0400 (2016-04-20)
parents elpa/yasnippet-0.8.0/snippets/emacs-lisp-mode/x-find-replace.yasnippet@156cbb54f344
children
line wrap: on
line source
# contributor: Xah Lee (XahLee.org)
# name: find and replace on region
# key: x-find-replace
# --
(defun replace-html-chars-region (start end)
  "Replace “<” to “&lt;” and other chars in HTML.
This works on the current region."
  (interactive "r")
  (save-restriction
    (narrow-to-region start end)
    (goto-char (point-min))
    (while (search-forward "&" nil t) (replace-match "&amp;" nil t))
    (goto-char (point-min))
    (while (search-forward "<" nil t) (replace-match "&lt;" nil t))
    (goto-char (point-min))
    (while (search-forward ">" nil t) (replace-match "&gt;" nil t))
    )
  )