Mercurial > emacs
annotate leim/quail/uni-input.el @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sun, 23 Jan 2011 23:08:04 -0600 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
40712 | 1 ;;; uni-input.el --- Hex Unicode input method |
2 | |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
75253
f5f322eb227f
Update copyright for years from Emacs 21 to present.
Glenn Morris <rgm@gnu.org>
parents:
75203
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
5 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
67657 | 6 ;; National Institute of Advanced Industrial Science and Technology (AIST) |
7 ;; Registration Number H14PRO021 | |
40712 | 8 |
9 ;; Author: Dave Love <fx@gnu.org> | |
10 ;; Keywords: i18n | |
11 | |
42320 | 12 ;; This file is part of GNU Emacs. |
13 | |
94710
4f1fd208c354
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
40712 | 15 ;; it under the terms of the GNU General Public License as published by |
94710
4f1fd208c354
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
4f1fd208c354
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
17 ;; (at your option) any later version. |
40712 | 18 |
94710
4f1fd208c354
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
40712 | 20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
94710
4f1fd208c354
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
40712 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;; Provides an input method for entering characters by hex unicode in | |
30 ;; the form `uxxxx', similarly to the Yudit editor. | |
31 | |
32 ;; This is not really a Quail method, but uses some Quail functions. | |
33 ;; There is probably A Better Way. | |
34 | |
88785 | 35 ;; You can get a similar effect by using C-q with |
36 ;; `read-quoted-char-radix' set to 16. | |
40712 | 37 |
89384 | 38 ;; Note that this only allows you to enter BMP values unless someone |
39 ;; extends it to use variable numbers of digits. | |
40712 | 40 |
41 ;;; Code: | |
42 | |
43 (require 'quail) | |
44 | |
57180
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
45 (defun ucs-input-insert-char (char) |
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
46 (insert char) |
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
47 (move-overlay quail-overlay (overlay-start quail-overlay) (point))) |
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
48 |
40712 | 49 (defun ucs-input-method (key) |
50 (if (or buffer-read-only | |
51 (and (/= key ?U) (/= key ?u))) | |
52 (list key) | |
53 (quail-setup-overlays nil) | |
57180
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
54 (ucs-input-insert-char key) |
40712 | 55 (let ((modified-p (buffer-modified-p)) |
56 (buffer-undo-list t) | |
57 (input-method-function nil) | |
58 (echo-keystrokes 0) | |
59 (help-char nil) | |
60 (events (list key)) | |
61 (str " ")) | |
62 (unwind-protect | |
63 (catch 'non-digit | |
64 (progn | |
65 (dotimes (i 4) | |
66 (let ((seq (read-key-sequence nil)) | |
67 key) | |
68 (if (and (stringp seq) | |
69 (= 1 (length seq)) | |
70 (setq key (aref seq 0)) | |
71 (memq key '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?a | |
88785 | 72 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F))) |
40712 | 73 (progn |
74 (push key events) | |
57180
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
75 (ucs-input-insert-char key)) |
40712 | 76 (quail-delete-region) |
77 (throw 'non-digit (append (reverse events) | |
78 (listify-key-sequence seq)))))) | |
79 (quail-delete-region) | |
88785 | 80 (let ((n (string-to-number (apply 'string |
81 (cdr (nreverse events))) | |
82 16))) | |
83 (if (characterp n) | |
84 (list n))))) | |
40712 | 85 (quail-delete-overlays) |
86 (set-buffer-modified-p modified-p) | |
87 (run-hooks 'input-method-after-insert-chunk-hook))))) | |
88 | |
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. | |
92 | |
93 While this input method is active, the variable | |
94 `input-method-function' is bound to the function `ucs-input-method'." | |
95 (if (and arg | |
96 (< (prefix-numeric-value arg) 0)) | |
97 (unwind-protect | |
98 (progn | |
57180
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
99 (quail-hide-guidance) |
40712 | 100 (quail-delete-overlays) |
101 (setq describe-current-input-method-function nil)) | |
102 (kill-local-variable 'input-method-function)) | |
103 (setq inactivate-current-input-method-function 'ucs-input-inactivate) | |
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) | |
109 'ucs-input-method))) | |
110 | |
111 (defun ucs-input-inactivate () | |
112 "Inactivate UCS input method." | |
113 (interactive) | |
114 (ucs-input-activate -1)) | |
115 | |
116 (defun ucs-input-help () | |
117 (interactive) | |
118 (with-output-to-temp-buffer "*Help*" | |
119 (princ "\ | |
74538
dc4eb942b3a5
(ucs-input-help): Fix title of ucs input method.
Juanma Barranquero <lekktu@gmail.com>
parents:
72860
diff
changeset
|
120 Input method: ucs (mode line indicator:U+) |
40712 | 121 |
122 Input as Unicode: U<hex> or u<hex>, where <hex> is a four-digit hex number."))) | |
123 | |
57180
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
124 ;; The file ../leim-ext.el contains the following call. |
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
125 ;; (register-input-method "ucs" "UTF-8" 'ucs-input-activate "U+" |
5afba9a35578
Move the call of register-input-method to leim-ext.el.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
126 ;; "Unicode input as hex in the form Uxxxx.") |
40712 | 127 |
128 (provide 'uni-input) | |
129 | |
130 ;;; uni-input.el ends here |