diff options
| author | Kenichi Handa | 2004-10-22 13:10:23 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-10-22 13:10:23 +0000 |
| commit | 0e86dca11a6c9ff2e17c12596f299838a62dbd7f (patch) | |
| tree | 13f45ef8d43af6da31bee7054ceaf03e19a787ba | |
| parent | 365d14677e0dae7fd34730e9872a5b8fe655f733 (diff) | |
| download | emacs-0e86dca11a6c9ff2e17c12596f299838a62dbd7f.tar.gz emacs-0e86dca11a6c9ff2e17c12596f299838a62dbd7f.zip | |
(translate-region): Implement it in Lisp
as a front end of translate-region-internal.
| -rw-r--r-- | lisp/international/mule.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 840dd67087f..f5294fea92f 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -2015,6 +2015,34 @@ the table in `translation-table-vector'." | |||
| 2015 | (put symbol 'translation-table-id id) | 2015 | (put symbol 'translation-table-id id) |
| 2016 | id)) | 2016 | id)) |
| 2017 | 2017 | ||
| 2018 | (defun translate-region (start end table) | ||
| 2019 | "From START to END, translate characters according to TABLE. | ||
| 2020 | TABLE is a string or a char-table. | ||
| 2021 | If TABLE is a string, the Nth character in it is the mapping | ||
| 2022 | for the character with code N. | ||
| 2023 | If TABLE is a char-table, the element for character N is the mapping | ||
| 2024 | for the character with code N. | ||
| 2025 | It returns the number of characters changed." | ||
| 2026 | (interactive | ||
| 2027 | (list (region-beginning) | ||
| 2028 | (region-end) | ||
| 2029 | (let (table l) | ||
| 2030 | (dotimes (i (length translation-table-vector)) | ||
| 2031 | (if (consp (aref translation-table-vector i)) | ||
| 2032 | (push (list (symbol-name | ||
| 2033 | (car (aref translation-table-vector i)))) l))) | ||
| 2034 | (if (not l) | ||
| 2035 | (error "No translation table defined")) | ||
| 2036 | (while (not table) | ||
| 2037 | (setq table (completing-read "Translation table: " l nil t))) | ||
| 2038 | (intern table)))) | ||
| 2039 | (if (symbolp table) | ||
| 2040 | (let ((val (get table 'translation-table))) | ||
| 2041 | (or (char-table-p val) | ||
| 2042 | (error "Invalid translation table name: %s" table)) | ||
| 2043 | (setq table val))) | ||
| 2044 | (translate-region-internal start end table)) | ||
| 2045 | |||
| 2018 | (put 'with-category-table 'lisp-indent-function 1) | 2046 | (put 'with-category-table 'lisp-indent-function 1) |
| 2019 | 2047 | ||
| 2020 | (defmacro with-category-table (table &rest body) | 2048 | (defmacro with-category-table (table &rest body) |