summaryrefslogtreecommitdiff
path: root/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace
diff options
context:
space:
mode:
authorSimeon Simeonov2013-09-19 22:27:58 +0200
committerSimeon Simeonov2013-09-19 22:27:58 +0200
commit7bf6712498ad2618bee7bf5b3866fb6da0772339 (patch)
treefd4d959c0f1679f2abf5663399d68df0a06472de /.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace
parentb045e27c545d4027811637193632ec3ea5ef7858 (diff)
All snippets imported, init file polished
Diffstat (limited to '.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace')
-rw-r--r--.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace17
1 files changed, 17 insertions, 0 deletions
diff --git a/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace
new file mode 100644
index 0000000..cefcf51
--- /dev/null
+++ b/.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace
@@ -0,0 +1,17 @@
1#name : find and replace on region
2#contributor : Xah Lee
3# --
4(defun replace-html-chars-region (start end)
5 "Replace “<” to “&lt;” and other chars in HTML.
6This works on the current region."
7 (interactive "r")
8 (save-restriction
9 (narrow-to-region start end)
10 (goto-char (point-min))
11 (while (search-forward "&" nil t) (replace-match "&amp;" nil t))
12 (goto-char (point-min))
13 (while (search-forward "<" nil t) (replace-match "&lt;" nil t))
14 (goto-char (point-min))
15 (while (search-forward ">" nil t) (replace-match "&gt;" nil t))
16 )
17 )