From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mounir AITTAHAR Newsgroups: gmane.emacs.help Subject: Re: [solved] Non-ASCII characters Key binding (emacs 21.4) Date: Mon, 24 Oct 2005 21:23:51 +0200 Organization: 9Telecom Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1130182024 32720 80.91.229.2 (24 Oct 2005 19:27:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Oct 2005 19:27:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 24 21:27:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EU7wa-0003Nn-S8 for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Oct 2005 21:25:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EU7wa-0006IW-An for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Oct 2005 15:25:16 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fr.ip.ndsoftware.net!proxad.net!usenet-fr.net!gaoland.net!grec.isp.9tel.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 86 Original-NNTP-Posting-Host: 220.13.101-84.rev.gaoland.net Original-X-Trace: apollon.grec.isp.9tel.net 1130181888 12900 84.101.13.220 (24 Oct 2005 19:24:48 GMT) Original-X-Complaints-To: abuse@9online.fr Original-NNTP-Posting-Date: Mon, 24 Oct 2005 19:24:48 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:134945 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:30533 Archived-At: 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