diff options
| author | Kenichi Handa | 2004-03-04 00:52:45 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-03-04 00:52:45 +0000 |
| commit | 16431d3c7eb3e628e615c35f22f5b9de1fe7953f (patch) | |
| tree | a76e254fc1ee11c5a7f32e59da93c92afa39b7e6 | |
| parent | 7f8005cd23a9d4b179b76f7f68841405dcf99a9c (diff) | |
| download | emacs-16431d3c7eb3e628e615c35f22f5b9de1fe7953f.tar.gz emacs-16431d3c7eb3e628e615c35f22f5b9de1fe7953f.zip | |
(translate-region): Re-implement it here. Make it interactive.
| -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 38bccdc699c..28c93bb176d 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -1897,6 +1897,34 @@ the table in `translation-table-vector'." | |||
| 1897 | (put symbol 'translation-table-id id) | 1897 | (put symbol 'translation-table-id id) |
| 1898 | id)) | 1898 | id)) |
| 1899 | 1899 | ||
| 1900 | (defun translate-region (start end table) | ||
| 1901 | "From START to END, translate characters according to TABLE. | ||
| 1902 | TABLE is a string or a char-table. | ||
| 1903 | If TABLE is a string, the Nth character in it is the mapping | ||
| 1904 | for the character with code N. | ||
| 1905 | If TABLE is a char-table, the element for character N is the mapping | ||
| 1906 | for the character with code N. | ||
| 1907 | It returns the number of characters changed." | ||
| 1908 | (interactive | ||
| 1909 | (list (region-beginning) | ||
| 1910 | (region-end) | ||
| 1911 | (let (table l) | ||
| 1912 | (dotimes (i (length translation-table-vector)) | ||
| 1913 | (if (consp (aref translation-table-vector i)) | ||
| 1914 | (push (list (symbol-name | ||
| 1915 | (car (aref translation-table-vector i)))) l))) | ||
| 1916 | (if (not l) | ||
| 1917 | (error "No translation table defined")) | ||
| 1918 | (while (not table) | ||
| 1919 | (setq table (completing-read "Translation table: " l nil t))) | ||
| 1920 | (intern table)))) | ||
| 1921 | (if (symbolp table) | ||
| 1922 | (let ((val (get table 'translation-table))) | ||
| 1923 | (or (char-table-p val) | ||
| 1924 | (error "Invalid translation table name: %s" table)) | ||
| 1925 | (setq table val))) | ||
| 1926 | (translate-region-internal start end table)) | ||
| 1927 | |||
| 1900 | (put 'with-category-table 'lisp-indent-function 1) | 1928 | (put 'with-category-table 'lisp-indent-function 1) |
| 1901 | 1929 | ||
| 1902 | (defmacro with-category-table (table &rest body) | 1930 | (defmacro with-category-table (table &rest body) |