[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: defconst in lao.el
From: |
Kenichi Handa |
Subject: |
Re: defconst in lao.el |
Date: |
Sat, 4 Dec 2004 11:49:36 +0900 (JST) |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) |
Sorry for not responding on this thread long.
In article <address@hidden>, Luc Teirlinck <address@hidden> writes:
> In the case of lao.el however, I believe that using no defconst's at
> all is better, because Handa has indicated that it actually might make
> sense for a user to change `lao-key-alist' in his .emacs, in which
> case defconst could lead to trouble.
I agree.
> On second thought, the concrete code to be executed depends on the
> situation. So I believe that the following comment is better:
> ;; If you change the value of this variable while lao is already loaded,
> ;; you need to re-load it to properly re-initialize related alists.
Ok, I put that sentence in the docstring of lao-key-alist.
On the other hand, lao-consonant-key-alist, and etc. should
be constant. So, I've just installed the attached change.
I introduced a temporary variable lao-key-alist-vector to
initialize lao-consonant-key-alist, etc., and makunbound it
after the initialization (the same method that Dave used in
utf-16.el).
What do you think?
---
Ken'ichi HANDA
address@hidden
2004-12-04 Kenichi Handa <address@hidden>
* quail/lao.el (lao-key-alist): Declare it by defvar.
(lao-key-alist-vector): New variable.
(lao-consonant-key-alist, lao-semivowel-key-alist)
(lao-vowel-key-alist, lao-voweltone-key-alist)
(lao-tone-key-alist, lao-other-key-alist): Initialize them from
lao-key-alist-vector.
Index: lao.el
===================================================================
RCS file: /cvsroot/emacs/emacs/leim/quail/lao.el,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -c -r1.8 -r1.9
cvs diff: conflicting specifications of output style
*** lao.el 1 Sep 2003 15:45:02 -0000 1.8
--- lao.el 4 Dec 2004 02:45:47 -0000 1.9
***************
*** 2,7 ****
--- 2,10 ----
;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
+ ;; Copyright (C) 2004
+ ;; National Institute of Advanced Industrial Science and Technology (AIST)
+ ;; Registration Number H14PRO021
;; Keywords: multilingual, input method, Lao
***************
*** 42,48 ****
(compose-string (quail-lookup-map-and-concat quail-current-key))))
control-flag)
! (defconst lao-key-alist
'(("!" . "1")
("\"" . "=")
("#" . "3")
--- 45,51 ----
(compose-string (quail-lookup-map-and-concat quail-current-key))))
control-flag)
! (defvar lao-key-alist
'(("!" . "1")
("\"" . "=")
("#" . "3")
***************
*** 146,183 ****
("\\7" . "໗")
("\\8" . "໘")
("\\9" . "໙")
! ))
!
! (defconst lao-consonant-key-alist nil)
! (defconst lao-semivowel-key-alist nil)
! (defconst lao-vowel-key-alist nil)
! (defconst lao-voweltone-key-alist nil)
! (defconst lao-tone-key-alist nil)
! (defconst lao-other-key-alist nil)
!
! (let ((tail lao-key-alist)
! elt phonetic-type)
! (while tail
! (setq elt (car tail) tail (cdr tail))
! (if (stringp (cdr elt))
! (setq phonetic-type (get-char-code-property (aref (cdr elt) 0)
'phonetic-type))
! (setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0)
! 'phonetic-type))
! (aset (cdr elt) 0 (compose-string (aref (cdr elt) 0))))
! (cond ((eq phonetic-type 'consonant)
! (setq lao-consonant-key-alist (cons elt lao-consonant-key-alist)))
! ((memq phonetic-type '(vowel-upper vowel-lower))
! (if (stringp (cdr elt))
! (setq lao-vowel-key-alist (cons elt lao-vowel-key-alist))
! (setq lao-voweltone-key-alist
! (cons elt lao-voweltone-key-alist))))
! ((eq phonetic-type 'tone)
! (setq lao-tone-key-alist (cons elt lao-tone-key-alist)))
! ((eq phonetic-type 'semivowel-lower)
! (setq lao-semivowel-key-alist (cons elt lao-semivowel-key-alist)))
! (t
! (setq lao-other-key-alist (cons elt lao-other-key-alist))))))
(quail-define-package
"lao" "Lao" "ລ" t
--- 149,198 ----
("\\7" . "໗")
("\\8" . "໘")
("\\9" . "໙")
! )
! "Alist of key sequences vs the corresponding Lao string to input.
! This variable is for the input method \"lao\".
! If you change the value of this variable while quail/lao is already loaded,
! you need to re-load it to properly re-initialize related alists.")
!
! ;; Temporary variable to initialize lao-consonant-key-alist, etc.
! (defconst lao-key-alist-vector
! (let ((tail lao-key-alist)
! consonant-key-alist semivowel-key-alist vowel-key-alist
! voweltone-key-alist tone-key-alist other-key-alist
! elt phonetic-type)
! (while tail
! (setq elt (car tail) tail (cdr tail))
! (if (stringp (cdr elt))
! (setq phonetic-type (get-char-code-property (aref (cdr elt) 0)
! 'phonetic-type))
! (setq phonetic-type (get-char-code-property (aref (aref (cdr elt) 0) 0)
'phonetic-type))
! (aset (cdr elt) 0 (compose-string (aref (cdr elt) 0))))
! (cond ((eq phonetic-type 'consonant)
! (setq consonant-key-alist (cons elt consonant-key-alist)))
! ((memq phonetic-type '(vowel-upper vowel-lower))
! (if (stringp (cdr elt))
! (setq vowel-key-alist (cons elt vowel-key-alist))
! (setq voweltone-key-alist (cons elt voweltone-key-alist))))
! ((eq phonetic-type 'tone)
! (setq tone-key-alist (cons elt tone-key-alist)))
! ((eq phonetic-type 'semivowel-lower)
! (setq semivowel-key-alist (cons elt semivowel-key-alist)))
! (t
! (setq other-key-alist (cons elt other-key-alist)))))
! (vector consonant-key-alist semivowel-key-alist vowel-key-alist
! voweltone-key-alist tone-key-alist other-key-alist)))
!
! (defconst lao-consonant-key-alist (aref lao-key-alist-vector 0))
! (defconst lao-semivowel-key-alist (aref lao-key-alist-vector 1))
! (defconst lao-vowel-key-alist (aref lao-key-alist-vector 2))
! (defconst lao-voweltone-key-alist (aref lao-key-alist-vector 3))
! (defconst lao-tone-key-alist (aref lao-key-alist-vector 4))
! (defconst lao-other-key-alist (aref lao-key-alist-vector 5))
!
! ;; Done with it.
! (makunbound 'lao-key-alist-vector)
(quail-define-package
"lao" "Lao" "ລ" t
- Re: defconst in lao.el,
Kenichi Handa <=