Skip to content

Instantly share code, notes, and snippets.

@uchidev
Created August 13, 2020 19:15
Show Gist options
  • Save uchidev/60f9c1488e5fadfc3d4084fc89c2aa5e to your computer and use it in GitHub Desktop.
Save uchidev/60f9c1488e5fadfc3d4084fc89c2aa5e to your computer and use it in GitHub Desktop.
(defvar personal-transform-history
(list "codeblock" "linkline" "pre,code" "hconv <>" "div id=\"\" class=\"\"" "hexstr" "utfcode" "ucscode")
"The history of personal-transform-region")
(defun personal-transform-region (arg-str beg end)
"Sets of the personal tools to transform specified the region"
(interactive
(let ((str (read-string
(format "Command[%s]: " (car personal-transform-history))
nil 'personal-transform-history)))
(list (if (string= str "") (car personal-transform-history) str)
(region-beginning) (region-end))))
(cond
;; hconv <>
((string-match "^hconv \s*\\([^\s]+\\)\s*$" arg-str)
(let ((s (match-string 1 arg-str)))
(personal-transform-region-html-special-char s beg end)))
;; hexstr
((string-match "^hexstr$" arg-str)
(personal-transform-region-to-hex-esc-str beg end))
;; utfcode
((string-match "^utfcode$" arg-str)
(personal-transform-region-to-code beg end 'utf-8))
;; ucscode
((string-match "^ucscode$" arg-str)
(personal-transform-region-to-code beg end 'utf-16be))
;; codeblock
((string-match "^codeblock\s*$" arg-str)
(personal-transform-region-to-cblock-1 beg end))
;; codeblock (java|js|c)
((string-match "^codeblock \s*\\([0-9A-Za-z_\-\+\/]+\\)\s*$" arg-str)
(let ((s (match-string 1 arg-str)))
(personal-transform-region-to-cblock-2 beg end s)))
;; linkline
((string-match "^linkline\s*$" arg-str)
(personal-transform-region-to-link-line beg end))
;; pre,conv
;; div id="xxx"
;; h3
;; ......
(t (personal-transform-region-html-markup arg-str beg end))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment