Saturday, May 19, 2012

emacs japanese

c-x ret r for changing the encoding of an already opened file
x-x ret f for changing the encoding for saving the file

sudo apt-get install  anthy-el

then, in emacs

m-x load-library:

and c-\  :

for mozc

sudo apt-get install emacs-mozc emacs-mozc-bin

and in emacs add

(require 'mozc)
;; or (load-file "/path/to/mozc.el")
(set-language-environment "Japanese")
(setq default-input-method "japanese-mozc")
(prefer-coding-system 'utf-8) 
for key mode change (USE FCITX,NOT IBUS)
dconf-editor, org.gnome.desktop.input-sources sources should read
[('fcitx', 'mozc-jp')]
(global-set-key (kbd "<zenkaku-hankaku>") 'toggle-input-method)

for cursor color depending on the input mode
;; Change cursor color according to mode
    (defvar hcz-set-cursor-color-color "")
    (defvar hcz-set-cursor-color-buffer "")
    (defun hcz-set-cursor-color-according-to-mode ()
      "change cursor color according to some minor modes."
      ;; set-cursor-color is somewhat costly, so we only call it when needed:
      (let ((color
             (if buffer-read-only "white"
               (if mozc-mode "red"
        (unless (and
                 (string= color hcz-set-cursor-color-color)
                 (string= (buffer-name) hcz-set-cursor-color-buffer))
          (set-cursor-color (setq hcz-set-cursor-color-color color))
          (setq hcz-set-cursor-color-buffer (buffer-name)))))
    (add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode)


No comments:

Post a Comment