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:
  anthy

and c-\  :
  japanese-anthy

 =========
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


(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"
                 saved-cursor-color))))
        (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)





sources:
http://d.hatena.ne.jp/kitokitoki/20120925/p2
https://www.emacswiki.org/emacs/ChangingCursorDynamically
https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Commands.html

No comments:

Post a Comment