From 7bf6712498ad2618bee7bf5b3866fb6da0772339 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Thu, 19 Sep 2013 22:27:58 +0200 Subject: All snippets imported, init file polished --- .../mysnippets/text-mode/emacs-lisp-mode/find-replace | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace (limited to '.emacs.d/mysnippets/text-mode/emacs-lisp-mode/find-replace') 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 @@ +#name : find and replace on region +#contributor : Xah Lee +# -- +(defun replace-html-chars-region (start end) + "Replace “<” to “<” 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 "&" nil t)) + (goto-char (point-min)) + (while (search-forward "<" nil t) (replace-match "<" nil t)) + (goto-char (point-min)) + (while (search-forward ">" nil t) (replace-match ">" nil t)) + ) + ) -- cgit v1.3