!.→。/,→、の置換 普段は,句読点には.と,を使っているのだけど,ごくたまに。と、にする必要がある. M-x replace-stringとかで変換するのだけど, ふと思いたって, (defun conv-japanese-punctuation-region (start end) (interactive "r") (progn (replace-string-in-region "." "。" start end) (replace-string-in-region "," "、" start end) )) を,ChatGPTに与えて,「このままだと動かないのだけど動くようにして」と,頼んでみたところ, (defun conv-japanese-punctuation-region (start end) "Convert Japanese delimiters in region from Chinese-style to Japanese-style." (interactive "r") (save-excursion (save-restriction (narrow-to-region start end) (goto-char (point-min)) (while (search-forward "." nil t) (replace-match "。")) (goto-char (point-min)) (while (search-forward "," nil t) (replace-match "、"))))) なる回答をだしてきてくれた.で,これ,ちゃんと動く.すごい. リージョンじゃなくてバッファを対象にする場合は?と聞くと, (defun conv-japanese-punctuation-buffer () "Convert all Chinese-style punctuation in the buffer to Japanese-style punctuation." (interactive) (save-excursion (goto-char (point-min)) (while (search-forward "." nil t) (replace-match "。")) (goto-char (point-min)) (while (search-forward "," nil t) (replace-match "、")))) だそうで,これもちゃんと動作する.すごい. で,いつものemacs-lisp集に追加したので,これからは簡単に変換ができるようになった.