-
Notifications
You must be signed in to change notification settings - Fork 2
/
ibus.el
3362 lines (3123 loc) · 114 KB
/
ibus.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
;;; ibus.el -- IBus client for GNU Emacs
;; Copyright (C) 2010-2011 S. Irie
;; Author: S. Irie
;; Maintainer: S. Irie
;; Keywords: Input Method, i18n
(defconst ibus-mode-version "0.3.0")
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; IBus is a new input method framework under active development
;; which is designed to overcome the limitations of SCIM.
;; IBus uses D-Bus protocol for communication between the ibus-daemon
;; and clients (engines, panel, config tools). Since the components
;; run in separate processes there is enhanced modularity and stability.
;; Client processes can be loaded, started and stopped independently.
;; The input method engines and clients can be written in any language
;; with a dbus binding.
;; ibus.el is a IBus client for GNU Emacs. This program allows users
;; on-the-spot style input with IBus. The input statuses are
;; individually kept for each buffer, and prefix-keys such as C-x and
;; C-c can be used even if IBus is active. So you can input various
;; languages fast and comfortably by using it.
;; This program is *not* a part of IBus.
;;
;; Requirements:
;;
;; * GNU Emacs 22 or later
;; * IBus (Version 1.2.0 or later)
;; * python-xlib
;;
;; Note that ibus-mode works only when Emacs is running under X session.
;;
;;
;; Installation:
;;
;; First, save this file as ibus.el and byte-compile in
;; a directory that is listed in load-path, and also save
;; ibus-el-agent somewhere in your system.
;;
;; Put the following in your .emacs file:
;;
;; (require 'ibus)
;; (add-hook 'after-init-hook 'ibus-mode-on)
;;
;; If ibus.el and ibus-el-agent are saved in different
;; directories, add a setting to the above as follows:
;;
;; (setq ibus-agent-file-name "/PATH/TO/ibus-el-agent")
;;
;; To disable XIM in Emacs, put the following in ~/.Xresources:
;;
;; Emacs*useXIM: false
;;
;; and restart X session or execute a shell command:
;;
;; xrdb ~/.Xresources
;;
;;
;; Here is the example of settings in .emacs:
;;
;; (require 'ibus)
;; ;; Turn on ibus-mode automatically after loading .emacs
;; (add-hook 'after-init-hook 'ibus-mode-on)
;; ;; Use C-SPC for Set Mark command
;; (ibus-define-common-key ?\C-\s nil)
;; ;; Use C-/ for Undo command
;; (ibus-define-common-key ?\C-/ nil)
;; ;; Change cursor color depending on IBus status
;; (setq ibus-cursor-color '("red" "blue" "limegreen"))
;;
;;; History:
;; 2011-12-24 S. Irie
;; * Version 0.3.0
;; * Update for IBus 1.4.0
;; * Add support for surrounding text
;; * Add option `ibus-candidate-window-h-offset'
;; * Add option `ibus-prediction-window-h-offset'
;; * Add command `ibus-enable-specified-engine'
;; * Bug fixes
;;
;; 2010-11-03 S. Irie
;; * Version 0.2.1
;; * Add support for vim-mode
;; * Bug fixes
;;
;; 2010-08-19 S. Irie
;; * Version 0.2.0
;; * Add `i18n' to parent groups of `ibus'
;; * Add option `ibus-agent-start-ibus-daemon'
;; * Change not to start ibus-daemon automatically by default
;; * Change not to use xwininfo
;; * Change not to ask X root window the property "_NET_ACTIVE_WINDOW"
;; * Delete internal option `ibus-meta-key-exists'
;; * Bug fixes
;;
;; 2010-06-11 S. Irie
;; * Version 0.1.1
;; * Improved performance and stability
;; * Add option `ibus-prediction-window-position'
;; * Add option `ibus-agent-buffering-time'
;; * Bug fixes
;;
;; 2010-05-29 S. Irie
;; * Version 0.1.0
;; * Initial release
;; * Add support for multi-displays environment
;; * Add support for isearch-mode
;; * Add support for INHERIT-INPUT-METHOD
;; * Add support for Japanese kana typing method
;; * Add support for Japanese thumb shift typing method
;; * Fix a lot of bugs
;;
;; 2010-05-09 S. Irie
;; * Version 0.0.2
;; * Imported many functions from scim-bridge.el
;;
;; 2010-04-12 S. Irie
;; * Version 0.0.1
;; * Initial experimental version
;; ToDo:
;; * Don't use xmodmap
;; * Text-only frame support
;; * leim support
;; * performance issue
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; User settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup ibus nil
"Intelligent Input Bus (IBus)"
:prefix "ibus-"
:group 'editing :group 'wp :group 'i18n)
;; Basic settings
(defgroup ibus-basic nil
"Settings of operation, such as mode management and keyboard"
:group 'ibus)
(defcustom ibus-mode-local t
"Non-nil means input statuses can be individually switched at each
buffer by using multiple input contexts. Otherwise, the input status
is globally changed for all buffers."
:type 'boolean
:group 'ibus-basic)
(defcustom ibus-imcontext-temporary-for-minibuffer t
"Non-nil means use one-time input context at minibuffer so that
the minibuffer input starts with IBus' input status off. This option
is ineffectual unless `ibus-mode-local' is non-nil."
:type 'boolean
:group 'ibus-basic)
(defun ibus-customize-isearch (var value)
(set var value)
(if (and (fboundp 'ibus-setup-isearch)
(bound-and-true-p ibus-mode))
(ibus-setup-isearch)))
(defcustom ibus-use-in-isearch-window t
"Non-nil means IBus can be used together with isearch-mode."
:set 'ibus-customize-isearch
:type 'boolean
:group 'ibus-basic)
(defun ibus-customize-key (var value)
(set var value)
(if (and (fboundp 'ibus-update-key-bindings)
(bound-and-true-p ibus-mode))
(ibus-update-key-bindings var)))
(defcustom ibus-common-function-key-list
'((control ".")
(control ",")
(control "<")
(control ">")
(control "/")
(control " ")
(shift " ")
(control alt left)
(control alt right)
(control alt up)
(control alt down)
(zenkaku-hankaku)
(henkan)
(shift henkan)
(alt henkan)
(muhenkan)
(hiragana-katakana)
(alt romaji)
(f6)
(f7)
(f8)
(shift f8)
(f9)
(f10)
(f11)
(f12)
(kp-space)
(kp-equal)
(kp-multiply)
(kp-add)
(kp-separator)
(kp-subtract)
(kp-decimal)
(kp-divide)
(kp-0)
(kp-1)
(kp-2)
(kp-3)
(kp-4)
(kp-5)
(kp-6)
(kp-7)
(kp-8)
(kp-9))
"List of keystrokes that IBus takes over regardless of input status.
To add or remove the elements, you should use a function
`ibus-define-common-key'. Note that `meta' modifier in the element
doesn't indicate alt keys but actual meta key.
WARNING: Don't set an entry of prefix key such as ESC and C-x, or
key sequences starting with the prefix become unusable."
:set 'ibus-customize-key
:type '(repeat (list :format "%v"
(set :format "%v"
:inline t
(const :format "M- " meta)
(const :format "C- " control)
(const :format "S- " shift)
(const :format "H- " hyper)
(const :format "s- " super)
(const :format "A- " alt))
(restricted-sexp :format "%v"
:match-alternatives
(symbolp stringp))))
:group 'ibus-basic)
(defcustom ibus-preedit-function-key-list
'((escape)
(left)
(right)
(up)
(down)
(home)
(end)
(prior)
(next)
(return)
(shift left)
(shift right)
(shift up)
(shift down)
(shift return)
(tab)
(iso-lefttab)
(shift tab)
(shift iso-lefttab)
(backtab)
(backspace)
(delete)
(kp-enter)
(kp-tab))
"List of keystrokes that IBus takes over only when preediting.
To add or remove the elements, you should use a function
`ibus-define-preedit-key'. Note that `meta' modifier in the element
doesn't indicate alt keys but actual meta key."
:set 'ibus-customize-key
:type '(repeat (list :format "%v"
(set :format "%v"
:inline t
(const :format "M- " meta)
(const :format "C- " control)
(const :format "S- " shift)
(const :format "H- " hyper)
(const :format "s- " super)
(const :format "A- " alt))
(restricted-sexp :format "%v"
:match-alternatives
(symbolp stringp))))
:group 'ibus-basic)
(defcustom ibus-use-kana-onbiki-key nil
"Non-nil means you can input a kana prolonged sound mark (\"ー\")
without pushing the shift key when using Japanese kana typing method
with jp-106 keyboard.
This option uses a shell command \"xmodmap\" to modify X's keymap."
:set 'ibus-customize-key
:type 'boolean
:group 'ibus-basic)
(defcustom ibus-simultaneous-pressing-time nil
"Maximum time interval that two keystrokes are recognized as a
simultaneous keystroke. Measured in seconds. The value nil means
any keystrokes are recognized as separate ones.
You must specify the time interval if using Japanese thumb shift
typing method with IBus-Anthy."
:type '(choice (const :tag "none" nil)
(number :tag "interval (sec.)" :value 0.1))
:group 'ibus-basic)
(defcustom ibus-undo-by-committed-string nil
"Non-nil means perform undoing to each committed string.
Otherwise, insertions of committed strings modify undo boundaries to
simulate `self-insert-command' so that undo is performed by nearly 20
columns."
:type 'boolean
:group 'ibus-basic)
(defcustom ibus-clear-preedit-when-unexpected-event nil
"If non-nil, clear preediting area when an unexpected event happens.
The unexpected event is, for example, string insertion by mouse clicking."
:type 'boolean
:group 'ibus-basic)
;; Appearance
(defgroup ibus-appearance nil
"Behaviors of cursor, candidate window, etc."
:group 'ibus)
(defun ibus-customize-cursor-color (var value)
(set var value)
(if (and (fboundp 'ibus-set-cursor-color)
(bound-and-true-p ibus-mode))
(ibus-set-cursor-color)))
(defcustom ibus-cursor-color
nil
"Specify cursor color(s) corresponding to IBus' status.
If the value is a string, specify the cursor color applied when IBus is
on. If a cons cell, its car and cdr are the cursor colors which indicate
that IBus is on and off, respectively. If a list, the first, second and
third (if any) elements correspond to that IBus is on, off and disabled,
respectively. The value nil means don't change the cursor color at all."
:set 'ibus-customize-cursor-color
:type '(choice (const :tag "none (nil)" nil)
(color :tag "red" :format "red (%{sample%})\n" :value "red")
(color :tag "blue" :format "blue (%{sample%})\n" :value "blue")
(color :tag "green" :format "green (%{sample%})\n" :value "limegreen")
(color :tag "other" :value "red")
(cons :tag "other (ON . OFF)"
(color :format "ON: %v (%{sample%}) " :value "red")
(color :format "OFF: %v (%{sample%})\n" :value "blue"))
(list :tag "other (ON OFF)"
(color :format "ON: %v (%{sample%}) " :value "red")
(color :format "OFF: %v (%{sample%}) DISABLED: none\n"
:value "blue"))
(list :tag "other (ON OFF DISABLED)"
(color :format "ON: %v (%{sample%}) " :value "red")
(color :format "OFF: %v (%{sample%})\n" :value "blue")
(color :format "DISABLED: %v (%{sample%})\n"
:value "limegreen")))
:group 'ibus-appearance)
(defcustom ibus-isearch-cursor-type
0
"Cursor shape which is applied when isearch-mode is active.
A value of integer 0 means don't change the cursor shape.
See `cursor-type'."
:type '(choice (const :tag "don't specify (0)" 0)
(const :tag "use frame parameter" t)
(const :tag "don't display" nil)
(const :tag "filled box" box)
(const :tag "hollow box" hollow)
(const :tag "vertical bar" bar)
(cons :tag "vertical bar (specify width)"
(const :format "" bar)
(integer :tag "width" :value 1))
(const :tag "horizontal bar" hbar)
(cons :tag "horizontal bar (specify height)"
(const :format "" hbar)
(integer :tag "height" :value 1)))
:group 'ibus-appearance)
(defcustom ibus-cursor-type-for-candidate
'bar
"Cursor shape which is applied when showing conversion candidates
within the preediting area. A value of integer 0 means don't change
the cursor shape.
See `cursor-type'."
:type '(choice (const :tag "don't specify (0)" 0)
(const :tag "use frame parameter" t)
(const :tag "don't display" nil)
(const :tag "filled box" box)
(const :tag "hollow box" hollow)
(const :tag "vertical bar" bar)
(cons :tag "vertical bar (specify width)"
(const :format "" bar)
(integer :tag "width" :value 1))
(const :tag "horizontal bar" hbar)
(cons :tag "horizontal bar (specify height)"
(const :format "" hbar)
(integer :tag "height" :value 1)))
:group 'ibus-appearance)
(defcustom ibus-put-cursor-on-candidate
t
"Non-nil means put cursor on a selected segment of preediting area.
Otherwise, the cursor is put to the tail of the preediting area when
showing conversion candidates."
:type 'boolean
:group 'ibus-appearance)
(defcustom ibus-candidate-window-h-offset
0
"Specify horizontal offset of candidate window (in pixels)."
:type 'integer
:group 'ibus-appearance)
(defcustom ibus-prediction-window-h-offset
nil
"Specify horizontal offset of prediction window (in pixels or nil).
The value nil means use same offset as `ibus-candidate-window-h-offset'.
Prediction window is used for suggesting words or sentence by some input
methods such as ibus-mozc."
:type '(choice (integer :tag "horizontal offset" 0)
(const :tag "same as candidate window" nil))
:group 'ibus-appearance)
(defcustom ibus-prediction-window-position
0
"Specify position showing a prediction window used by some input
methods such as ibus-mozc. A value of t means show it just under cursor.
An integer 0 means just under the start point of preediting area. If you
won't use prediction window at all, you can set nil in order not to send
data of the coordinates to ibus-daemon."
:type '(choice (const :tag "Don't use prediction" nil)
(const :tag "Head of preediting area" 0)
(const :tag "Just under cursor" t))
:group 'ibus-appearance)
;; Advanced settings
(defgroup ibus-expert nil
"Advanced settings"
:group 'ibus)
(defcustom ibus-agent-file-name
(let ((dir-list `(,(file-name-directory load-file-name)
"~/bin/"
"/usr/local/bin/"
"/usr/local/libexec/"
"/usr/local/libexec/ibus-el/"
"/usr/local/libexec/emacs-ibus/"
"/usr/local/lib/ibus-el/"
"/usr/local/lib/emacs-ibus/"
"/usr/local/share/ibus-el/"
"/usr/local/share/emacs-ibus/"
"/usr/bin/"
"/usr/libexec/"
"/usr/libexec/ibus-el/"
"/usr/libexec/emacs-ibus/"
"/usr/lib/ibus-el/"
"/usr/lib/emacs-ibus/"
"/usr/share/ibus-el/"
"/usr/share/emacs-ibus/"))
file-name)
(while dir-list
(setq file-name (concat (pop dir-list) "ibus-el-agent"))
(if (file-exists-p file-name)
(setq dir-list nil)))
file-name)
"File name of the agent script used for communicating with
ibus-daemon and X servers. If `ibus-python-shell-command-name' is
nil, the agent is executed directly as a shell command so it must
be executable."
:type '(file :must-match t)
:group 'ibus-expert)
(defcustom ibus-python-shell-command-name "python"
"String specifying shell command of Python interpreter, which is
used for executing ibus-el-agent. The value nil means execute the agent
directly as a shell command."
:type '(choice (const :tag "Execute agent directly (nil)" nil)
(file :tag "Path of interpreter" :must-match t))
:group 'ibus-expert)
(defcustom ibus-focus-update-interval 0.3
"Time interval (in seconds) for checking frame focus periodically."
:type 'number
:group 'ibus-expert)
(defcustom ibus-kana-onbiki-x-keysym "F24"
"String specifying a name of X keysym which is used as a substitute
of keysym corresponding to Japanese prolonged sound mark (onbiki) key. The
value nil means don't use the substitutive keysym. ibus-mode modifies X's
keymap according to this option in order to distinguish yen-mark key from
backslash key. This option is ineffectual unless using jp-106 keyboard."
:set 'ibus-customize-key
:type '(choice (string :tag "keysym name" :value "F24")
(const :tag "none" nil))
:group 'ibus-expert)
(defcustom ibus-kana-onbiki-key-symbol 'f24
"Symbol or integer specifying an event of Japanese prolonged sound
mark (onbiki) key. The value nil means don't use that key. If setting
`ibus-kana-onbiki-x-keysym' a substitutive X keysym, you must specify
the event corresponding to that keysym. This option is ineffectual
unless using jp-106 keyboard."
:set 'ibus-customize-key
:type '(choice (symbol :tag "symbol" :value 'f24)
(integer :tag "character code (integer)" :value ?|)
(const :tag "none" nil))
:group 'ibus-expert)
(defcustom ibus-agent-timeout 3.0
"Maximum waiting time for data reception from IBus.
A floating point number means the number of seconds, otherwise an integer
the milliseconds."
:type 'number
:group 'ibus-expert)
(defcustom ibus-agent-buffering-time 50
"Waiting time for data reception which happen in some particular
cases such as focusing out. A floating point number means the number of
seconds, otherwise an integer the milliseconds."
:type 'number
:group 'ibus-expert)
(defcustom ibus-agent-start-ibus-daemon nil
"Specify what to do for ibus-daemon not running.
The value nil means do nothing, so ibus-mode will stop immediately.
If the value is a function, start the daemon automatically if the
function returns non-nil and the daemon is not running. The other
non-nil value means start the daemon unconditionally."
:type '(choice (const :tag "Do nothing (nil)" nil)
(const :tag "Start ibus-daemon (t)" t)
(function :tag "According to function"
(lambda () (equal (getenv "GTK_IM_MODULE") "ibus"))))
:group 'ibus-expert)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; System settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ibus-debug nil)
(defvar ibus-log-buffer "*ibus-mode log*")
(defvar ibus-agent-buffer-name " *IBus*")
(defvar ibus-incompatible-major-modes
'(ebrowse-tree-mode w3m-mode)
"List of symbols specifying major modes that keymaps of ibus-mode are
deactivated.")
(defvar ibus-preedit-incompatible-commands
'(undo undo-only redo undo-tree-undo undo-tree-redo)
"List of symbols specifying commands which are disabled when preediting.")
(defvar ibus-inherit-im-functions
'(read-from-minibuffer read-string read-no-blanks-input completing-read)
"List of symbols specifying functions which inherit input method.
If the function takes the argument INHERIT-INPUT-METHOD, input method
is inherited only when it's non-nil. Otherwise, input method is
unconditionally inherited.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ibus-modifier-alists
'((
(shift . 0)
(control . 2)
(alt . 3)
(super . 26)
(hyper . 27)
(meta . 28)
)
(
(shift . 0)
(control . 2)
(meta . 3)
(super . 26)
(hyper . 27)
)))
(defvar ibus-alt-modifier-alist
'(
(hiragana-katakana . romaji)
(zenkaku-hankaku . kanji)
; (henkan . mode-switch)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Key code table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ibus-keyval-alist
'(
;; *** Function keys ***********************************************
(backspace . ?\xff08)
(tab . ?\xff09)
(linefeed . ?\xff0a)
(clear . ?\xff0b)
(return . ?\xff0d)
(pause . ?\xff13)
; (scroll-lock . ?\xff14)
; (sys-req . ?\xff15)
(escape . ?\xff1b)
(delete . ?\xffff)
;; *** International & multi-key character composition *************
; (multi-key . ?\xff20)
; (codeinput . ?\xff37)
; (singlecandidate . ?\xff3c)
; (multiplecandidate . ?\xff3d)
; (previouscandidate . ?\xff3e)
;; Japanese keyboard support ***************************************
(kanji . ?\xff21)
(muhenkan . ?\xff22)
; (henkan-mode . ?\xff23)
(henkan . ?\xff23)
(romaji . ?\xff24)
(hiragana . ?\xff25)
(katakana . ?\xff26)
(hiragana-katakana . ?\xff27)
(zenkaku . ?\xff28)
(hankaku . ?\xff29)
(zenkaku-hankaku . ?\xff2a)
(touroku . ?\xff2b)
(massyo . ?\xff2c)
(kana-lock . ?\xff2d)
(kana-shift . ?\xff2e)
(eisu-shift . ?\xff2f)
(eisu-toggle . ?\xff30)
; (kanji-bangou . ?\xff37)
; (zen-koho . ?\xff3d)
; (mae-koho . ?\xff3e)
;; *** Cursor control & motion *************************************
(home . ?\xff50)
(left . ?\xff51)
(up . ?\xff52)
(right . ?\xff53)
(down . ?\xff54)
(prior . ?\xff55)
; (page-up . ?\xff55)
(next . ?\xff56)
; (page-down . ?\xff56)
(end . ?\xff57)
(begin . ?\xff58)
;; *** Misc Functions **********************************************
(select . ?\xff60)
(print . ?\xff61)
(execute . ?\xff62)
(insert . ?\xff63)
(undo . ?\xff65)
(redo . ?\xff66)
(menu . ?\xff67)
(find . ?\xff68)
(cancel . ?\xff69)
(help . ?\xff6a)
(break . ?\xff6b)
; (mode-switch . ?\xff7e)
; (num-lock . ?\xff7f)
;; *** Keypad ******************************************************
(kp-space . ?\xff80)
(kp-tab . ?\xff89)
(kp-enter . ?\xff8d)
(kp-f1 . ?\xff91)
(kp-f2 . ?\xff92)
(kp-f3 . ?\xff93)
(kp-f4 . ?\xff94)
(kp-home . ?\xff95)
(kp-left . ?\xff96)
(kp-up . ?\xff97)
(kp-right . ?\xff98)
(kp-down . ?\xff99)
(kp-prior . ?\xff9a)
; (kp-page-up . ?\xff9a)
(kp-next . ?\xff9b)
; (kp-page-down . ?\xff9b)
(kp-end . ?\xff9c)
(kp-begin . ?\xff9d)
(kp-insert . ?\xff9e)
(kp-delete . ?\xff9f)
(kp-equal . ?\xffbd)
(kp-multiply . ?\xffaa)
(kp-add . ?\xffab)
(kp-separator . ?\xffac)
(kp-subtract . ?\xffad)
(kp-decimal . ?\xffae)
(kp-divide . ?\xffaf)
(kp-0 . ?\xffb0)
(kp-1 . ?\xffb1)
(kp-2 . ?\xffb2)
(kp-3 . ?\xffb3)
(kp-4 . ?\xffb4)
(kp-5 . ?\xffb5)
(kp-6 . ?\xffb6)
(kp-7 . ?\xffb7)
(kp-8 . ?\xffb8)
(kp-9 . ?\xffb9)
;; *** Auxilliary functions ****************************************
(f1 . ?\xffbe)
(f2 . ?\xffbf)
(f3 . ?\xffc0)
(f4 . ?\xffc1)
(f5 . ?\xffc2)
(f6 . ?\xffc3)
(f7 . ?\xffc4)
(f8 . ?\xffc5)
(f9 . ?\xffc6)
(f10 . ?\xffc7)
(f11 . ?\xffc8)
(f12 . ?\xffc9)
(f13 . ?\xffca)
(f14 . ?\xffcb)
(f15 . ?\xffcc)
(f16 . ?\xffcd)
(f17 . ?\xffce)
(f18 . ?\xffcf)
(f19 . ?\xffd0)
(f20 . ?\xffd1)
(f21 . ?\xffd2)
(f22 . ?\xffd3)
(f23 . ?\xffd4)
(f24 . ?\xffd5)
(f25 . ?\xffd6)
(f26 . ?\xffd7)
(f27 . ?\xffd8)
(f28 . ?\xffd9)
(f29 . ?\xffda)
(f30 . ?\xffdb)
(f31 . ?\xffdc)
(f32 . ?\xffdd)
(f33 . ?\xffde)
(f34 . ?\xffdf)
(f35 . ?\xffe0)
;; *** Modifier keys ***********************************************
; (shift-l . ?\xffe1)
; (shift-r . ?\xffe2)
; (control-l . ?\xffe3)
; (control-r . ?\xffe4)
; (caps-lock . ?\xffe5)
(capslock . ?\xffe5)
; (shift-lock . ?\xffe6)
; (meta-l . ?\xffe7)
; (meta-r . ?\xffe8)
; (alt-l . ?\xffe9)
; (alt-r . ?\xffea)
; (super-l . ?\xffeb)
; (super-r . ?\xffec)
; (hyper-l . ?\xffed)
; (hyper-r . ?\xffee)
;; *** ISO 9995 function and modifier keys *************************
; (iso-lock . ?\xfe01)
; (iso-level2-latch . ?\xfe02)
; (iso-level3-shift . ?\xfe03)
; (iso-level3-latch . ?\xfe04)
; (iso-level3-lock . ?\xfe05)
; (iso-group-shift . ?\xff7e)
; (iso-group-latch . ?\xfe06)
; (iso-group-lock . ?\xfe07)
; (iso-next-group . ?\xfe08)
; (iso-next-group-lock . ?\xfe09)
; (iso-prev-group . ?\xfe0a)
; (iso-prev-group-lock . ?\xfe0b)
; (iso-first-group . ?\xfe0c)
; (iso-first-group-lock . ?\xfe0d)
; (iso-last-group . ?\xfe0e)
; (iso-last-group-lock . ?\xfe0f)
; (iso-left-tab . ?\xfe20)
(iso-lefttab . ?\xfe20)
(iso-move-line-up . ?\xfe21)
(iso-move-line-down . ?\xfe22)
(iso-partial-line-up . ?\xfe23)
(iso-partial-line-down . ?\xfe24)
(iso-partial-space-left . ?\xfe25)
(iso-partial-space-right . ?\xfe26)
(iso-set-margin-left . ?\xfe27)
(iso-set-margin-right . ?\xfe28)
(iso-release-margin-left . ?\xfe29)
(iso-release-margin-right . ?\xfe2a)
(iso-release-both-margins . ?\xfe2b)
(iso-fast-cursor-left . ?\xfe2c)
(iso-fast-cursor-right . ?\xfe2d)
(iso-fast-cursor-up . ?\xfe2e)
(iso-fast-cursor-down . ?\xfe2f)
(iso-continuous-underline . ?\xfe30)
(iso-discontinuous-underline . ?\xfe31)
(iso-emphasize . ?\xfe32)
(iso-center-object . ?\xfe33)
(iso-enter . ?\xfe34)
;; *** Lispy accent keys *******************************************
(dead-grave . ?\xfe50)
(dead-acute . ?\xfe51)
(dead-circumflex . ?\xfe52)
(dead-tilde . ?\xfe53)
(dead-macron . ?\xfe54)
(dead-breve . ?\xfe55)
(dead-abovedot . ?\xfe56)
(dead-diaeresis . ?\xfe57)
(dead-abovering . ?\xfe58)
(dead-doubleacute . ?\xfe59)
(dead-caron . ?\xfe5a)
(dead-cedilla . ?\xfe5b)
(dead-ogonek . ?\xfe5c)
(dead-iota . ?\xfe5d)
(dead-voiced-sound . ?\xfe5e)
(dead-semivoiced-sound . ?\xfe5f)
(dead-belowdot . ?\xfe60)
(dead-hook . ?\xfe61)
(dead-horn . ?\xfe62)
;; *** Katakana ****************************************************
(overline . ?\x47e)
(kana-fullstop . ?\x4a1)
(kana-openingbracket . ?\x4a2)
(kana-closingbracket . ?\x4a3)
(kana-comma . ?\x4a4)
(kana-conjunctive . ?\x4a5)
; (kana-middledot . ?\x4a5)
(kana-WO . ?\x4a6)
(kana-a . ?\x4a7)
(kana-i . ?\x4a8)
(kana-u . ?\x4a9)
(kana-e . ?\x4aa)
(kana-o . ?\x4ab)
(kana-ya . ?\x4ac)
(kana-yu . ?\x4ad)
(kana-yo . ?\x4ae)
(kana-tsu . ?\x4af)
; (kana-tu . ?\x4af)
(prolongedsound . ?\x4b0)
(kana-A . ?\x4b1)
(kana-I . ?\x4b2)
(kana-U . ?\x4b3)
(kana-E . ?\x4b4)
(kana-O . ?\x4b5)
(kana-KA . ?\x4b6)
(kana-KI . ?\x4b7)
(kana-KU . ?\x4b8)
(kana-KE . ?\x4b9)
(kana-KO . ?\x4ba)
(kana-SA . ?\x4bb)
(kana-SHI . ?\x4bc)
(kana-SU . ?\x4bd)
(kana-SE . ?\x4be)
(kana-SO . ?\x4bf)
(kana-TA . ?\x4c0)
(kana-CHI . ?\x4c1)
; (kana-TI . ?\x4c1)
(kana-TSU . ?\x4c2)
; (kana-TU . ?\x4c2)
(kana-TE . ?\x4c3)
(kana-TO . ?\x4c4)
(kana-NA . ?\x4c5)
(kana-NI . ?\x4c6)
(kana-NU . ?\x4c7)
(kana-NE . ?\x4c8)
(kana-NO . ?\x4c9)
(kana-HA . ?\x4ca)
(kana-HI . ?\x4cb)
(kana-FU . ?\x4cc)
; (kana-HU . ?\x4cc)
(kana-HE . ?\x4cd)
(kana-HO . ?\x4ce)
(kana-MA . ?\x4cf)
(kana-MI . ?\x4d0)
(kana-MU . ?\x4d1)
(kana-ME . ?\x4d2)
(kana-MO . ?\x4d3)
(kana-YA . ?\x4d4)
(kana-YU . ?\x4d5)
(kana-YO . ?\x4d6)
(kana-RA . ?\x4d7)
(kana-RI . ?\x4d8)
(kana-RU . ?\x4d9)
(kana-RE . ?\x4da)
(kana-RO . ?\x4db)
(kana-WA . ?\x4dc)
(kana-N . ?\x4dd)
(voicedsound . ?\x4de)
(semivoicedsound . ?\x4df)
; (kana-switch . ?\xFF7E)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mode management
(defcustom ibus-mode nil
"Toggle ibus-mode.
Setting this variable directly does not take effect;
use either \\[customize] or the function `ibus-mode'."
:set 'custom-set-minor-mode
:initialize 'custom-initialize-default
:version "22.1"
:type 'boolean
:group 'ibus
:require 'ibus)
;; Server information
(defvar ibus-version "0")
(defvar ibus-active-engine-list nil)
(defvar ibus-engine-history nil)
;; Hook variables
(defvar ibus-set-commit-string-hook nil)
(defvar ibus-commit-string-hook nil)
(defvar ibus-preedit-show-hook nil)
;; Manage key bindings
(defvar ibus-meta-key-exist-p nil)
(defvar ibus-modifier-alist nil)
(defvar ibus-mode-map nil)
(defvar ibus-mode-preedit-map nil)
(defvar ibus-mode-common-map nil)
(defvar ibus-mode-kana-onbiki-map nil)
(defvar ibus-mode-minimum-map nil)
(defvar ibus-mode-map-alist nil)
(defvar ibus-mode-map-disabled nil)
(make-variable-buffer-local 'ibus-mode-map-disabled)
(defvar ibus-mode-map-prev-disabled nil)
(make-variable-buffer-local 'ibus-mode-map-prev-disabled)
(put 'ibus-mode-map-prev-disabled 'permanent-local t)
(defvar ibus-kana-onbiki-prev-x-keysym nil)
(defvar ibus-keyboard-layout nil)
(defvar ibus-keymap-overlay nil)
;; Communication & buffer editing
(defvar ibus-agent-process nil)
(defvar ibus-agent-process-alist nil)
(defvar ibus-callback-queue nil)
(defvar ibus-agent-key-event-handled nil)
(defvar ibus-selected-display nil)
(defvar ibus-last-command-event nil)
(defvar ibus-current-buffer nil)
(defvar ibus-selected-frame nil)
(defvar ibus-frame-focus nil)
(defvar ibus-focused-window-id nil)
(defvar ibus-string-insertion-failed nil)
(defvar ibus-last-rejected-event nil)
(defvar ibus-last-command nil)
(defvar ibus-cursor-prev-location nil)
;; IMContexts
(defvar ibus-buffer-group nil)
(make-variable-buffer-local 'ibus-buffer-group)
(put 'ibus-buffer-group 'permanent-local t)
;; Memo:
;; Each element of `ibus-buffer-group-alist' is a list:
;; (GROUP IMCONTEXT-ID-ALIST IMCONTEXT-STATUS-ALIST BUFFER-LIST)
;; GROUP is group identifier which is an object comparable by `eq'
;; IMCONTEXT-ID-ALIST is an alist of number such as 12
;; IMCONTEXT-STATUS-ALIST is an alist of string or nil, where string
;; indicates input method engine
;; BUFFER-LIST is a list of buffers which belong to this group
;; Example:
;; ((#<buffer text.txt>
;; ((":1.0" . 1)
;; (":0.0" . 20))
;; ((":1.0" . "anthy")
;; (":0.0" . nil))
;; (#<buffer text.txt>))
;; (#<buffer *scratch*>
;; ((":1.0" . 2)
;; (":0.0" . 19))
;; ((":1.0" . nil)
;; (":0.0" . "skk"))
;; (#<buffer *scratch*>)))
(defvar ibus-buffer-group-alist nil)
(defvar ibus-imcontext-id nil)
(defvar ibus-imcontext-status nil)
(defvar ibus-preediting-p nil)
(defvar ibus-preedit-point (make-marker))
(defvar ibus-preedit-update nil)
(defvar ibus-preedit-shown nil)
(defvar ibus-preedit-text "")
(defvar ibus-preedit-prev-text "")
(defvar ibus-preedit-curpos 0)
(defvar ibus-preedit-prev-curpos 0)
(defvar ibus-preedit-attributes nil)
(defvar ibus-preedit-prev-attributes nil)