aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2000-09-11 23:42:27 +0000
committerKenichi Handa2000-09-11 23:42:27 +0000
commit362a80657011980202fb4a0fac516d1724e309da (patch)
tree13b27455985a72b993b5e5f7c1ba9a148b01e6e0
parent1ad24be198aed89e3873c0a72ce2e6e27f9cdb17 (diff)
downloademacs-362a80657011980202fb4a0fac516d1724e309da.tar.gz
emacs-362a80657011980202fb4a0fac516d1724e309da.zip
(quail-translation-docstring): New variable.
(quail-show-keyboard-layout): Docstring modified. (quail-select-current): Likewise. (quail-build-decode-map): Change arg MAP to MAP-LIST to avoid infinite recursive call. (quail-help): Check quail-translation-docstring. Format of the output changed. (quail-help-insert-keymap-description): Adjusted for the above change.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/international/quail.el191
2 files changed, 138 insertions, 58 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8567f69be40..8e2a45e2676 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12000-09-12 Kenichi Handa <handa@etl.go.jp> 12000-09-12 Kenichi Handa <handa@etl.go.jp>
2 2
3 * international/titdic-cnv.el (quail-cxterm-package-ext-info): Add
4 extra docstrings for "chinese-ccdospy", "chinese-ecdict",
5 "chinese-etzy", "chinese-sw", and "chinese-ziranma". Modify the
6 docstring of "chinese-py".
7
3 * international/quail.el (quail-translation-docstring): New 8 * international/quail.el (quail-translation-docstring): New
4 variable. 9 variable.
5 (quail-show-keyboard-layout): Docstring modified. 10 (quail-show-keyboard-layout): Docstring modified.
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index 8fb637931ad..7352e002abd 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -272,13 +272,34 @@ Only a few especially complex input methods use this map;
272most use `quail-simple-translation-keymap' instead. 272most use `quail-simple-translation-keymap' instead.
273This map is activated while translation region is active.") 273This map is activated while translation region is active.")
274 274
275;; Hide some verbose commands to make the output of quail-help 275(defvar quail-translation-docstring
276;; concise. 276 "When you type keys, the echo area shows the possible characters
277(let ((l '(quail-other-command 277which correspond to that key sequence, each preceded by a digit. You
278 quail-self-insert-command 278can select one of the characters shown by typing the corresponding
279 quail-delete-last-char))) 279digit. Alternatively, you can use C-f and C-b to move through the
280line to select the character you want, then type a letter to begin
281entering another Chinese character or type a space or punctuation
282character.
283
284If there are more than ten possible characters for the given spelling,
285the echo area shows ten characters at a time; you can use C-n to move
286to the next group of ten, and C-p to move back to the previous group
287of ten.")
288
289;; Categorize each Quail commands to make the output of quail-help
290;; concise. This is done by putting `quail-help' property. The value
291;; is:
292;; hide -- never show this command
293;; non-deterministic -- show only for non-deterministic input method
294(let ((l '((quail-other-command . hide)
295 (quail-self-insert-command . hide)
296 (quail-delete-last-char . hide)
297 (quail-next-translation . non-deterministic)
298 (quail-prev-translation . non-deterministic)
299 (quail-next-translation-block . non-deterministic)
300 (quail-prev-translation-block . non-deterministic))))
280 (while l 301 (while l
281 (put (car l) 'quail-help-hide t) 302 (put (car (car l)) 'quail-help (cdr (car l)))
282 (setq l (cdr l)))) 303 (setq l (cdr l))))
283 304
284(defvar quail-simple-translation-keymap 305(defvar quail-simple-translation-keymap
@@ -358,7 +379,12 @@ If it is an alist, the element has the form (CHAR . STRING). Each character
358 shown. 379 shown.
359If it is nil, the current key is shown. 380If it is nil, the current key is shown.
360 381
361DOCSTRING is the documentation string of this package. 382DOCSTRING is the documentation string of this package. The command
383`describe-input-method' shows this string while replacing the form
384\\<VAR> in the string by the value of VAR. That value should be a
385string. For instance, the form \\<quail-translation-docstring> is
386replaced by a description about how to select a translation from a
387list of candidates.
362 388
363TRANSLATION-KEYS specifies additional key bindings used while translation 389TRANSLATION-KEYS specifies additional key bindings used while translation
364region is active. It is an alist of single key character vs. corresponding 390region is active. It is an alist of single key character vs. corresponding
@@ -815,7 +841,10 @@ you type is correctly handled."
815 841
816;;;###autoload 842;;;###autoload
817(defun quail-show-keyboard-layout (&optional keyboard-type) 843(defun quail-show-keyboard-layout (&optional keyboard-type)
818 "Show keyboard layout." 844 "Show the physical layout of the keyboard type KEYBOARD-TYPE.
845
846The variable `quail-keyboard-layout-type' holds the currently selected
847keyboard type."
819 (interactive 848 (interactive
820 (list (completing-read "Keyboard type (default, current choise): " 849 (list (completing-read "Keyboard type (default, current choise): "
821 quail-keyboard-layout-alist 850 quail-keyboard-layout-alist
@@ -1411,7 +1440,7 @@ The returned value is a Quail map specific to KEY."
1411 (erase-buffer)))) 1440 (erase-buffer))))
1412 1441
1413(defun quail-select-current () 1442(defun quail-select-current ()
1414 "Select the current text shown in Quail translation region." 1443 "Accept the currently selected translation."
1415 (interactive) 1444 (interactive)
1416 (quail-terminate-translation)) 1445 (quail-terminate-translation))
1417 1446
@@ -2194,10 +2223,22 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2194 (select-window (active-minibuffer-window)) 2223 (select-window (active-minibuffer-window))
2195 (exit-minibuffer)))))) 2224 (exit-minibuffer))))))
2196 2225
2197(defun quail-build-decode-map (map key decode-map num &optional maxnum ignores) 2226;; Accumulate in the cdr part of DECODE-MAP all pairs of key sequences
2198 (let ((translation (quail-get-translation (car map) key (length key))) 2227;; vs the corresponding translations defined in the Quail map
2199 elt) 2228;; specified by the first element MAP-LIST. Each pair has the form
2229;; (KEYSEQ . TRANSLATION). DECODE-MAP should have the form
2230;; (decode-map . ALIST), where ALIST is an alist of length NUM. KEY
2231;; is a key sequence to reach MAP.
2232;; Optional 5th arg MAXNUM limits the number of accumulated pairs.
2233;; Optional 6th arg IGNORES is a list of translations to ignore.
2234
2235(defun quail-build-decode-map (map-list key decode-map num
2236 &optional maxnum ignores)
2237 (let* ((map (car map-list))
2238 (translation (quail-get-translation (car map) key (length key)))
2239 elt)
2200 (cond ((integerp translation) 2240 (cond ((integerp translation)
2241 ;; Accept only non-ASCII chars not listed in IGNORES.
2201 (when (and (> translation 255) (not (memq translation ignores))) 2242 (when (and (> translation 255) (not (memq translation ignores)))
2202 (setcdr decode-map 2243 (setcdr decode-map
2203 (cons (cons key translation) (cdr decode-map))) 2244 (cons (cons key translation) (cdr decode-map)))
@@ -2206,6 +2247,8 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2206 (setq translation (cdr translation)) 2247 (setq translation (cdr translation))
2207 (let ((multibyte nil)) 2248 (let ((multibyte nil))
2208 (mapc (function (lambda (x) 2249 (mapc (function (lambda (x)
2250 ;; Accept only non-ASCII chars not
2251 ;; listed in IGNORES.
2209 (if (and (if (integerp x) (> x 255) 2252 (if (and (if (integerp x) (> x 255)
2210 (> (string-bytes x) (length x))) 2253 (> (string-bytes x) (length x)))
2211 (not (member x ignores))) 2254 (not (member x ignores)))
@@ -2218,14 +2261,20 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2218 (if (and maxnum (> num maxnum)) 2261 (if (and maxnum (> num maxnum))
2219 (- num) 2262 (- num)
2220 (setq map (cdr map)) 2263 (setq map (cdr map))
2264 ;; Recursively check the deeper map.
2221 (while (and map (>= num 0)) 2265 (while (and map (>= num 0))
2222 (setq elt (car map) map (cdr map)) 2266 (setq elt (car map) map (cdr map))
2223 (when (and (integerp (car elt)) (consp (cdr elt))) 2267 (when (and (integerp (car elt)) (consp (cdr elt))
2224 (setq num (quail-build-decode-map (cdr elt) 2268 (not (memq (cdr elt) map-list)))
2269 (setq num (quail-build-decode-map (cons (cdr elt) map-list)
2225 (format "%s%c" key (car elt)) 2270 (format "%s%c" key (car elt))
2226 decode-map num maxnum ignores)))) 2271 decode-map num maxnum ignores))))
2227 num))) 2272 num)))
2228 2273
2274;; Insert the pairs of key sequences vs the corresponding translations
2275;; stored in DECODE-MAP by the concise format. DECODE-MAP should be
2276;; made by `quail-build-decode-map' (which see).
2277
2229(defun quail-insert-decode-map (decode-map) 2278(defun quail-insert-decode-map (decode-map)
2230 (setq decode-map 2279 (setq decode-map
2231 (sort (cdr decode-map) 2280 (sort (cdr decode-map)
@@ -2235,38 +2284,40 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2235 (and (= (length x) (length y)) 2284 (and (= (length x) (length y))
2236 (not (string< x y)))))))) 2285 (not (string< x y))))))))
2237 (let ((frame-width (frame-width)) 2286 (let ((frame-width (frame-width))
2238 (short-key-width 3) 2287 (single-key-width 3)
2239 (short-trans-width 4) 2288 (single-trans-width 4)
2240 (long-key-width 3) 2289 (multiple-key-width 3)
2241 (short-list nil) 2290 (single-list nil)
2242 (long-list nil) 2291 (multiple-list nil)
2243 elt trans width pos cols rows col row str col-width) 2292 elt trans width pos cols rows col row str col-width)
2244 ;; Divide the decoding map into shorter one and longer one. 2293 ;; Divide the elements of decoding map into single ones (i.e. the
2294 ;; one that has single translation) and multibyte ones (i.e. the
2295 ;; one that has multiple translations).
2245 (while decode-map 2296 (while decode-map
2246 (setq elt (car decode-map) decode-map (cdr decode-map) 2297 (setq elt (car decode-map) decode-map (cdr decode-map)
2247 trans (cdr elt)) 2298 trans (cdr elt))
2248 (if (and (vectorp trans) (= (length trans) 1)) 2299 (if (and (vectorp trans) (= (length trans) 1))
2249 (setq trans (aref trans 0))) 2300 (setq trans (aref trans 0)))
2250 (if (vectorp trans) 2301 (if (vectorp trans)
2251 (setq long-list (cons elt long-list)) 2302 (setq multiple-list (cons elt multiple-list))
2252 (setq short-list (cons (cons (car elt) trans) short-list) 2303 (setq single-list (cons (cons (car elt) trans) single-list)
2253 width (if (stringp trans) (string-width trans) 2304 width (if (stringp trans) (string-width trans)
2254 (char-width trans))) 2305 (char-width trans)))
2255 (if (> width short-trans-width) 2306 (if (> width single-trans-width)
2256 (setq short-trans-width width))) 2307 (setq single-trans-width width)))
2257 (setq width (length (car elt))) 2308 (setq width (length (car elt)))
2258 (if (> width short-key-width) 2309 (if (> width single-key-width)
2259 (setq short-key-width width)) 2310 (setq single-key-width width))
2260 (if (> width long-key-width) 2311 (if (> width multiple-key-width)
2261 (setq long-key-width width))) 2312 (setq multiple-key-width width)))
2262 (when short-list 2313 (when single-list
2263 (setq col-width (+ short-key-width 1 short-trans-width 1) 2314 (setq col-width (+ single-key-width 1 single-trans-width 1)
2264 cols (/ frame-width col-width) 2315 cols (/ frame-width col-width)
2265 rows (/ (length short-list) cols)) 2316 rows (/ (length single-list) cols))
2266 (if (> (% (length short-list) cols) 0) 2317 (if (> (% (length single-list) cols) 0)
2267 (setq rows (1+ rows))) 2318 (setq rows (1+ rows)))
2268 (insert "key") 2319 (insert "key")
2269 (indent-to (1+ short-key-width)) 2320 (indent-to (1+ single-key-width))
2270 (insert "char") 2321 (insert "char")
2271 (indent-to (1+ col-width)) 2322 (indent-to (1+ col-width))
2272 (insert "[type a key sequence to insert the corresponding character]\n") 2323 (insert "[type a key sequence to insert the corresponding character]\n")
@@ -2274,34 +2325,34 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2274 (insert-char ?\n (+ rows 2)) 2325 (insert-char ?\n (+ rows 2))
2275 (goto-char pos) 2326 (goto-char pos)
2276 (setq col (- col-width) row 0) 2327 (setq col (- col-width) row 0)
2277 (while short-list 2328 (while single-list
2278 (setq elt (car short-list) short-list (cdr short-list)) 2329 (setq elt (car single-list) single-list (cdr single-list))
2279 (when (= (% row rows) 0) 2330 (when (= (% row rows) 0)
2280 (goto-char pos) 2331 (goto-char pos)
2281 (setq col (+ col col-width)) 2332 (setq col (+ col col-width))
2282 (move-to-column col t) 2333 (move-to-column col t)
2283 (insert-char ?- short-key-width) 2334 (insert-char ?- single-key-width)
2284 (insert ? ) 2335 (insert ? )
2285 (insert-char ?- short-trans-width) 2336 (insert-char ?- single-trans-width)
2286 (forward-line 1)) 2337 (forward-line 1))
2287 (move-to-column col t) 2338 (move-to-column col t)
2288 (insert (car elt)) 2339 (insert (car elt))
2289 (indent-to (+ col short-key-width 1)) 2340 (indent-to (+ col single-key-width 1))
2290 (insert (cdr elt)) 2341 (insert (cdr elt))
2291 (forward-line 1) 2342 (forward-line 1)
2292 (setq row (1+ row))) 2343 (setq row (1+ row)))
2293 (goto-char (point-max))) 2344 (goto-char (point-max)))
2294 2345
2295 (when long-list 2346 (when multiple-list
2296 (insert "key") 2347 (insert "key")
2297 (indent-to (1+ long-key-width)) 2348 (indent-to (1+ multiple-key-width))
2298 (insert "character(s) [type a key (sequence) and select one from the list]\n") 2349 (insert "character(s) [type a key (sequence) and select one from the list]\n")
2299 (insert-char ?- long-key-width) 2350 (insert-char ?- multiple-key-width)
2300 (insert " ------------\n") 2351 (insert " ------------\n")
2301 (while long-list 2352 (while multiple-list
2302 (setq elt (car long-list) long-list (cdr long-list)) 2353 (setq elt (car multiple-list) multiple-list (cdr multiple-list))
2303 (insert (car elt)) 2354 (insert (car elt))
2304 (indent-to long-key-width) 2355 (indent-to multiple-key-width)
2305 (if (vectorp (cdr elt)) 2356 (if (vectorp (cdr elt))
2306 (mapc (function 2357 (mapc (function
2307 (lambda (x) 2358 (lambda (x)
@@ -2309,7 +2360,7 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2309 (string-width x)))) 2360 (string-width x))))
2310 (when (> (+ (current-column) 1 width) frame-width) 2361 (when (> (+ (current-column) 1 width) frame-width)
2311 (insert "\n") 2362 (insert "\n")
2312 (indent-to long-key-width)) 2363 (indent-to multiple-key-width))
2313 (insert " " x)))) 2364 (insert " " x))))
2314 (cdr elt)) 2365 (cdr elt))
2315 (insert " " (cdr elt))) 2366 (insert " " (cdr elt)))
@@ -2318,7 +2369,8 @@ are shown (at most to the depth specified `quail-completion-max-depth')."
2318 2369
2319(defun quail-help (&optional package) 2370(defun quail-help (&optional package)
2320 "Show brief description of the current Quail package. 2371 "Show brief description of the current Quail package.
2321Optional 2nd arg PACKAGE specifies the alternative Quail package to describe." 2372Optional 2nd arg PACKAGE specifies the name of alternative Quail
2373package to describe."
2322 (interactive) 2374 (interactive)
2323 (if package 2375 (if package
2324 (setq package (assoc package quail-package-alist)) 2376 (setq package (assoc package quail-package-alist))
@@ -2331,8 +2383,20 @@ Optional 2nd arg PACKAGE specifies the alternative Quail package to describe."
2331 (insert "Input method: " (quail-name) 2383 (insert "Input method: " (quail-name)
2332 " (mode line indicator:" 2384 " (mode line indicator:"
2333 (quail-title) 2385 (quail-title)
2334 ")\n\n" 2386 ")\n\n")
2335 (quail-docstring)) 2387 (save-restriction
2388 (narrow-to-region (point) (point))
2389 (insert (quail-docstring))
2390 (goto-char (point-min))
2391 (with-syntax-table emacs-lisp-mode-syntax-table
2392 (while (re-search-forward "\\\\<\\sw\\(\\sw\\|\\s_\\)+>" nil t)
2393 (let ((sym (intern-soft
2394 (buffer-substring (+ (match-beginning 0) 2)
2395 (1- (point))))))
2396 (if (and (boundp sym)
2397 (stringp (symbol-value sym)))
2398 (replace-match (symbol-value sym) t t)))))
2399 (goto-char (point-max)))
2336 (or (bolp) 2400 (or (bolp)
2337 (insert "\n")) 2401 (insert "\n"))
2338 (insert "\n") 2402 (insert "\n")
@@ -2340,8 +2404,10 @@ Optional 2nd arg PACKAGE specifies the alternative Quail package to describe."
2340 (let ((done-list nil)) 2404 (let ((done-list nil))
2341 ;; Show keyboard layout if the current package requests it.. 2405 ;; Show keyboard layout if the current package requests it..
2342 (when (quail-show-layout) 2406 (when (quail-show-layout)
2343 (insert 2407 (insert "
2344"Physical key layout for this input method is as below. 2408KEYBOARD LAYOUT
2409---------------
2410Physical key layout for this input method is as below.
2345You can input a character in the table by typing a key 2411You can input a character in the table by typing a key
2346at the same location on your keyboard.\n") 2412at the same location on your keyboard.\n")
2347 (setq done-list 2413 (setq done-list
@@ -2364,10 +2430,13 @@ adjust the variable `quail-keyboard-layout-type' ")
2364 ;; Show key sequences. 2430 ;; Show key sequences.
2365 (let ((decode-map (list 'decode-map)) 2431 (let ((decode-map (list 'decode-map))
2366 elt pos num) 2432 elt pos num)
2367 (setq num (quail-build-decode-map (quail-map) "" decode-map 2433 (setq num (quail-build-decode-map (list (quail-map)) "" decode-map
2368 0 512 done-list)) 2434 0 512 done-list))
2369 (when (> num 0) 2435 (when (> num 0)
2370 (insert ?\n) 2436 (insert "
2437KEY SEQUENCE
2438-----------
2439")
2371 (if (quail-show-layout) 2440 (if (quail-show-layout)
2372 (insert "You can also input more characters") 2441 (insert "You can also input more characters")
2373 (insert "You can input characters")) 2442 (insert "You can input characters"))
@@ -2376,12 +2445,16 @@ adjust the variable `quail-keyboard-layout-type' ")
2376 2445
2377 (quail-help-insert-keymap-description 2446 (quail-help-insert-keymap-description
2378 (quail-translation-keymap) 2447 (quail-translation-keymap)
2379 "--- key bindings for selecting a character ---\n") 2448 "\
2449KEY BINDINGS FOR TRANSLATION
2450----------------------------\n")
2380 (insert ?\n) 2451 (insert ?\n)
2381 (if (quail-conversion-keymap) 2452 (if (quail-conversion-keymap)
2382 (quail-help-insert-keymap-description 2453 (quail-help-insert-keymap-description
2383 (quail-conversion-keymap) 2454 (quail-conversion-keymap)
2384 "--- Key bindings for converting a character (sequence) ---\n")) 2455 "\
2456KEY BINDINGS FOR CONVERSION
2457---------------------------\n"))
2385 (help-setup-xref (list #'quail-help (quail-name)) 2458 (help-setup-xref (list #'quail-help (quail-name))
2386 (interactive-p)) 2459 (interactive-p))
2387 (setq quail-current-package nil))))) 2460 (setq quail-current-package nil)))))
@@ -2391,9 +2464,9 @@ adjust the variable `quail-keyboard-layout-type' ")
2391 (setq pos1 (point)) 2464 (setq pos1 (point))
2392 (if header 2465 (if header
2393 (insert header)) 2466 (insert header))
2394 (insert (substitute-command-keys "\\{keymap}")) 2467 (save-excursion
2395 (goto-char pos1) 2468 (insert (substitute-command-keys "\\{keymap}")))
2396 ;; Skip headers "--- key bindings ---", etc. 2469 ;; Skip headers "key bindings", etc.
2397 (forward-line 3) 2470 (forward-line 3)
2398 (setq pos2 (point)) 2471 (setq pos2 (point))
2399 (with-syntax-table emacs-lisp-mode-syntax-table 2472 (with-syntax-table emacs-lisp-mode-syntax-table
@@ -2401,7 +2474,9 @@ adjust the variable `quail-keyboard-layout-type' ")
2401 (let ((sym (intern-soft (buffer-substring (match-beginning 0) 2474 (let ((sym (intern-soft (buffer-substring (match-beginning 0)
2402 (point))))) 2475 (point)))))
2403 (if (and sym (fboundp sym) 2476 (if (and sym (fboundp sym)
2404 (get sym 'quail-help-hide)) 2477 (or (eq (get sym 'quail-help) 'hide)
2478 (and (quail-deterministic)
2479 (eq (get sym 'quail-help) 'non-deterministic))))
2405 (delete-region (line-beginning-position) 2480 (delete-region (line-beginning-position)
2406 (1+ (line-end-position))))))) 2481 (1+ (line-end-position)))))))
2407 (goto-char pos2) 2482 (goto-char pos2)