Skip to content

Instantly share code, notes, and snippets.

@takehiko
Created July 12, 2012 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takehiko/3100452 to your computer and use it in GitHub Desktop.
Save takehiko/3100452 to your computer and use it in GitHub Desktop.
Replace Punctuation (ten-maru and comma-period in Japanese)
;; 句読点変換(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