Source

latin-euro-standards / latin-euro-latin9.el

Full commit
;;; latin-euro-latin9.el --- Define language environment

;; Copyright (C) 2002, 2003 Free Software Foundation, Inc

;; Author: Stephen J. Turnbull
;; Keywords: mule, charsets
;; Created: 2002 March 7 (as latin-unity-latin9.el)
;; Last-modified: 2005 February 7

;; This file is part of XEmacs.

;; XEmacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; XEmacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.


;;; Commentary:

;; Provides the latin-9 language environment, character set and coding
;; system.

;;; Code:

;; define ISO-8859-15 for XEmacs 21.4 and earlier

;;;###autoload
(unless (find-charset 'latin-iso8859-15)
  ;; Create character set
  (make-charset
   'latin-iso8859-15 "ISO8859-15 (Latin 9)"
   '(short-name "Latin-9"
     long-name "ISO8859-15 (Latin 9)"
     registry "iso8859-15"
     dimension 1
     columns 1
     chars 96
     final ?b
     graphic 1
     direction l2r))
  ;; For syntax of Latin-9 characters.
  (loop for c from 64 to 127		; from '�' to '�'
    do (modify-syntax-entry (make-char 'latin-iso8859-15 c) "w"))
  (loop for c in '(#xA6 #xA8 #xB4 #xB8 #xBC #xBD #xBE)
    do (modify-syntax-entry (make-char 'latin-iso8859-15 c) "w"))
  (modify-syntax-entry (make-char 'latin-iso8859-15 32) "w") ; no-break space
  (modify-syntax-entry (make-char 'latin-iso8859-15 87) "_") ; multiply
  (modify-syntax-entry (make-char 'latin-iso8859-15 119) "_")) ; divide

;;;###autoload
(unless (find-coding-system 'iso-8859-15)
  ;; Create coding system. No need for a `safe-charsets' parameter, if an
  ;; XEmacs can handle that, it has this coding system built in.
  (make-coding-system
   'iso-8859-15 'iso2022 "MIME ISO-8859-15"
   '(charset-g0 ascii
     charset-g1 latin-iso8859-15
     charset-g2 t			; grrr
     charset-g3 t			; grrr
     mnemonic "MIME/Ltn-9")))

;;;###autoload
(unless (assoc "Latin-9" language-info-alist)
  (defun setup-latin9-environment ()
    "Set up multilingual environment (MULE) for European Latin-9 users."
    (interactive)
    (set-language-environment "Latin-9"))

  (set-language-info-alist
   "Latin-9"
   `((charset ascii latin-iso8859-15)
     (coding-system . iso-8859-15)
     (coding-priority . iso-8859-15)
     (input-method . "latin-9-prefix")
     (sample-text . ,(format "\
Hello, Hej, Tere, Hei, Bonjour, Gr%c%c Gott, Ciao, %cHola!, my %c0.02"
                             ;; SMALL U WITH UMLAUT
                             (make-char 'latin-iso8859-15 #x7C)
                             ;; GERMAN SHARP S
                             (make-char 'latin-iso8859-15 #x5F)
                             ;; INVERTED EXCLAMATION MARK
                             (make-char 'latin-iso8859-15 #x21)
                             ;; EURO SIGN
                             (make-char 'latin-iso8859-15 #x24)))
     (documentation . "\
This is a generic language environment for Latin-9 (ISO-8859-15).  It
supports the Euro and the following languages:
 Danish, Dutch, English, Faeroese, Finnish, French, German, Icelandic,
 Irish, Italian, Norwegian, Portuguese, Spanish, and Swedish.
We also have a German specific language environment \"German\"."))
   '("European")))

;;;###autoload
(defun-when-void set-character-of-keysym (keysym character)
  "Make CHARACTER be inserted when KEYSYM is pressed, 
and the key has been bound to `self-insert-command'.  Contrary to the case
with `get-character-of-keysym', KEYSYM may only be a symbol, characters are
forbidden.  "
  (check-argument-type 'symbolp keysym) 
  (check-argument-type 'characterp character)
  (put keysym 'ascii-character character))

;;;###autoload
(defun-when-void get-character-of-keysym (keysym)
  "Return the character inserted when KEYSYM is pressed, 
and the key is bound to `self-insert-command'.  "
  (check-argument-type 'symbolp keysym)
  (event-to-character (make-event 'key-press (list 'key keysym))))

;; #### move these to a separate file for keysyms
;; These are all the ones not in Latin-1.

;;;###autoload
(flet ((define-keysym-as-char (keysym character)
	 (unless (lookup-key global-map (vector keysym))
	   (define-key global-map (vector keysym) #'self-insert-command))
	 ;; Belt and braces ... 
	 (unless (get-character-of-keysym keysym)
	   (set-character-of-keysym keysym character)))
       (foo (k o)
	 (define-keysym-as-char k (make-char 'latin-iso8859-15 o))))
  (foo 'EuroSign   #x24)
  ;; Don't override these. This code is autoloaded, before the X11 device is
  ;; available, so what happens is the Latin 2 keysyms are overridden. See
  ;; http://mid.gmane.org/87ll1xcm3r.fsf@xemacs.org and the associated
  ;; thread; Hrvoje was correct, I was wrong.
;  (foo 'Scaron     #x26)
;  (foo 'scaron     #x28)
;  (foo 'Zcaron     #x34)
;  (foo 'zcaron     #x38)
  (foo 'OE         #x3C)
  (foo 'oe         #x3D)
  (foo 'Ydiaeresis #x3E))

(provide 'latin-euro-latin9)

;;; end of latin-euro-latin9.el