Created
August 13, 2020 19:15
-
-
Save uchidev/60f9c1488e5fadfc3d4084fc89c2aa5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun personal-transform-region-to-link-line (beg end) | |
"タイトルとURLの2行を、markdownのLINK行の形式に変換する" | |
(save-excursion | |
(goto-char end) | |
(cond ((bolp)(forward-char -1)(insert ")")) | |
((eolp)(insert-before-markers ")")) | |
(t (insert-before-markers ")\n")(forward-char -1))) | |
(beginning-of-line) | |
(insert "(") | |
(beginning-of-line) | |
(delete-char -1) | |
(insert "]") | |
(beginning-of-line) | |
(insert "- ["))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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