1 ;;; uni-input.el --- Hex Unicode input method
3 ;; Copyright (C) 2001-2015 Free Software Foundation, Inc.
4 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 ;; National Institute of Advanced Industrial Science and Technology (AIST)
6 ;; Registration Number H14PRO021
8 ;; Author: Dave Love <fx@gnu.org>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; Provides an input method for entering characters by hex unicode in
29 ;; the form `uxxxx', similarly to the Yudit editor.
31 ;; This is not really a Quail method, but uses some Quail functions.
32 ;; There is probably A Better Way.
34 ;; You can get a similar effect by using C-q with
35 ;; `read-quoted-char-radix' set to 16.
37 ;; Note that this only allows you to enter BMP values unless someone
38 ;; extends it to use variable numbers of digits.
44 (defun ucs-input-insert-char (char)
46 (move-overlay quail-overlay
(overlay-start quail-overlay
) (point)))
48 (defun ucs-input-method (key)
49 (if (or buffer-read-only
50 (and (/= key ?U
) (/= key ?u
)))
52 (quail-setup-overlays nil
)
53 (ucs-input-insert-char key
)
54 (let ((modified-p (buffer-modified-p))
56 (input-method-function nil
)
65 (let ((seq (read-key-sequence nil
))
67 (if (and (stringp seq
)
69 (setq key
(aref seq
0))
70 (memq key
'(?
0 ?
1 ?
2 ?
3 ?
4 ?
5 ?
6 ?
7 ?
8 ?
9 ?a
71 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F
)))
74 (ucs-input-insert-char key
))
76 (throw 'non-digit
(append (reverse events
)
77 (listify-key-sequence seq
))))))
79 (let ((n (string-to-number (apply 'string
80 (cdr (nreverse events
)))
84 (quail-delete-overlays)
85 (set-buffer-modified-p modified-p
)
86 (run-hooks 'input-method-after-insert-chunk-hook
)))))
89 (defun ucs-input-activate (&optional arg
)
90 "Activate UCS input method.
91 With ARG, activate UCS input method if and only if ARG is positive.
93 While this input method is active, the variable
94 `input-method-function' is bound to the function `ucs-input-method'."
96 (< (prefix-numeric-value arg
) 0))
100 (quail-delete-overlays)
101 (setq describe-current-input-method-function nil
))
102 (kill-local-variable 'input-method-function
))
103 (setq deactivate-current-input-method-function
'ucs-input-deactivate
)
104 (setq describe-current-input-method-function
'ucs-input-help
)
105 (quail-delete-overlays)
106 (if (eq (selected-window) (minibuffer-window))
107 (add-hook 'minibuffer-exit-hook
'quail-exit-from-minibuffer
))
108 (set (make-local-variable 'input-method-function
)
111 (defun ucs-input-deactivate ()
112 "Deactivate UCS input method."
114 (ucs-input-activate -
1))
116 (define-obsolete-function-alias
117 'ucs-input-inactivate
118 'ucs-input-deactivate
"24.3")
120 (defun ucs-input-help ()
122 (with-output-to-temp-buffer "*Help*"
124 Input method: ucs (mode line indicator:U+)
126 Input as Unicode: U<hex> or u<hex>, where <hex> is a four-digit hex number.")))
128 ;; The file leim-list.el contains the following call.
129 ;; (register-input-method "ucs" "UTF-8" 'ucs-input-activate "U+"
130 ;; "Unicode input as hex in the form Uxxxx.")
135 ;; generated-autoload-load-name: "quail/uni-input"
138 ;;; uni-input.el ends here