dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

lh-xml.el (565B)


      1 ;; -*- lexical-binding: t; -*-
      2 (require 'xml)
      3 
      4 (defun lh/xml-escape-region (beg end ARG)
      5   (interactive "r\nP")
      6   (when (not (region-active-p))
      7     (setq beg (point-min))
      8     (setq end (point-max)))
      9   (let* ((text (buffer-substring-no-properties beg end))
     10          (escaped (if ARG
     11                       (with-temp-buffer
     12                         (save-excursion
     13                           (insert text))
     14                         (xml-parse-string))
     15                     (xml-escape-string text))))
     16     (delete-region beg end)
     17     (insert escaped)))
     18 
     19 (provide 'lh-xml)