Created
July 12, 2012 19:45
-
-
Save takehiko/3100452 to your computer and use it in GitHub Desktop.
Replace Punctuation (ten-maru and comma-period in Japanese)
This file contains hidden or 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
;; 句読点変換(M-x tenmaru / M-x commamaru / M-x commaperiod) | |
;; http://d.hatena.ne.jp/takehikom/20120713/1342122621 | |
(defun replace-punctuation (a1 a2 b1 b2) | |
"Replace periods and commas" | |
(let ((s1 (if mark-active "選択領域" "バッファ全体")) | |
(s2 (concat a2 b2)) | |
(b (if mark-active (region-beginning) (point-min))) | |
(e (if mark-active (region-end) (point-max)))) | |
(if (y-or-n-p (concat s1 "の句読点を「" s2 "」にしますがよろしいですか?")) | |
(progn | |
(replace-string a1 a2 nil b e) | |
(replace-string b1 b2 nil b e))))) | |
(defun tenmaru () | |
"選択領域またはバッファ全体の句読点を「、。」にします" | |
(interactive) | |
(replace-punctuation "," "、" "." "。")) | |
(defun commamaru () | |
"選択領域またはバッファ全体の句読点を「,。」にします" | |
(interactive) | |
(replace-punctuation "、" "," "." "。")) | |
(defun commaperiod () | |
"選択領域またはバッファ全体の句読点を「,.」にします" | |
(interactive) | |
(replace-punctuation "、" "," "。" ".")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment