[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [solved] Non-ASCII characters Key binding (emacs 21.4)
From: |
Mounir AITTAHAR |
Subject: |
Re: [solved] Non-ASCII characters Key binding (emacs 21.4) |
Date: |
Mon, 24 Oct 2005 21:23:51 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.7 (X11/20050923) |
Here is sample codes (works on emacs 21.4 - console, "-nw" and X mode),
maybe emacs 20.7) :
;; *********************************************************************
;; Only for emacs -nw
;; *********************************************************************
(normal-erase-is-backspace-mode 1)
(set-keyboard-coding-system 'latin-1)
;;***********************************************************************
;; Local key bindings for some modes
;;***********************************************************************
;; Set up translation-tables for unifying ISO 8859 characters on encoding.
(unify-8859-on-encoding-mode 1)
(unify-8859-on-decoding-mode 1)
;; Returns emacs keys representation
(defun kbd-from-string (list-string)
(if list-string
(cons (elt (read-kbd-macro (car list-string)) 0)
(kbd-from-string(cdr list-string)))
nil))
(setq char-strings '("é" "è" "ê" "à" "â" "î" "ô" "ù" "û"))
(setq html-char-symbols '("é" "è" "ê"
"à" "â" "î"
"ô" "ù" "û"
"ç"))
(setq tex-char-symbols '("\\'e" "\\`e" "\\^e"
"\\`a" "\\^a" "\\^i"
"\\^o" "\\`u" "\\^u"
"\\,c"))
;; Get keys repreentation
(setq char-codes (kbd-from-string char-strings nil))
;; Bindings function
(defun set-keys-from-lists (list-keys list-strings)
(if (not list-keys)
nil
(local-set-key (vector (car list-keys))
(car list-strings))
(set-keys-from-lists (cdr list-keys) (cdr list-strings))))
(defun unset-keys-from-list (list-keys)
(if (not list-keys)
nil
(local-unset-key (vector (car list-keys)))
(unset-keys-from-list (cdr list-keys))))
(defun set-default-char ()
(princ "default char mode")
(unset-keys-from-list char-codes))
(defun set-html-char ()
(princ "default char mode")
(local-set-key "\M- " (lambda()(interactive)(insert " ")))
(set-keys-from-lists char-codes html-char-symbols))
(defun set-tex-char ()
(princ "default char mode")
(set-keys-from-lists char-codes tex-char-symbols))
;; Hooks
(add-hook 'sgml-mode-hook 'set-html-char)
(add-hook 'tex-mode-hook 'set-tex-char)
;; Cool stuff
(defun switch-html-default-char-mode ()
"Switch html<=>default key bindings"
(interactive)
(cond (is-html-char-mode (setq is-html-char-mode nil)(set-default-char))
(t (setq is-html-char-mode t) (set-html-char))))
(setq is-html-char-mode nil)
(global-set-key [f5] 'switch-html-default-char-mode)
--
Mounir AITTAHAR
Re: Non-ASCII characters Key binding (emacs 21.4), Mounir AITTAHAR, 2005/10/17
Re: [solved] Non-ASCII characters Key binding (emacs 21.4),
Mounir AITTAHAR <=