Created
September 15, 2013 10:11
-
-
Save syohex/6569391 to your computer and use it in GitHub Desktop.
japanese-region-only for only Katakana.
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
;;;###autoload | |
(defun japanese-hankaku-region-only-katakana (from to &optional ascii-only) | |
(interactive "r\nP") | |
(save-restriction | |
(narrow-to-region from to) | |
(save-excursion | |
(goto-char (point-min)) | |
(while (re-search-forward "\\cK" nil t) | |
(let* ((zenkaku (preceding-char)) | |
(zenkaku-str (char-to-string zenkaku)) | |
(hankaku (or (and (not ascii-only) | |
(get-char-code-property zenkaku 'jisx0201)) | |
(get-char-code-property zenkaku 'ascii)))) | |
(when hankaku | |
(japanese-replace-region (match-beginning 0) (match-end 0) | |
hankaku))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment