Prev / Next

2003-11-19 / dabbrev 日英混在文用の設定

入門 Meadow / Emacs p.248 より.

;; dabbrev
;; 日英混在文用の設定
(defadvice dabbrev-expand
  (around modify-regexp-for-japanese activate compile)
  "Modify `dabbrev-abbrev-char-regexp` dynamically for Japanese words."
  (if (bobp)
      ad-do-it
    (let ((dabbrev-abbrev-char-regexp
	   (let ((c (char-category-set (char-before))))
	     (cond
	      ((aref c ?a) "[-_A-Za-z0-9]") ; ASCII
	      ((aref c ?j)                  ; Japanese
	       (cond
		((aref c ?K) "\\cK")        ; Katakana
		((aref c ?A) "\\cA")        ; 2 byte alphanumeric
		((aref c ?H) "\\cH")        ; hiragana
		((aref c ?C) "\\cC")        ; kanji
		(t "\\cj")))
	      ((aref c ?k) "\\ck")          ; hankaku-kana
	      ((aref c ?r) "\\cr")          ; Japanese roman ?
	      (t dabbrev-abbrev-char-regexp)))))
      ad-do-it)))

入門Meadow/Emacs / 小関吉則

comments powered by Disqus