diff options
| author | Kenichi Handa | 2006-10-26 11:34:09 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-10-26 11:34:09 +0000 |
| commit | 3f0cd39228483550ff06cf0c217bd89d4b8e38c7 (patch) | |
| tree | d398322fed7bc32787674d86e368904bc60f02a0 | |
| parent | d8b52430a56dd551b0b9357ea38b60e3055969d2 (diff) | |
| download | emacs-3f0cd39228483550ff06cf0c217bd89d4b8e38c7.tar.gz emacs-3f0cd39228483550ff06cf0c217bd89d4b8e38c7.zip | |
(terminal-composition-function): New function.
(terminal-composition-function-table): New variable.
(auto-compose-chars): If running on a terminal, use
terminal-composition-function-table.
| -rw-r--r-- | lisp/composite.el | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/lisp/composite.el b/lisp/composite.el index fc973452cec..30010f0f56d 100644 --- a/lisp/composite.el +++ b/lisp/composite.el | |||
| @@ -427,6 +427,41 @@ See also the command `toggle-auto-composition'.") | |||
| 427 | 427 | ||
| 428 | (put 'save-buffer-state 'lisp-indent-function 1) | 428 | (put 'save-buffer-state 'lisp-indent-function 1) |
| 429 | 429 | ||
| 430 | (defun terminal-composition-function (pos &optional string) | ||
| 431 | "General composition function used on terminal. | ||
| 432 | Non-spacing characters are composed with the preceding spacing | ||
| 433 | character. All non-spacing characters has this function in | ||
| 434 | `terminal-composition-function-table'." | ||
| 435 | (let ((from (1- pos)) | ||
| 436 | ch) | ||
| 437 | (if string | ||
| 438 | (length string) | ||
| 439 | (setq pos (1+ pos)) | ||
| 440 | (while (and (< pos (point-max)) | ||
| 441 | (= (aref char-width-table (char-after pos)) 0)) | ||
| 442 | (setq pos (1+ pos))) | ||
| 443 | (if (and (>= from (point-min)) | ||
| 444 | (= (aref (symbol-name (get-char-code-property (char-after from) | ||
| 445 | 'general-category)) | ||
| 446 | 0) | ||
| 447 | ?L)) | ||
| 448 | (compose-region from pos (buffer-substring from pos)) | ||
| 449 | (compose-region (1+ from) pos | ||
| 450 | (concat " " (buffer-substring (1+ from) pos)))) | ||
| 451 | pos))) | ||
| 452 | |||
| 453 | (defvar terminal-composition-function-table | ||
| 454 | (let ((table (make-char-table nil))) | ||
| 455 | (map-char-table | ||
| 456 | #'(lambda (key val) | ||
| 457 | (if (= val 0) (set-char-table-range table key | ||
| 458 | 'terminal-composition-function))) | ||
| 459 | char-width-table) | ||
| 460 | table) | ||
| 461 | "Char table of functions for automatic character composition on terminal. | ||
| 462 | This is like `composition-function-table' but used when Emacs is running | ||
| 463 | on a terminal.") | ||
| 464 | |||
| 430 | (defvar auto-compose-current-font nil | 465 | (defvar auto-compose-current-font nil |
| 431 | "The current font-object used for characters being composed automatically.") | 466 | "The current font-object used for characters being composed automatically.") |
| 432 | 467 | ||
| @@ -444,6 +479,9 @@ This function is the default value of `auto-composition-function' (which see)." | |||
| 444 | (let ((start pos) | 479 | (let ((start pos) |
| 445 | (limit (if string (length string) (point-max))) | 480 | (limit (if string (length string) (point-max))) |
| 446 | (auto-compose-current-font font-object) | 481 | (auto-compose-current-font font-object) |
| 482 | (table (if (display-graphic-p) | ||
| 483 | composition-function-table | ||
| 484 | terminal-composition-function-table)) | ||
| 447 | ch func newpos) | 485 | ch func newpos) |
| 448 | (setq limit | 486 | (setq limit |
| 449 | (or (text-property-any pos limit 'auto-composed t string) | 487 | (or (text-property-any pos limit 'auto-composed t string) |
| @@ -455,7 +493,7 @@ This function is the default value of `auto-composition-function' (which see)." | |||
| 455 | (setq ch (aref string pos)) | 493 | (setq ch (aref string pos)) |
| 456 | (if (= ch ?\n) | 494 | (if (= ch ?\n) |
| 457 | (throw 'tag (1+ pos))) | 495 | (throw 'tag (1+ pos))) |
| 458 | (setq func (aref composition-function-table ch)) | 496 | (setq func (aref table ch)) |
| 459 | (if (and (functionp func) | 497 | (if (and (functionp func) |
| 460 | (setq newpos (funcall func pos string)) | 498 | (setq newpos (funcall func pos string)) |
| 461 | (> newpos pos)) | 499 | (> newpos pos)) |
| @@ -465,7 +503,7 @@ This function is the default value of `auto-composition-function' (which see)." | |||
| 465 | (setq ch (char-after pos)) | 503 | (setq ch (char-after pos)) |
| 466 | (if (= ch ?\n) | 504 | (if (= ch ?\n) |
| 467 | (throw 'tag (1+ pos))) | 505 | (throw 'tag (1+ pos))) |
| 468 | (setq func (aref composition-function-table ch)) | 506 | (setq func (aref table ch)) |
| 469 | (if (and (functionp func) | 507 | (if (and (functionp func) |
| 470 | (setq newpos (funcall func pos string)) | 508 | (setq newpos (funcall func pos string)) |
| 471 | (> newpos pos)) | 509 | (> newpos pos)) |