From: Mounir AITTAHAR <mounir.aittahar@free-pasdspam.fr>
Subject: Re: [solved] Non-ASCII characters Key binding (emacs 21.4)
Date: Mon, 24 Oct 2005 21:23:51 +0200 [thread overview]
Message-ID: <djjce0$cj4$1@apollon.grec.isp.9tel.net> (raw)
In-Reply-To: <diui9l$66m$1@apollon.grec.isp.9tel.net>
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
next prev parent reply other threads:[~2005-10-24 19:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-16 21:54 Non-ASCII characters Key binding (emacs 21.4) Mounir AITTAHAR
2005-10-17 3:08 ` Stefan Monnier
2005-10-18 15:58 ` Mounir AITTAHAR
2005-10-18 16:06 ` Mounir AITTAHAR
2005-10-18 16:51 ` Pascal Bourguignon
2005-10-19 8:51 ` Mounir AITTAHAR
2005-10-19 23:11 ` Stefan Monnier
2005-10-17 11:47 ` Mounir AITTAHAR
2005-10-18 12:35 ` Mounir AITTAHAR
2005-10-19 1:47 ` Pascal Bourguignon
2005-10-24 19:23 ` Mounir AITTAHAR [this message]
2005-10-24 23:52 ` [solved] " Stefan Monnier
2005-10-25 13:29 ` Mounir AITTAHAR
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='djjce0$cj4$1@apollon.grec.isp.9tel.net' \
--to=mounir.aittahar@free-pasdspam.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).