unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Non-ASCII characters Key binding (emacs 21.4)
@ 2005-10-16 21:54 Mounir AITTAHAR
  2005-10-17  3:08 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-16 21:54 UTC (permalink / raw)


Hi,

On emacs 20.7 (yes), i wrote some lisp functions in order to
subsitute local characters (like é, ô) with sgml values (like é, 
ô) or LaTeX corresponding sequences (like \'e,\^o).

Theses functions looked like :

(local-set-key (vector 233) ;
                   (lambda()(interactive)(sgml-name-char 233)))
Or,
(local-set-key (vector 233)
                   (lambda()(interactive) (insert "è")))


On emacs 20.7, it worked. On emacs 21.4, it doesn't work more.
I've tried to found why trough Google search, tried several way likee
but nothing.

233 is the value of "grave e" character.

I'm using a vector because it is told on the description of 
local-set-key , and to prevent the problem of multibytes
characters (GNU Emacs manual : 
http://www.gnu.org/software/emacs/elisp-manual/html_node/elisp_333.html).

What have i done wrong ? Is this a known problem ?

Thanks and regards,

-- 
Mounir AITTAHAR
PS : this mail is in iso-latin-1. I hope it will be readable by all.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  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-17 11:47 ` Mounir AITTAHAR
  2005-10-24 19:23 ` [solved] " Mounir AITTAHAR
  2 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2005-10-17  3:08 UTC (permalink / raw)


> On emacs 20.7, it worked. On emacs 21.4, it doesn't work more.
> I've tried to found why trough Google search, tried several way likee
> but nothing.

> 233 is the value of "grave e" character.

Yes, under Emacs-20.7 the code received was not always translated through
the locale-coding-system, so it sometimes said "233" instead of "à".
Luckily it still worked in most cases because self-insert-command, when
inserting the char in the buffer used the `nonascii-translation-table' which
turned the "233" into "à".

In Emacs-21, this was fixed so that the code received is now always "à"
rather than 233 (233 may mean à in some locales but it means other things in
other locales).  In future Emacsen, which specific "à" is returned is likely
to change.

See the "translating keys" thread.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-16 21:54 Non-ASCII characters Key binding (emacs 21.4) Mounir AITTAHAR
  2005-10-17  3:08 ` Stefan Monnier
@ 2005-10-17 11:47 ` Mounir AITTAHAR
  2005-10-18 12:35   ` Mounir AITTAHAR
  2005-10-24 19:23 ` [solved] " Mounir AITTAHAR
  2 siblings, 1 reply; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-17 11:47 UTC (permalink / raw)


This problem occurs when emacs is launched in X11 mode (console mode works)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-17 11:47 ` Mounir AITTAHAR
@ 2005-10-18 12:35   ` Mounir AITTAHAR
  2005-10-19  1:47     ` Pascal Bourguignon
  0 siblings, 1 reply; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-18 12:35 UTC (permalink / raw)


Mounir AITTAHAR wrote:
> This problem occurs when emacs is launched in X11 mode (console mode works)

In true console mode, yes.

Even in Xterm-mode it doenst work, and this is more serious :
  * typing "é" produces "M-i" !
  * "C-xxx" doesn'nt work too...

I'm feeling lost...

-- 
Mounir AITTAHAR

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  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
  0 siblings, 2 replies; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-18 15:58 UTC (permalink / raw)


I can bind on interactive mode, but on line mode, I cannot reach the
key "é". I've tried this :

(kbd "é"), "é", "M-i"... Nothing works...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-18 15:58   ` Mounir AITTAHAR
@ 2005-10-18 16:06     ` Mounir AITTAHAR
  2005-10-18 16:51     ` Pascal Bourguignon
  1 sibling, 0 replies; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-18 16:06 UTC (permalink / raw)


Hey, I've found  a way : (read-key-sequence "") returns 3945 (???) if y
type "é"

so :

(local-set-key (vector 3945)
                  (lambda()(interactive) (insert "é")))

Works !! But I cannot explain why... :/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Pascal Bourguignon @ 2005-10-18 16:51 UTC (permalink / raw)


"Mounir AITTAHAR" <downwater@free.fr> writes:

> I can bind on interactive mode, but on line mode, I cannot reach the
> key "é". I've tried this :
>
> (kbd "é"), "é", "M-i"... Nothing works...

Here: (kbd "é") --> [2281]

What do you get on your computer?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Cats meow out of angst
"Thumbs! If only we had thumbs!
We could break so much!"

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-18 12:35   ` Mounir AITTAHAR
@ 2005-10-19  1:47     ` Pascal Bourguignon
  0 siblings, 0 replies; 13+ messages in thread
From: Pascal Bourguignon @ 2005-10-19  1:47 UTC (permalink / raw)


Mounir AITTAHAR <mounir.aittahar@fri.fr> writes:

> Mounir AITTAHAR wrote:
>> This problem occurs when emacs is launched in X11 mode (console mode works)
>
> In true console mode, yes.
>
> Even in Xterm-mode it doenst work, and this is more serious :
>   * typing "é" produces "M-i" !
>   * "C-xxx" doesn'nt work too...
>
> I'm feeling lost...

Not surprizing, if you change random variables.

In a terminal, the input is much more basic.  You have only a stream
of 8-bit codes.  The terminal can be configured to send ESC c when you
type Meta-C, or to send c|0x80.  Unfortunately, if you use another
encoding than ASCII, codes with the high order bit set are used (to
encode non ASCII characters).

So if  you want to  be able to  distinguish an ISO-8859-1 é  from M-i,
you'll have to configure the terminal to send ESC i for M-i instead of
'i'|0x80.  And of course, configure emacs accordingly.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-18 16:51     ` Pascal Bourguignon
@ 2005-10-19  8:51       ` Mounir AITTAHAR
  2005-10-19 23:11         ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-19  8:51 UTC (permalink / raw)


> Here: (kbd "é") --> [2281]
> What do you get on your computer?

Something amazing :) See yourself :

(kbd "é")-->[233]
(kbd "è")-->[232]

Okay, but read this :

(read-key-sequence ""), and typing "é" ---> [3945]
(read-key-sequence ""), and typing "è" ---> [3944]

It seems this is (kbd %c) + 3712. Why 3712.

So, if I do emacs (with X), it works :
(global-set-key [3945] (lambda()(interactive)(insert "e acute")))
(global-set-key [3944] (lambda()(interactive)(insert "e grave")))

Amazing, isn't it ?

-----------------------------------------------------------------
Related :

If i do this in emacs -nw, it works (unless i put keyboard-coding-system 
to iso-latin-1 or latin-1) :
(global-set-key [233] (lambda()(interactive)(insert "e acute")))
(global-set-key [232] (lambda()(interactive)(insert "e grave")))
or
(global-set-key (kbd "é") (lambda()(interactive)(insert "e acute")))
(global-set-key (kbd "è") (lambda()(interactive)(insert "e grave")))

If i do this in emacs (*true* console mode), it works too.

------------------------------------------------------------------


-- 
Mounir AITTAHAR

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Non-ASCII characters Key binding (emacs 21.4)
  2005-10-19  8:51       ` Mounir AITTAHAR
@ 2005-10-19 23:11         ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2005-10-19 23:11 UTC (permalink / raw)


> (kbd "é")-->[233]
> (kbd "è")-->[232]

You're probably using the (standard-display-european) abomination.
Please remove it from your .emacs.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [solved] Non-ASCII characters Key binding (emacs 21.4)
  2005-10-16 21:54 Non-ASCII characters Key binding (emacs 21.4) Mounir AITTAHAR
  2005-10-17  3:08 ` Stefan Monnier
  2005-10-17 11:47 ` Mounir AITTAHAR
@ 2005-10-24 19:23 ` Mounir AITTAHAR
  2005-10-24 23:52   ` Stefan Monnier
  2 siblings, 1 reply; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-24 19:23 UTC (permalink / raw)


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 '("&eacute;" "&egrave;" "&ecirc;"
                           "&agrave;" "&acirc;"  "&icirc;"
                           "&ocirc" "&ugrave;" "&ucirc;"
                           "&ccedil"))
(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 "&nbsp;")))
   (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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [solved] Non-ASCII characters Key binding (emacs 21.4)
  2005-10-24 19:23 ` [solved] " Mounir AITTAHAR
@ 2005-10-24 23:52   ` Stefan Monnier
  2005-10-25 13:29     ` Mounir AITTAHAR
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2005-10-24 23:52 UTC (permalink / raw)


> (setq html-char-symbols '("&eacute;" "&egrave;" "&ecirc;"
>                            "&agrave;" "&acirc;"  "&icirc;"
>                            "&ocirc" "&ugrave;" "&ucirc;"
>                            "&ccedil"))

For what it's worth I never use those.  Instead I use latin-1 (or utf-8) and
specify the coding-system.

> (setq tex-char-symbols '("\\'e" "\\`e" "\\^e"
>                           "\\`a" "\\^a" "\\^i"
>                           "\\^o" "\\`u" "\\^u"
>                           "\\,c"))

Same thing here.  A good \usepackage[latin1]{inputenc} gives you real
accents rather than the above abomination (which not only looks ugly but
doesn't work quite right in many contexts, such as verbatim).


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [solved] Non-ASCII characters Key binding (emacs 21.4)
  2005-10-24 23:52   ` Stefan Monnier
@ 2005-10-25 13:29     ` Mounir AITTAHAR
  0 siblings, 0 replies; 13+ messages in thread
From: Mounir AITTAHAR @ 2005-10-25 13:29 UTC (permalink / raw)


> For what it's worth I never use those.  Instead I use latin-1 (or utf-8) and
> specify the coding-system.

> Same thing here.  A good \usepackage[latin1]{inputenc} gives you real
> accents rather than the above abomination (which not only looks ugly but
> doesn't work quite right in many contexts, such as verbatim).

Right, someone in the french emacs usegroup (f.c.a.emacs) just told me 
the same thing. For html, I know but I code theses bindings some years 
ago when it was fashionnable to use &eacute; than latin-1/utf-8 coding 
system meta. About LaTeX inputenc package, I didn't know it :(

I spent several days to perform theses bindings (and they works now on 
true/xterm console and X11) for NO-THING !

Thanks for your help all, however.

Regards,

-- 
Mounir AITTAHAR

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-10-25 13:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [solved] " Mounir AITTAHAR
2005-10-24 23:52   ` Stefan Monnier
2005-10-25 13:29     ` Mounir AITTAHAR

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).