aboutsummaryrefslogtreecommitdiffstats
path: root/leim
diff options
context:
space:
mode:
authorKenichi Handa2008-06-05 07:23:16 +0000
committerKenichi Handa2008-06-05 07:23:16 +0000
commitebba3e08ee615c47ee58efa3313a70bb12131dad (patch)
treeacaec9a4c2df5e9377e186f7b3b85195b8b7c895 /leim
parentb1d6cda3015a32ad5787f941e80ff45d2224d4c6 (diff)
downloademacs-ebba3e08ee615c47ee58efa3313a70bb12131dad.tar.gz
emacs-ebba3e08ee615c47ee58efa3313a70bb12131dad.zip
Docstrings and comments improved.
Diffstat (limited to 'leim')
-rw-r--r--leim/quail/hangul.el117
1 files changed, 70 insertions, 47 deletions
diff --git a/leim/quail/hangul.el b/leim/quail/hangul.el
index 1792fad3bb1..b9aba3dad49 100644
--- a/leim/quail/hangul.el
+++ b/leim/quail/hangul.el
@@ -32,32 +32,43 @@
32(require 'hanja-util) 32(require 'hanja-util)
33 33
34;; Hangul double jamo table. 34;; Hangul double jamo table.
35;; NEED COMMENT. What is the car and cdr part? 35;; The format is an alist of JAMO-TYPE vs. DOUBLE-JAMO-TABLE.
36;;
37;; JAMO-TYPE is a symbol `cho' for Choseong, `jung' for Jungseong, and
38;; `jong' for Jongseong.
39;;
40;; DOUBLE-JAMO-TABLE is an alist of jamo index vs. the vector of jamo
41;; indies that can be combined with the car part.
42;;
43;; Jamo index is a relative index in `hangul Compatibility Jamo' area
44;; of the Unicode (i.e. 1 for U+3131).
45
36(defconst hangul-djamo-table 46(defconst hangul-djamo-table
37 '((cho . ((1 . [1]) 47 '((cho . ((1 . [1]) ; Choseong
38 (7 . [7]) 48 (7 . [7])
39 (18 . [18]) 49 (18 . [18])
40 (21 . [21]) 50 (21 . [21])
41 (24 . [24]))) 51 (24 . [24])))
42 (jung . ((39 . [31 32 51]) 52 (jung . ((39 . [31 32 51]) ; Jungseong
43 (44 . [35 36 51]) 53 (44 . [35 36 51])
44 (49 . [51]))) 54 (49 . [51])))
45 (jong . ((1 . [1 21]) 55 (jong . ((1 . [1 21]) ; Jongseong
46 (4 . [24 30]) 56 (4 . [24 30])
47 (9 . [1 17 18 21 28 29 30]) 57 (9 . [1 17 18 21 28 29 30])
48 (18 . [18 21]) 58 (18 . [18 21])
49 (21 . [21]))))) 59 (21 . [21])))))
50 60
51;; Hangul 2-Bulsik keymap. 61;; Hangul 2-Bulsik keymap.
52;; This table has Hangul Jamo index. 62;; It converts an ASCII code A-Z, a-z, to the corresponding hangul
53;; NEED COMMENT. What is "Hangul Jamo index"? 63;; jamo index.
64
54(defconst hangul2-keymap 65(defconst hangul2-keymap
55 [17 48 26 23 7 9 30 39 33 35 31 51 49 44 32 36 18 1 4 21 37 29 24 28 43 27]) 66 [17 48 26 23 7 9 30 39 33 35 31 51 49 44 32 36 18 1 4 21 37 29 24 28 43 27])
56 67
57;; Hangul 3-Bulsik final keymap. 3-Bulsik use full keyboard layout. 68;; Hangul 3-Bulsik final keymap. 3-Bulsik use full keyboard layout.
58;; Therefore, We must assign all ASCII codes except control codes 69;; Therefore, we must map all printable ASCII codes (`!' to `~')
59;; to Hangul 3-Bulsik codes. 70;; to Hangul 3-Bulsik codes.
60;; NEED COMMENT. What are these numbers? 71;; Other parts are the same as `hangul2-keymap'.
61(defconst hangul3-keymap 72(defconst hangul3-keymap
62 [2 183 24 15 14 8220 120 39 126 8221 43 44 41 46 74 119 30 22 18 78 83 73 [2 183 24 15 14 8220 120 39 126 8221 43 44 41 46 74 119 30 22 18 78 83
63 68 73 85 79 52 110 44 62 46 33 10 7 63 27 12 5 11 69 48 55 49 50 51 74 68 73 85 79 52 110 44 62 46 33 10 7 63 27 12 5 11 69 48 55 49 50 51
@@ -66,7 +77,7 @@
66 101 17 37 92 47 8251]) 77 101 17 37 92 47 8251])
67 78
68;; Hangul 3-Bulsik 390 keymap. 79;; Hangul 3-Bulsik 390 keymap.
69;; NEED COMMENT. What are these numbers? 80;; The role is the same as `hangul3-keymap'.
70(defconst hangul390-keymap 81(defconst hangul390-keymap
71 [24 34 35 36 37 38 120 40 41 42 43 44 45 46 73 119 30 22 18 77 82 67 72 82 [24 34 35 36 37 38 120 40 41 42 43 44 45 46 73 119 30 22 18 77 82 67 72
72 84 78 58 110 50 61 51 63 64 7 33 11 10 27 2 47 39 56 52 53 54 49 48 83 84 78 58 110 50 61 51 63 64 7 33 11 10 27 2 47 39 56 52 53 54 49 48
@@ -79,7 +90,7 @@
79 (define-key map "\d" 'hangul-delete-backward-char) 90 (define-key map "\d" 'hangul-delete-backward-char)
80 (define-key map [f9] 'hangul-to-hanja-conversion) 91 (define-key map [f9] 'hangul-to-hanja-conversion)
81 map) 92 map)
82 "Keymap for Hangul method. It is using all Hangul input method.") 93 "Keymap for Hangul method. It is used by all Hangul input method.")
83 94
84;; Current input character buffer. Store separated hangul character. 95;; Current input character buffer. Store separated hangul character.
85;; First and second index of vector stored "Choseong". 96;; First and second index of vector stored "Choseong".
@@ -96,10 +107,9 @@
96 (and (>= char ?a) (<= char ?z)))) 107 (and (>= char ?a) (<= char ?z))))
97 108
98(defun hangul-character (cho jung jong) 109(defun hangul-character (cho jung jong)
99 "Choseong, Jungseong, and Jongseong which are contained Hangul Compatibility Jamo area 110 "Convert CHO, JUNG, JONG to the precomposed `Hangul Syllables' character.
100are transformed hangul character in Hangul Syllables area." 111CHO, JUNG, JONG are relative indices in `Hangul Compatibility Jamo' of unicode.
101 ;; NEED ADJUSTMENT. Please read the section "Documentation Basics" 112Return a zero-length string if the conversion fails."
102 ;; of elisp info.
103 (or 113 (or
104 (decode-char 114 (decode-char
105 'ucs 115 'ucs
@@ -125,7 +135,9 @@ are transformed hangul character in Hangul Syllables area."
125 "")) 135 ""))
126 136
127(defun hangul-insert-character (&rest queues) 137(defun hangul-insert-character (&rest queues)
128 "Insert each QUEUES. Then setup overlay last inserted character." 138 "Insert characters generated from QUEUEs.
139Each QUEUE has the same form as `hangul-queue'.
140Setup `quail-overlay' to the last character."
129 (if (and mark-active transient-mark-mode) 141 (if (and mark-active transient-mark-mode)
130 (progn 142 (progn
131 (delete-region (region-beginning) (region-end)) 143 (delete-region (region-beginning) (region-end))
@@ -147,10 +159,10 @@ are transformed hangul character in Hangul Syllables area."
147 (move-overlay quail-overlay (1+ (overlay-start quail-overlay)) (point)))) 159 (move-overlay quail-overlay (1+ (overlay-start quail-overlay)) (point))))
148 160
149(defun hangul-djamo (jamo char1 char2) 161(defun hangul-djamo (jamo char1 char2)
150 "If CHAR1 and CHAR2 are able to combine, 162 "Return the dobule jamo index calculated from the arguments.
151this function returns double jamo index." 163JAMO is a type of Hangul jamo; `cho', `jung', or `jong'.
152 ;; NEED ADJUSTMENT. Please read the section "Documentation Basics" 164CHAR1 and CAHR2 are Hangul jamo indices.
153 ;; of elisp info. 165Return nil if CHAR1 and CHAR2 can not combined."
154 (let* ((jamo (cdr (assoc jamo hangul-djamo-table))) 166 (let* ((jamo (cdr (assoc jamo hangul-djamo-table)))
155 (char1 (cdr (assoc char1 jamo)))) 167 (char1 (cdr (assoc char1 jamo))))
156 (if char1 168 (if char1
@@ -163,13 +175,13 @@ this function returns double jamo index."
163 0)) 175 0))
164 0))) 176 0)))
165 177
166;; NEED ADJUSTMENT. The following 5 have exactly the same docstring.
167;; How are they different?
168
169(defsubst hangul2-input-method-jaum (char) 178(defsubst hangul2-input-method-jaum (char)
170 "CHAR is putted in hangul-queue. 179 "Store hangul jamo indice CHAR in `hangul-queue'.
171Unless the function insert CHAR to current input queue, 180Maybe, it is a Hangul 2-Bulsik jaum.
172commit current character and then start next character." 181This function processes a Hangul 2-Bulsik jaum.
182Unless the function inserts CHAR to current input queue,
183commit current character and then start next character.
184The Hangul 2-Bulsik is composed of `jaum' and `moum'."
173 (if (cond ((zerop (aref hangul-queue 0)) 185 (if (cond ((zerop (aref hangul-queue 0))
174 (aset hangul-queue 0 char)) 186 (aset hangul-queue 0 char))
175 ((and (zerop (aref hangul-queue 1)) 187 ((and (zerop (aref hangul-queue 1))
@@ -220,9 +232,10 @@ commit current character and then start next character."
220 (setq hangul-queue (vector char 0 0 0 0 0))))) 232 (setq hangul-queue (vector char 0 0 0 0 0)))))
221 233
222(defsubst hangul2-input-method-moum (char) 234(defsubst hangul2-input-method-moum (char)
223 "CHAR is putted in hangul-queue. 235 "Store hangul jamo indice CHAR in `hangul-queue'.
224Unless the function insert CHAR to current input queue, 236Maybe, it is a Hangul 2-Bulsik moum.
225commit current character and then start next character." 237This function process a Hangul 2-Bulsik moum.
238Other parts are the same as a `hangul2-input-method-jaum'."
226 (if (cond ((zerop (aref hangul-queue 2)) 239 (if (cond ((zerop (aref hangul-queue 2))
227 (aset hangul-queue 2 char)) 240 (aset hangul-queue 2 char))
228 ((and (zerop (aref hangul-queue 3)) 241 ((and (zerop (aref hangul-queue 3))
@@ -241,9 +254,11 @@ commit current character and then start next character."
241 (setq hangul-queue next-char))))) 254 (setq hangul-queue next-char)))))
242 255
243(defsubst hangul3-input-method-cho (char) 256(defsubst hangul3-input-method-cho (char)
244 "CHAR is putted in hangul-queue. 257 "Store hangul jamo indice CHAR in `hangul-queue'.
245Unless the function insert CHAR to current input queue, 258Maybe, it is a Hangul 3-Bulsik choseong.
246commit current character and then start next character." 259This function process a Hangul 3-Bulsik choseong.
260The Hangul 3-Bulsik is composed of `choseong', `jungseong' and `jongseong'.
261Other parts are the same as a `hangul2-input-method-jaum'."
247 (if (cond ((and (zerop (aref hangul-queue 0)) 262 (if (cond ((and (zerop (aref hangul-queue 0))
248 (zerop (aref hangul-queue 4))) 263 (zerop (aref hangul-queue 4)))
249 (aset hangul-queue 0 char)) 264 (aset hangul-queue 0 char))
@@ -256,9 +271,10 @@ commit current character and then start next character."
256 (setq hangul-queue (vector char 0 0 0 0 0))))) 271 (setq hangul-queue (vector char 0 0 0 0 0)))))
257 272
258(defsubst hangul3-input-method-jung (char) 273(defsubst hangul3-input-method-jung (char)
259 "CHAR is putted in hangul-queue. 274 "Store hangul jamo indice CHAR in `hangul-queue'.
260Unless the function insert CHAR to current input queue, 275Maybe, it is a Hangul 3-Bulsik jungseong.
261commit current character and then start next character." 276This function process a Hangul 3-Bulsik jungseong.
277Other parts are the same as a `hangul3-input-method-cho'."
262 (if (cond ((and (zerop (aref hangul-queue 2)) 278 (if (cond ((and (zerop (aref hangul-queue 2))
263 (zerop (aref hangul-queue 4))) 279 (zerop (aref hangul-queue 4)))
264 (aset hangul-queue 2 char)) 280 (aset hangul-queue 2 char))
@@ -270,9 +286,10 @@ commit current character and then start next character."
270 (setq hangul-queue (vector 0 0 char 0 0 0))))) 286 (setq hangul-queue (vector 0 0 char 0 0 0)))))
271 287
272(defsubst hangul3-input-method-jong (char) 288(defsubst hangul3-input-method-jong (char)
273 "CHAR is putted in hangul-queue. 289 "Store hangul jamo indice CHAR in `hangul-queue'.
274Unless the function insert CHAR to current input queue, 290Maybe, it is a Hangul 3-Bulsik jongseong.
275commit current character and then start next character." 291This function process a Hangul 3-Bulsik jongseong.
292Other parts are the same as a `hangul3-input-method-cho'."
276 (if (cond ((and (zerop (aref hangul-queue 4)) 293 (if (cond ((and (zerop (aref hangul-queue 4))
277 (notzerop (aref hangul-queue 0)) 294 (notzerop (aref hangul-queue 0))
278 (notzerop (aref hangul-queue 2)) 295 (notzerop (aref hangul-queue 2))
@@ -317,7 +334,7 @@ commit current character and then start next character."
317 (setq hangul-queue (vector 0 0 0 0 char 0)))))) 334 (setq hangul-queue (vector 0 0 0 0 char 0))))))
318 335
319(defun hangul-delete-backward-char () 336(defun hangul-delete-backward-char ()
320 "Backward delete command for hangul. It deletes a hangul character by jaso units." 337 "Delete the previous hangul character by jaso units."
321 (interactive) 338 (interactive)
322 (let ((i 5)) 339 (let ((i 5))
323 (while (and (> i 0) (zerop (aref hangul-queue i))) 340 (while (and (> i 0) (zerop (aref hangul-queue i)))
@@ -328,7 +345,7 @@ commit current character and then start next character."
328 (delete-backward-char 1))) 345 (delete-backward-char 1)))
329 346
330(defun hangul-to-hanja-conversion () 347(defun hangul-to-hanja-conversion ()
331 "This function converts a hangul character to a hanja character." 348 "Convert the previous hangul character to the corresponding hanja character."
332 (interactive) 349 (interactive)
333 (let ((echo-keystrokes 0) 350 (let ((echo-keystrokes 0)
334 delete-func 351 delete-func
@@ -340,7 +357,9 @@ commit current character and then start next character."
340 (setq hangul-queue (make-vector 6 0)) 357 (setq hangul-queue (make-vector 6 0))
341 (move-overlay quail-overlay (point) (point))))) 358 (move-overlay quail-overlay (point) (point)))))
342 359
343;; NEED COMMENT. What is KEY? 360;; Support function for `hangul2-input-method'. Actually, this
361;; function handles the Hangul 2-Bulsik. KEY is an entered key code
362;; used for looking up `hangul2-keymap'."
344(defun hangul2-input-method-internal (key) 363(defun hangul2-input-method-internal (key)
345 (let ((char (+ (aref hangul2-keymap (1- (% key 32))) 364 (let ((char (+ (aref hangul2-keymap (1- (% key 32)))
346 (cond ((or (= key ?O) (= key ?P)) 2) 365 (cond ((or (= key ?O) (= key ?P)) 2)
@@ -352,7 +371,7 @@ commit current character and then start next character."
352 (hangul2-input-method-moum char)))) 371 (hangul2-input-method-moum char))))
353 372
354(defun hangul2-input-method (key) 373(defun hangul2-input-method (key)
355 "2-Bulsik input method" 374 "2-Bulsik input method."
356 (if (or buffer-read-only (not (alphabetp key))) 375 (if (or buffer-read-only (not (alphabetp key)))
357 (list key) 376 (list key)
358 (quail-setup-overlays nil) 377 (quail-setup-overlays nil)
@@ -379,7 +398,9 @@ commit current character and then start next character."
379 (throw 'exit-input-loop nil)))))) 398 (throw 'exit-input-loop nil))))))
380 (quail-delete-overlays))))) 399 (quail-delete-overlays)))))
381 400
382;; NEED COMMENT. What is KEY? 401;; Support function for `hangul3-input-method'. Actually, this
402;; function handles the Hangul 3-Bulsik final. KEY is an entered key
403;; code used for looking up `hangul3-keymap'."
383(defun hangul3-input-method-internal (key) 404(defun hangul3-input-method-internal (key)
384 (let ((char (aref hangul3-keymap (- key 33)))) 405 (let ((char (aref hangul3-keymap (- key 33))))
385 (cond ((and (> char 92) (< char 123)) 406 (cond ((and (> char 92) (< char 123))
@@ -394,7 +415,7 @@ commit current character and then start next character."
394 (move-overlay quail-overlay (point) (point)))))) 415 (move-overlay quail-overlay (point) (point))))))
395 416
396(defun hangul3-input-method (key) 417(defun hangul3-input-method (key)
397 "3-Bulsik final input method" 418 "3-Bulsik final input method."
398 (if (or buffer-read-only (< key 33) (>= key 127)) 419 (if (or buffer-read-only (< key 33) (>= key 127))
399 (list key) 420 (list key)
400 (quail-setup-overlays nil) 421 (quail-setup-overlays nil)
@@ -421,7 +442,9 @@ commit current character and then start next character."
421 (throw 'exit-input-loop nil)))))) 442 (throw 'exit-input-loop nil))))))
422 (quail-delete-overlays))))) 443 (quail-delete-overlays)))))
423 444
424;; NEED COMMENT. What is KEY? 445;; Support function for `hangul390-input-method'. Actually, this
446;; function handles the Hangul 3-Bulsik 390. KEY is an entered key
447;; code used for looking up `hangul390-keymap'."
425(defun hangul390-input-method-internal (key) 448(defun hangul390-input-method-internal (key)
426 (let ((char (aref hangul390-keymap (- key 33)))) 449 (let ((char (aref hangul390-keymap (- key 33))))
427 (cond ((or (and (> char 86) (< char 91)) 450 (cond ((or (and (> char 86) (< char 91))
@@ -437,7 +460,7 @@ commit current character and then start next character."
437 (move-overlay quail-overlay (point) (point)))))) 460 (move-overlay quail-overlay (point) (point))))))
438 461
439(defun hangul390-input-method (key) 462(defun hangul390-input-method (key)
440 "3-Bulsik 390 input method" 463 "3-Bulsik 390 input method."
441 (if (or buffer-read-only (< key 33) (>= key 127)) 464 (if (or buffer-read-only (< key 33) (>= key 127))
442 (list key) 465 (list key)
443 (quail-setup-overlays nil) 466 (quail-setup-overlays nil)
@@ -474,8 +497,8 @@ commit current character and then start next character."
474FUNC is a function to handle input key. 497FUNC is a function to handle input key.
475HELP-TEXT is a text set in `hangul-input-method-help-text'." 498HELP-TEXT is a text set in `hangul-input-method-help-text'."
476 (setq inactivate-current-input-method-function 'hangul-input-method-inactivate 499 (setq inactivate-current-input-method-function 'hangul-input-method-inactivate
477 describe-current-input-method-function 'hangul-input-method-help 500 describe-current-input-method-function 'hangul-input-method-help
478 hangul-input-method-help-text help-text) 501 hangul-input-method-help-text help-text)
479 (quail-delete-overlays) 502 (quail-delete-overlays)
480 (if (eq (selected-window) (minibuffer-window)) 503 (if (eq (selected-window) (minibuffer-window))
481 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) 504 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))