diff options
| author | Stefan Monnier | 2008-11-24 15:39:43 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-11-24 15:39:43 +0000 |
| commit | 23a01417aa834dc135cec7da0de3e112b8d5b602 (patch) | |
| tree | 207819bbff65788aa81d7afdcc8d43f7bafb92ce | |
| parent | edad5f97011f156f4cd3ee46b4354a883c133a06 (diff) | |
| download | emacs-23a01417aa834dc135cec7da0de3e112b8d5b602.tar.gz emacs-23a01417aa834dc135cec7da0de3e112b8d5b602.zip | |
(quail-vunion): New function.
(quail-defrule-internal): Use it to prevent accumulating redundant
alternatives when `append' is set.
(quail-insert-decode-map): Simplify computation of the max-key-width.
Compute it right for multiple-list.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/international/quail.el | 176 |
2 files changed, 97 insertions, 91 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dca75ba70ba..641c99f9aad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2008-11-24 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * international/quail.el (quail-vunion): New function. | ||
| 4 | (quail-defrule-internal): Use it to prevent accumulating redundant | ||
| 5 | alternatives when `append' is set. | ||
| 6 | (quail-insert-decode-map): Simplify computation of the max-key-width. | ||
| 7 | Compute it right for multiple-list. | ||
| 8 | |||
| 1 | 2008-11-24 Chong Yidong <cyd@stupidchicken.com> | 9 | 2008-11-24 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 10 | ||
| 3 | * emacs-lisp/elp.el (elp-instrument-list): Check argument type | 11 | * emacs-lisp/elp.el (elp-instrument-list): Check argument type |
| @@ -12,8 +20,8 @@ | |||
| 12 | 2008-11-24 Dan Nicolaescu <dann@ics.uci.edu> | 20 | 2008-11-24 Dan Nicolaescu <dann@ics.uci.edu> |
| 13 | 21 | ||
| 14 | * vc-hg.el (vc-hg-global-switches): Remove. | 22 | * vc-hg.el (vc-hg-global-switches): Remove. |
| 15 | (vc-hg-state, vc-hg-working-revision, vc-hg-command): Undo | 23 | (vc-hg-state, vc-hg-working-revision, vc-hg-command): |
| 16 | previous change. | 24 | Undo previous change. |
| 17 | 25 | ||
| 18 | 2008-11-23 Martin Rudalics <rudalics@gmx.at> | 26 | 2008-11-23 Martin Rudalics <rudalics@gmx.at> |
| 19 | 27 | ||
diff --git a/lisp/international/quail.el b/lisp/international/quail.el index 8f48e327f57..5415c394d98 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el | |||
| @@ -1093,6 +1093,10 @@ to the current translations for KEY instead of replacing them." | |||
| 1093 | (setq quail-current-package package))) | 1093 | (setq quail-current-package package))) |
| 1094 | (quail-defrule-internal key translation (quail-map) append)) | 1094 | (quail-defrule-internal key translation (quail-map) append)) |
| 1095 | 1095 | ||
| 1096 | (defun quail-vunion (v1 v2) | ||
| 1097 | (apply 'vector | ||
| 1098 | (nreverse (delete-dups (nconc (append v1 ()) (append v2 ())))))) | ||
| 1099 | |||
| 1096 | ;;;###autoload | 1100 | ;;;###autoload |
| 1097 | (defun quail-defrule-internal (key trans map &optional append decode-map props) | 1101 | (defun quail-defrule-internal (key trans map &optional append decode-map props) |
| 1098 | "Define KEY as TRANS in a Quail map MAP. | 1102 | "Define KEY as TRANS in a Quail map MAP. |
| @@ -1175,17 +1179,20 @@ function `quail-define-rules' for the detail." | |||
| 1175 | (setcdr decode-map | 1179 | (setcdr decode-map |
| 1176 | (cons (cons elt key) (cdr decode-map))))))) | 1180 | (cons (cons elt key) (cdr decode-map))))))) |
| 1177 | (if (and (car map) append) | 1181 | (if (and (car map) append) |
| 1178 | (let ((prev (quail-get-translation (car map) key len))) | 1182 | (let* ((prev (quail-get-translation (car map) key len)) |
| 1179 | (if (integerp prev) | 1183 | (prevchars (if (integerp prev) |
| 1180 | (setq prev (vector prev)) | 1184 | (vector prev) |
| 1181 | (setq prev (cdr prev))) | 1185 | (cdr prev)))) |
| 1182 | (if (integerp trans) | 1186 | (if (integerp trans) |
| 1183 | (setq trans (vector trans)) | 1187 | (setq trans (vector trans)) |
| 1184 | (if (stringp trans) | 1188 | (if (stringp trans) |
| 1185 | (setq trans (string-to-vector trans)))) | 1189 | (setq trans (string-to-vector trans)))) |
| 1190 | (let ((new (quail-vunion prevchars trans))) | ||
| 1186 | (setq trans | 1191 | (setq trans |
| 1187 | (cons (list 0 0 0 0 nil) | 1192 | (if (equal new prevchars) |
| 1188 | (vconcat prev trans))))) | 1193 | ;; Nothing to change, get back to orig value. |
| 1194 | prev | ||
| 1195 | (cons (list 0 0 0 0 nil) new)))))) | ||
| 1189 | (setcar map trans))))) | 1196 | (setcar map trans))))) |
| 1190 | 1197 | ||
| 1191 | (defun quail-get-translation (def key len) | 1198 | (defun quail-get-translation (def key len) |
| @@ -1358,7 +1365,7 @@ Return the input string." | |||
| 1358 | (let* ((echo-keystrokes 0) | 1365 | (let* ((echo-keystrokes 0) |
| 1359 | (help-char nil) | 1366 | (help-char nil) |
| 1360 | (overriding-terminal-local-map (quail-translation-keymap)) | 1367 | (overriding-terminal-local-map (quail-translation-keymap)) |
| 1361 | (generated-events nil) | 1368 | (generated-events nil) ;FIXME: What is this? |
| 1362 | (input-method-function nil) | 1369 | (input-method-function nil) |
| 1363 | (modified-p (buffer-modified-p)) | 1370 | (modified-p (buffer-modified-p)) |
| 1364 | last-command-event last-command this-command) | 1371 | last-command-event last-command this-command) |
| @@ -1416,7 +1423,7 @@ Return the input string." | |||
| 1416 | (let* ((echo-keystrokes 0) | 1423 | (let* ((echo-keystrokes 0) |
| 1417 | (help-char nil) | 1424 | (help-char nil) |
| 1418 | (overriding-terminal-local-map (quail-conversion-keymap)) | 1425 | (overriding-terminal-local-map (quail-conversion-keymap)) |
| 1419 | (generated-events nil) | 1426 | (generated-events nil) ;FIXME: What is this? |
| 1420 | (input-method-function nil) | 1427 | (input-method-function nil) |
| 1421 | (modified-p (buffer-modified-p)) | 1428 | (modified-p (buffer-modified-p)) |
| 1422 | last-command-event last-command this-command) | 1429 | last-command-event last-command this-command) |
| @@ -1637,7 +1644,7 @@ Make RELATIVE-INDEX the current translation." | |||
| 1637 | (maxcol (- (window-width) | 1644 | (maxcol (- (window-width) |
| 1638 | quail-guidance-translations-starting-column)) | 1645 | quail-guidance-translations-starting-column)) |
| 1639 | (block (nth 3 indices)) | 1646 | (block (nth 3 indices)) |
| 1640 | col idx width trans num-items blocks) | 1647 | col idx width trans num-items) |
| 1641 | (if (< cur start) | 1648 | (if (< cur start) |
| 1642 | ;; We must calculate from the head. | 1649 | ;; We must calculate from the head. |
| 1643 | (setq start 0 block 0) | 1650 | (setq start 0 block 0) |
| @@ -2219,8 +2226,7 @@ are shown (at most to the depth specified `quail-completion-max-depth')." | |||
| 2219 | (setq translations (cdr translations)) | 2226 | (setq translations (cdr translations)) |
| 2220 | ;; Insert every 10 elements with indices in a line. | 2227 | ;; Insert every 10 elements with indices in a line. |
| 2221 | (let ((len (length translations)) | 2228 | (let ((len (length translations)) |
| 2222 | (i 0) | 2229 | (i 0)) |
| 2223 | num) | ||
| 2224 | (while (< i len) | 2230 | (while (< i len) |
| 2225 | (when (zerop (% i 10)) | 2231 | (when (zerop (% i 10)) |
| 2226 | (when (>= i 10) | 2232 | (when (>= i 10) |
| @@ -2348,90 +2354,83 @@ should be made by `quail-build-decode-map' (which see)." | |||
| 2348 | (not (string< x y)))))))) | 2354 | (not (string< x y)))))))) |
| 2349 | (let ((window-width (window-width (get-buffer-window | 2355 | (let ((window-width (window-width (get-buffer-window |
| 2350 | (current-buffer) 'visible))) | 2356 | (current-buffer) 'visible))) |
| 2351 | (single-key-width 3) | ||
| 2352 | (single-trans-width 4) | 2357 | (single-trans-width 4) |
| 2353 | (multiple-key-width 3) | ||
| 2354 | (single-list nil) | 2358 | (single-list nil) |
| 2355 | (multiple-list nil) | 2359 | (multiple-list nil) |
| 2356 | elt trans width pos cols rows col row str col-width) | 2360 | trans) |
| 2357 | ;; Divide the elements of decoding map into single ones (i.e. the | 2361 | ;; Divide the elements of decoding map into single ones (i.e. the |
| 2358 | ;; one that has single translation) and multibyte ones (i.e. the | 2362 | ;; one that has single translation) and multiple ones (i.e. the |
| 2359 | ;; one that has multiple translations). | 2363 | ;; one that has multiple translations). |
| 2360 | (while decode-map | 2364 | (dolist (elt decode-map) |
| 2361 | (setq elt (car decode-map) decode-map (cdr decode-map) | 2365 | (setq trans (cdr elt)) |
| 2362 | trans (cdr elt)) | ||
| 2363 | (if (and (vectorp trans) (= (length trans) 1)) | 2366 | (if (and (vectorp trans) (= (length trans) 1)) |
| 2364 | (setq trans (aref trans 0))) | 2367 | (setq trans (aref trans 0))) |
| 2365 | (if (vectorp trans) | 2368 | (if (vectorp trans) |
| 2366 | (setq multiple-list (cons elt multiple-list)) | 2369 | (push elt multiple-list) |
| 2367 | (setq single-list (cons (cons (car elt) trans) single-list) | 2370 | (push (cons (car elt) trans) single-list) |
| 2368 | width (if (stringp trans) (string-width trans) | 2371 | (let ((width (if (stringp trans) (string-width trans) |
| 2369 | (char-width trans))) | 2372 | (char-width trans)))) |
| 2370 | (if (> width single-trans-width) | 2373 | (if (> width single-trans-width) |
| 2371 | (setq single-trans-width width))) | 2374 | (setq single-trans-width width))))) |
| 2372 | (setq width (length (car elt))) | ||
| 2373 | (if (> width single-key-width) | ||
| 2374 | (setq single-key-width width)) | ||
| 2375 | (if (> width multiple-key-width) | ||
| 2376 | (setq multiple-key-width width))) | ||
| 2377 | (when single-list | 2375 | (when single-list |
| 2378 | (setq col-width (+ single-key-width 1 single-trans-width 1) | 2376 | ;; Since decode-map is sorted, we known the longest key is at the end. |
| 2379 | cols (/ window-width col-width) | 2377 | (let* ((max-key-width (max 3 (length (caar (last single-list))))) |
| 2380 | rows (/ (length single-list) cols)) | 2378 | (col-width (+ max-key-width 1 single-trans-width 1)) |
| 2381 | (if (> (% (length single-list) cols) 0) | 2379 | (cols (/ window-width col-width)) |
| 2382 | (setq rows (1+ rows))) | 2380 | (rows (/ (+ (length single-list) (1- cols)) cols)) ; Round up. |
| 2383 | (insert "key") | 2381 | col pos row) |
| 2384 | (quail-indent-to (1+ single-key-width)) | 2382 | (insert "key") |
| 2385 | (insert "char") | 2383 | (quail-indent-to (1+ max-key-width)) |
| 2386 | (quail-indent-to (1+ col-width)) | 2384 | (insert "char") |
| 2387 | (insert "[type a key sequence to insert the corresponding character]\n") | 2385 | (quail-indent-to (1+ col-width)) |
| 2388 | (setq pos (point)) | 2386 | (insert "[type a key sequence to insert the corresponding character]\n") |
| 2389 | (insert-char ?\n (+ rows 2)) | 2387 | (setq pos (point)) |
| 2390 | (goto-char pos) | 2388 | (insert-char ?\n (+ rows 2)) |
| 2391 | (setq col (- col-width) row 0) | 2389 | (goto-char pos) |
| 2392 | (while single-list | 2390 | (setq col (- col-width) row 0) |
| 2393 | (setq elt (car single-list) single-list (cdr single-list)) | 2391 | (dolist (elt single-list) |
| 2394 | (when (= (% row rows) 0) | 2392 | (when (= (% row rows) 0) |
| 2395 | (goto-char pos) | 2393 | (goto-char pos) |
| 2396 | (setq col (+ col col-width)) | 2394 | (setq col (+ col col-width)) |
| 2395 | (move-to-column col) | ||
| 2396 | (quail-indent-to col) | ||
| 2397 | (insert-char ?- max-key-width) | ||
| 2398 | (insert ? ) | ||
| 2399 | (insert-char ?- single-trans-width) | ||
| 2400 | (forward-line 1)) | ||
| 2397 | (move-to-column col) | 2401 | (move-to-column col) |
| 2398 | (quail-indent-to col) | 2402 | (quail-indent-to col) |
| 2399 | (insert-char ?- single-key-width) | 2403 | (insert (car elt)) |
| 2400 | (insert ? ) | 2404 | (quail-indent-to (+ col max-key-width 1)) |
| 2401 | (insert-char ?- single-trans-width) | 2405 | (insert (cdr elt)) |
| 2402 | (forward-line 1)) | 2406 | (forward-line 1) |
| 2403 | (move-to-column col) | 2407 | (setq row (1+ row))) |
| 2404 | (quail-indent-to col) | 2408 | (goto-char (point-max)))) |
| 2405 | (insert (car elt)) | ||
| 2406 | (quail-indent-to (+ col single-key-width 1)) | ||
| 2407 | (insert (cdr elt)) | ||
| 2408 | (forward-line 1) | ||
| 2409 | (setq row (1+ row))) | ||
| 2410 | (goto-char (point-max))) | ||
| 2411 | 2409 | ||
| 2412 | (when multiple-list | 2410 | (when multiple-list |
| 2413 | (insert "key") | 2411 | ;; Since decode-map is sorted, we known the longest key is at the end. |
| 2414 | (quail-indent-to (1+ multiple-key-width)) | 2412 | (let ((max-key-width (max 3 (length (caar (last multiple-list)))))) |
| 2415 | (insert "character(s) [type a key (sequence) and select one from the list]\n") | 2413 | (insert "key") |
| 2416 | (insert-char ?- multiple-key-width) | 2414 | (quail-indent-to (1+ max-key-width)) |
| 2417 | (insert " ------------\n") | 2415 | (insert "character(s) [type a key (sequence) and select one from the list]\n") |
| 2418 | (while multiple-list | 2416 | (insert-char ?- max-key-width) |
| 2419 | (setq elt (car multiple-list) multiple-list (cdr multiple-list)) | 2417 | (insert " ------------\n") |
| 2420 | (insert (car elt)) | 2418 | (dolist (elt multiple-list) |
| 2421 | (quail-indent-to multiple-key-width) | 2419 | (insert (car elt)) |
| 2422 | (if (vectorp (cdr elt)) | 2420 | (quail-indent-to max-key-width) |
| 2423 | (mapc (function | 2421 | (if (vectorp (cdr elt)) |
| 2424 | (lambda (x) | 2422 | (mapc (function |
| 2425 | (let ((width (if (integerp x) (char-width x) | 2423 | (lambda (x) |
| 2426 | (string-width x)))) | 2424 | (let ((width (if (integerp x) (char-width x) |
| 2427 | (when (> (+ (current-column) 1 width) window-width) | 2425 | (string-width x)))) |
| 2428 | (insert "\n") | 2426 | (when (> (+ (current-column) 1 width) window-width) |
| 2429 | (quail-indent-to multiple-key-width)) | 2427 | (insert "\n") |
| 2430 | (insert " " x)))) | 2428 | (quail-indent-to max-key-width)) |
| 2431 | (cdr elt)) | 2429 | (insert " " x)))) |
| 2432 | (insert " " (cdr elt))) | 2430 | (cdr elt)) |
| 2433 | (insert ?\n)) | 2431 | (insert " " (cdr elt))) |
| 2434 | (insert ?\n)))) | 2432 | (insert ?\n)) |
| 2433 | (insert ?\n))))) | ||
| 2435 | 2434 | ||
| 2436 | (define-button-type 'quail-keyboard-layout-button | 2435 | (define-button-type 'quail-keyboard-layout-button |
| 2437 | :supertype 'help-xref | 2436 | :supertype 'help-xref |
| @@ -2524,13 +2523,12 @@ physical keyboard layout as specified with that variable. | |||
| 2524 | (insert "\n")) | 2523 | (insert "\n")) |
| 2525 | 2524 | ||
| 2526 | ;; Show key sequences. | 2525 | ;; Show key sequences. |
| 2527 | (let ((decode-map (list 'decode-map)) | 2526 | (let* ((decode-map (list 'decode-map)) |
| 2528 | elt pos num) | 2527 | (num (quail-build-decode-map (list (quail-map)) "" decode-map |
| 2529 | (setq num (quail-build-decode-map (list (quail-map)) "" decode-map | ||
| 2530 | ;; We used to use 512 here, but | 2528 | ;; We used to use 512 here, but |
| 2531 | ;; TeX has more than 1000 and | 2529 | ;; TeX has more than 1000 and |
| 2532 | ;; it's good to see the list. | 2530 | ;; it's good to see the list. |
| 2533 | 0 5120 done-list)) | 2531 | 0 5120 done-list))) |
| 2534 | (when (> num 0) | 2532 | (when (> num 0) |
| 2535 | (insert " | 2533 | (insert " |
| 2536 | KEY SEQUENCE | 2534 | KEY SEQUENCE |
| @@ -2561,8 +2559,8 @@ KEY BINDINGS FOR CONVERSION | |||
| 2561 | (run-hooks 'temp-buffer-show-hook))))) | 2559 | (run-hooks 'temp-buffer-show-hook))))) |
| 2562 | 2560 | ||
| 2563 | (defun quail-help-insert-keymap-description (keymap &optional header) | 2561 | (defun quail-help-insert-keymap-description (keymap &optional header) |
| 2564 | (let (pos1 pos2) | 2562 | (let ((pos1 (point)) |
| 2565 | (setq pos1 (point)) | 2563 | pos2) |
| 2566 | (if header | 2564 | (if header |
| 2567 | (insert header)) | 2565 | (insert header)) |
| 2568 | (save-excursion | 2566 | (save-excursion |
| @@ -2935,7 +2933,7 @@ of each directory." | |||
| 2935 | (interactive "FDirectory of LEIM: ") | 2933 | (interactive "FDirectory of LEIM: ") |
| 2936 | (setq dirname (expand-file-name dirname)) | 2934 | (setq dirname (expand-file-name dirname)) |
| 2937 | (let ((leim-list (expand-file-name leim-list-file-name dirname)) | 2935 | (let ((leim-list (expand-file-name leim-list-file-name dirname)) |
| 2938 | quail-dirs list-buf pkg-list pkg-buf pos) | 2936 | quail-dirs list-buf pkg-list pos) |
| 2939 | (if (not (file-writable-p leim-list)) | 2937 | (if (not (file-writable-p leim-list)) |
| 2940 | (error "Can't write to file \"%s\"" leim-list)) | 2938 | (error "Can't write to file \"%s\"" leim-list)) |
| 2941 | (message "Updating %s ..." leim-list) | 2939 | (message "Updating %s ..." leim-list) |