Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@syohex
Created September 15, 2013 10:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syohex/6569391 to your computer and use it in GitHub Desktop.
Save syohex/6569391 to your computer and use it in GitHub Desktop.
japanese-region-only for only Katakana.
;;;###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