annotate leim/quail/uni-input.el @ 89691:af1655b4ee65

(handle_auto_composed_prop): Fix setting of limit.
author Kenichi Handa <handa@m17n.org>
date Mon, 29 Dec 2003 07:57:00 +0000
parents 2f877ed80fa6
children 68c22ea6027c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
1 ;;; uni-input.el --- Hex Unicode input method
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
2
88785
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
3 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
4
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
5 ;; Author: Dave Love <fx@gnu.org>
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Keywords: i18n
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
7
42320
44b4a14ae7fc Fix Lisp headers.
Pavel Janík <Pavel@Janik.cz>
parents: 40712
diff changeset
8 ;; This file is part of GNU Emacs.
44b4a14ae7fc Fix Lisp headers.
Pavel Janík <Pavel@Janik.cz>
parents: 40712
diff changeset
9
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
10 ;; This file is free software; you can redistribute it and/or modify
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
13 ;; any later version.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
14
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
15 ;; This file is distributed in the hope that it will be useful,
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
19
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
24
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
26
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;; Provides an input method for entering characters by hex unicode in
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
28 ;; the form `uxxxx', similarly to the Yudit editor.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
29
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
30 ;; This is not really a Quail method, but uses some Quail functions.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; There is probably A Better Way.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
32
88785
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
33 ;; You can get a similar effect by using C-q with
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
34 ;; `read-quoted-char-radix' set to 16.
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
35
89384
02430d914fc1 Comment.
Dave Love <fx@gnu.org>
parents: 88785
diff changeset
36 ;; Note that this only allows you to enter BMP values unless someone
02430d914fc1 Comment.
Dave Love <fx@gnu.org>
parents: 88785
diff changeset
37 ;; extends it to use variable numbers of digits.
02430d914fc1 Comment.
Dave Love <fx@gnu.org>
parents: 88785
diff changeset
38
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
39 ;;; Code:
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
40
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
41 (require 'quail)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
42
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
43 (defun ucs-input-method (key)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
44 (if (or buffer-read-only
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
45 (and (/= key ?U) (/= key ?u)))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
46 (list key)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
47 (quail-setup-overlays nil)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
48 (let ((current-prefix-arg)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
49 (last-command-char key))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
50 (call-interactively 'self-insert-command))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
51 (let ((modified-p (buffer-modified-p))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
52 (buffer-undo-list t)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
53 (input-method-function nil)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
54 (echo-keystrokes 0)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
55 (help-char nil)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
56 (events (list key))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
57 (str " "))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
58 (unwind-protect
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
59 (catch 'non-digit
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
60 (progn
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
61 (dotimes (i 4)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
62 (let ((seq (read-key-sequence nil))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
63 key)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
64 (if (and (stringp seq)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
65 (= 1 (length seq))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
66 (setq key (aref seq 0))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
67 (memq key '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?a
88785
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
68 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F)))
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
69 (progn
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
70 (push key events)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
71 (let ((last-command-char key)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
72 (current-prefix-arg))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
73 (call-interactively 'self-insert-command)))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
74 (let ((last-command-char key)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
75 (current-prefix-arg))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
76 (condition-case nil
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
77 (call-interactively (key-binding seq))))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
78 (quail-delete-region)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
79 (throw 'non-digit (append (reverse events)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
80 (listify-key-sequence seq))))))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
81 (quail-delete-region)
88785
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
82 (let ((n (string-to-number (apply 'string
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
83 (cdr (nreverse events)))
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
84 16)))
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
85 (if (characterp n)
3387266b74c1 (utf-8-ccl-encode): Deleted.
Dave Love <fx@gnu.org>
parents: 42320
diff changeset
86 (list n)))))
40712
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
87 (quail-delete-overlays)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
88 (set-buffer-modified-p modified-p)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
89 (run-hooks 'input-method-after-insert-chunk-hook)))))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
90
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
91 (defun ucs-input-activate (&optional arg)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
92 "Activate UCS input method.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
93 With arg, activate UCS input method if and only if arg is positive.
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
94
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
95 While this input method is active, the variable
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
96 `input-method-function' is bound to the function `ucs-input-method'."
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
97 (if (and arg
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
98 (< (prefix-numeric-value arg) 0))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
99 (unwind-protect
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
100 (progn
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
101 (quail-hide-guidance-buf)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
102 (quail-delete-overlays)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
103 (setq describe-current-input-method-function nil))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
104 (kill-local-variable 'input-method-function))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
105 (setq inactivate-current-input-method-function 'ucs-input-inactivate)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
106 (setq describe-current-input-method-function 'ucs-input-help)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
107 (quail-delete-overlays)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
108 (if (eq (selected-window) (minibuffer-window))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
109 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
110 (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
111 (set (make-local-variable 'input-method-function)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
112 'ucs-input-method)))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
113
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
114 (defun ucs-input-inactivate ()
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
115 "Inactivate UCS input method."
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
116 (interactive)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
117 (ucs-input-activate -1))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
118
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
119 (defun ucs-input-help ()
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
120 (interactive)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
121 (with-output-to-temp-buffer "*Help*"
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
122 (princ "\
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
123 Input method: ucs (mode line indicator:U)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
124
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
125 Input as Unicode: U<hex> or u<hex>, where <hex> is a four-digit hex number.")))
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
126
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
127 (register-input-method "ucs" "UTF-8" 'ucs-input-activate "U+"
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
128 "Unicode input as hex in the form Uxxxx.")
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
129
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
130 (provide 'uni-input)
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
131
31101867e6bf *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
132 ;;; uni-input.el ends here