-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathemacs-27.1-windows-ime-20200914.patch
2527 lines (2455 loc) · 72.8 KB
/
emacs-27.1-windows-ime-20200914.patch
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
diff -urN emacs-27.1.orig/configure.ac emacs-27.1/configure.ac
--- emacs-27.1.orig/configure.ac 2020-09-14 14:08:53.683423700 +0900
+++ emacs-27.1/configure.ac 2020-09-14 16:12:09.698685200 +0900
@@ -448,6 +448,10 @@
On by default on macOS.])],[],[with_ns=maybe])
OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
+OPTION_DEFAULT_ON([w32-ime], [don't compile with W32-IME support])
+OPTION_DEFAULT_ON([reconversion], [don't compile with RECONVERSION support])
+OPTION_DEFAULT_ON([documentfeed], [don't compile with DOCUMENTFEED support])
+
OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
AC_ARG_WITH([gconf],[AS_HELP_STRING([--with-gconf],
@@ -5642,6 +5646,42 @@
ACL_SUMMARY=no
fi
+USE_W32_IME=no
+if test "${HAVE_W32}" = "yes"; then
+ if test "${with_w32_ime}" != "no"; then
+ USE_W32_IME=yes
+ AC_DEFINE(USE_W32_IME, 1, [Define to support W32-IME.])
+
+ RECONVERSION=no
+ if test "${with_reconversion}" != "no"; then
+ AC_CACHE_CHECK([whether RECONVERTSTRING is declared],
+ emacs_cv_have_reconvertstring,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <windows.h>
+#include <imm.h>]], [[RECONVERTSTRING]])],
+ emacs_cv_have_reconvertstring=yes, emacs_cv_have_reconvertstring=no)])
+ if test "$emacs_cv_have_reconvertstring" = "yes"; then
+ RECONVERSION=yes
+ AC_DEFINE(RECONVERSION, 1, [Define to support RECONVERSION.])
+ AC_DEFINE(HAVE_RECONVERTSTRING, 1, [Define to 1 if you have RECONVERTSTRING.])
+
+ DOCUMENTFEED=no
+ if test "${with_documentfeed}" != "no"; then
+ AC_CHECK_DECL(IMR_DOCUMENTFEED, HAVE_IMR_DOCUMENTFEED=yes,
+ HAVE_IMR_DOCUMENTFEED=no,[[
+#include <windows.h>
+#include <imm.h>]])
+ if test "$ac_cv_have_decl_IMR_DOCUMENTFEED" = "yes"; then
+ DOCUMENTFEED=yes
+ AC_DEFINE(DOCUMENTFEED, 1, [Define to support DOCUMENTFEED.])
+ AC_DEFINE(HAVE_IMR_DOCUMENTFEED, 1, [Define to 1 if you have IMR_DOCUMENTFEED.])
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+
emacs_standard_dirs='Standard dirs'
AS_ECHO(["
Configured for '${canonical}'.
@@ -5695,6 +5735,10 @@
AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
optsep=' '
done
+if test "${USE_W32_IME}" = "yes"; then
+ opt=W32_IME
+ AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
+fi
AC_DEFINE_UNQUOTED(EMACS_CONFIG_FEATURES, "${emacs_config_features}",
[Summary of some of the main features enabled by configure.])
@@ -5736,6 +5780,16 @@
Which dumping strategy does Emacs use? ${with_dumping}
"])
+if test "${HAVE_W32}" = "yes"; then
+ AS_ECHO([" Does Emacs support W32-IME? ${USE_W32_IME}"])
+ if test "${USE_W32_IME}" = "yes"; then
+ AS_ECHO([" Does Emacs support RECONVERSION? ${RECONVERSION}"])
+ if test "${RECONVERSION}" = "yes"; then
+ AS_ECHO([" Does Emacs support DOCUMENTFEED? ${DOCUMENTFEED}"])
+ fi
+ fi
+fi
+
if test -n "${EMACSDATA}"; then
AS_ECHO([" Environment variable EMACSDATA set to: $EMACSDATA"])
fi
diff -urN emacs-27.1.orig/lisp/international/smart-ime.el emacs-27.1/lisp/international/smart-ime.el
--- emacs-27.1.orig/lisp/international/smart-ime.el 1970-01-01 09:00:00.000000000 +0900
+++ emacs-27.1/lisp/international/smart-ime.el 2020-09-14 16:04:19.218273800 +0900
@@ -0,0 +1,172 @@
+;;; smart-ime.el - smart Input Method -*- lexical-binding: t -*-
+;;
+;; Copyright (C) 2011 HIROSHI OOTA
+
+;; Author: HIROSHI OOTA
+;; Keywords: convenience
+
+;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;;
+;; smart-im frees you from the frustration about IM.
+;; It disables an IM automatically according to a situation.
+
+;;; Install:
+;; Put this file into load-path'ed directory, and byte compile it if
+;; desired. And put the following expression into your ~/.emacs.
+;;
+;; (require 'smart-ime)
+
+;; Todo:
+
+;;; Code:
+
+;; variable
+(defvar sime-saved-input-method nil)
+(make-variable-buffer-local 'sime-saved-input-method)
+(set-default 'sime-saved-input-method nil)
+
+(defun sime-activate-input-method ()
+ (setq sime-saved-input-method (list current-input-method))
+ (deactivate-input-method))
+(defun sime-inactivate-input-method ()
+ (when sime-saved-input-method
+ (activate-input-method (car sime-saved-input-method))
+ (setq sime-saved-input-method nil)))
+
+;;
+;; minibuffer
+(add-hook 'minibuffer-setup-hook 'sime-activate-input-method)
+(add-hook 'minibuffer-exit-hook 'sime-inactivate-input-method)
+;;
+;; incremental search
+(add-hook 'isearch-mode-hook 'sime-activate-input-method)
+(add-hook 'isearch-mode-end-hook 'sime-inactivate-input-method)
+
+;;
+;; query-replace, query-replace-regexp, query-replace-regexp-eval ...
+(defadvice perform-replace
+ (around sime-ad-perform-replace compile activate)
+ (let ((im current-input-method))
+ (if (or (not im)
+ (not (ad-get-arg 2)))
+ ad-do-it
+ (deactivate-input-method)
+ ad-do-it
+ (activate-input-method im))))
+
+;;
+;; read-passwd
+(defadvice read-passwd
+ (around sime-ad-read-passwd compile activate)
+ (let ((sime-ad-toggle-ime-mapped-key-list nil)
+ (im current-input-method))
+ (dolist (k (where-is-internal
+ 'toggle-input-method overriding-local-map nil nil
+ (command-remapping 'toggle-input-method)))
+ (when (integerp (aref k 0))
+ (setq sime-ad-toggle-ime-mapped-key-list
+ (cons (aref k 0) sime-ad-toggle-ime-mapped-key-list))))
+
+ (ad-enable-advice 'read-key 'around 'sime-ad-read-key)
+ (ad-activate 'read-key)
+ (deactivate-input-method)
+ ad-do-it
+ (activate-input-method im)
+ (ad-disable-advice 'read-key 'around 'sime-ad-read-key)
+ (ad-activate 'read-key)))
+
+(defadvice read-key
+ (around sime-ad-read-key compile)
+ (let ((flag t)
+ (msg (current-message)))
+ (while flag
+ ad-do-it
+ (if (not (memq ad-return-value
+ sime-ad-toggle-ime-mapped-key-list))
+ (setq flag nil)
+ (toggle-input-method)
+ (message msg)))))
+
+;;
+;; universal-argument
+(defadvice universal-argument
+ (before sime-ad-universal-argument compile activate)
+ (setq sime-saved-input-method
+ (or sime-saved-input-method
+ (list current-input-method)))
+ (deactivate-input-method))
+
+(defun universal-argument--mode ()
+ (setq sime-saved-input-method
+ (or sime-saved-input-method
+ (list current-input-method)))
+ (deactivate-input-method)
+ (prefix-command-update)
+ (set-transient-map universal-argument-map #'sime-inactivate-input-method))
+
+;; a keyboard which has no KANJI-KEY
+;; entering/leaving KANJI-mode key-sequence is <kanji><M-kanji>
+;; then we should pass prefix-arg to next command.
+(global-set-key
+ [M-kanji]
+ #'(lambda (arg)
+ (interactive "P")
+ (setq prefix-arg arg)))
+
+;;
+;; others
+(defmacro wrap-function-to-control-input-method (fcn)
+ `(defadvice ,fcn (around
+ ,(make-symbol (concat "sime-ad-" (symbol-name fcn)))
+ compile activate)
+ (let ((im current-input-method))
+ (deactivate-input-method)
+ ad-do-it
+ (activate-input-method im))))
+
+(wrap-function-to-control-input-method map-y-or-n-p)
+(wrap-function-to-control-input-method y-or-n-p)
+(wrap-function-to-control-input-method read-key-sequence)
+
+;; disable W32-IME control during processing the timer handler
+(defadvice timer-event-handler
+ (around sime-ad-timer-event-handler compile activate)
+ (let ((w32-ime-buffer-switch-p nil))
+ ad-do-it))
+
+;; turn IME off when specifying a register
+(eval-when-compile (require 'cl-macs))
+(declare-function saved-read-key "register" (&optional prompt))
+(declare-function register-read-with-preview-with-ime-off "register" (orig-fun &rest args))
+(with-eval-after-load "register"
+ (fset 'saved-read-key (symbol-function 'read-key))
+ (defun read-key-with-ime-off (&optional prompt)
+ (let ((im current-input-method)
+ (key))
+ (deactivate-input-method)
+ (setq key (saved-read-key prompt))
+ (activate-input-method im)
+ key))
+ (defun register-read-with-preview-with-ime-off (orig-fun &rest args)
+ (cl-letf (((symbol-function 'read-key)
+ (symbol-function 'read-key-with-ime-off)))
+ (apply orig-fun args)))
+ (advice-add 'register-read-with-preview :around #'register-read-with-preview-with-ime-off))
+
+(provide 'smart-ime)
+;; -*- mode: Emacs-Lisp; coding: euc-jp-unix -*-
diff -urN emacs-27.1.orig/lisp/international/w32-ime.el emacs-27.1/lisp/international/w32-ime.el
--- emacs-27.1.orig/lisp/international/w32-ime.el 1970-01-01 09:00:00.000000000 +0900
+++ emacs-27.1/lisp/international/w32-ime.el 2020-09-14 16:04:19.222274400 +0900
@@ -0,0 +1,200 @@
+;;;;; w32-ime.el ---- Meadow features for NTEmacs. -*- lexical-binding: t -*-
+;;
+;; Author H.Miyashita
+;;
+;;;;;
+
+(defgroup W32-IME nil
+ "w32-ime"
+ :group 'emacs)
+
+(defvar w32-last-selection nil
+ "It is stored the last data from Emacs.")
+
+;----------
+
+(defvar w32-ime-on-hook nil
+ "Functions to eval when IME is turned on at least.
+Even if IME state is not changed, these functiona are maybe called.")
+(defvar w32-ime-off-hook nil
+ "Functions to eval when IME is turned off at least.
+Even if IME state is not changed, these functiona are maybe called.")
+(defvar w32-ime-buffer-switch-p t
+ "If this variable is nil, IME control when buffer is switched is disabled.")
+(defvar w32-ime-show-mode-line t
+ "When t, mode line indicates IME state.")
+(defvar w32-ime-mode-line-state-indicator "[O]"
+ "This is shown at the mode line. It is regarded as state of ime.")
+(make-variable-buffer-local 'w32-ime-mode-line-state-indicator)
+(put 'w32-ime-mode-line-state-indicator 'permanent-local t)
+(defvar w32-ime-mode-line-state-indicator-list '("-" "[|]" "[O]")
+ "List of IME state indicator string.")
+(defvar w32-ime-mode-line-format-original nil
+ "Original mode line format.")
+
+;;
+;; Section: IME
+;;
+
+;; ;; This is temporal solution. In the future, we will prepare
+;; ;; dynamic configuration.
+;; (defvar w32-ime-coding-system-language-environment-alist
+;; '(("Japanese" . japanese-shift-jis)
+;; ("Chinese-GB" . chinese-iso-8bit)
+;; ("Chinese-BIG5" . chinese-big5)
+;; ("Korean" . korean-iso-8bit)))
+
+;;
+;; IME state indicator
+;;
+(global-set-key [kanji] 'ignore)
+(global-set-key [compend] 'ignore)
+
+(defun wrap-function-to-control-ime
+ (function interactive-p interactive-arg &optional suffix)
+ "Wrap FUNCTION, and IME control is enabled when FUNCTION is called.
+An original function is saved to FUNCTION-SUFFIX when suffix is string.
+If SUFFIX is nil, \"-original\" is added. "
+ (let ((original-function
+ (intern (concat (symbol-name function)
+ (if suffix suffix "-original")))))
+ (cond
+ ((not (fboundp original-function))
+ (fset original-function
+ (symbol-function function))
+ (fset function
+ (list
+ 'lambda '(&rest arguments)
+ (when interactive-p
+ (list 'interactive interactive-arg))
+ `(cond
+ ((and (ime-get-mode)
+ (equal current-input-method "W32-IME"))
+ (ime-force-off)
+ (unwind-protect
+ (apply ',original-function arguments)
+ (when (and (not (ime-get-mode))
+ (equal current-input-method "W32-IME"))
+ (ime-force-on))))
+ (t
+ (apply ',original-function arguments)))))))))
+
+(defvar w32-ime-toroku-region-yomigana nil
+ "* if this variable is string, toroku-region regard this value as yomigana.")
+
+(defun w32-ime-toroku-region (begin end)
+ (interactive "r")
+ (let ((string (buffer-substring begin end))
+ (w32-ime-buffer-switch-p nil)
+ (reading w32-ime-toroku-region-yomigana))
+ (unless (stringp reading)
+ (w32-set-ime-mode 'hiragana)
+ (setq reading
+ (read-multilingual-string
+ (format "Input reading of \"%s\": " string) nil "W32-IME")))
+ (w32-ime-register-word-dialog reading string)))
+
+;; for IME management system.
+
+(defun w32-ime-sync-state (window)
+ (when w32-ime-buffer-switch-p
+ (with-current-buffer (window-buffer window)
+ (let* ((ime-state (ime-get-mode)))
+ (cond
+ ((and (not ime-state)
+ (equal current-input-method "W32-IME"))
+ (ime-force-on nil)
+ (run-hooks 'w32-ime-on-hook))
+ ((and ime-state
+ (not (equal current-input-method "W32-IME")))
+;;; (when (= (w32-ime-undetermined-string-length) 0)
+ (ime-force-off nil)
+ (run-hooks 'w32-ime-off-hook)))))))
+
+(defun w32-ime-set-selected-window-buffer-hook (oldbuf newwin newbuf)
+ (w32-ime-sync-state newwin))
+
+(defun w32-ime-select-window-hook (old new)
+ (w32-ime-sync-state new))
+
+(defun w32-ime-mode-line-update ()
+ (cond
+ (w32-ime-show-mode-line
+ (unless (window-minibuffer-p (selected-window))
+ (setq w32-ime-mode-line-state-indicator
+ (nth (if (ime-get-mode) 1 2)
+ w32-ime-mode-line-state-indicator-list))))
+ (t
+ (setq w32-ime-mode-line-state-indicator
+ (nth 0 w32-ime-mode-line-state-indicator-list))))
+ (force-mode-line-update))
+
+(defun w32-ime-init-mode-line-display ()
+ (unless (member 'w32-ime-mode-line-state-indicator mode-line-format)
+ (setq w32-ime-mode-line-format-original
+ (default-value 'mode-line-format))
+ (if (and (stringp (car mode-line-format))
+ (string= (car mode-line-format) "-"))
+ (setq-default mode-line-format
+ (cons ""
+ (cons 'w32-ime-mode-line-state-indicator
+ (cdr mode-line-format))))
+ (setq-default mode-line-format
+ (cons ""
+ (cons 'w32-ime-mode-line-state-indicator
+ mode-line-format))))
+ (force-mode-line-update t)))
+
+(defun w32-ime-initialize ()
+ (when (and (eq system-type 'windows-nt)
+ (eq window-system 'w32)
+ (featurep 'w32-ime))
+ (w32-ime-init-mode-line-display)
+ (w32-ime-mode-line-update)
+ (add-hook 'select-window-functions
+ 'w32-ime-select-window-hook)
+ (add-hook 'set-selected-window-buffer-functions
+ 'w32-ime-set-selected-window-buffer-hook)
+ (define-key global-map [kanji] 'toggle-input-method)))
+;; (set-keyboard-coding-system 'utf-8)))
+
+(defun w32-ime-uninitialize ()
+ (when (and (eq system-type 'windows-nt)
+ (eq window-system 'w32)
+ (featurep 'w32-ime))
+ (setq-default mode-line-format
+ w32-ime-mode-line-format-original)
+ (force-mode-line-update t)
+ (remove-hook 'select-window-functions
+ 'w32-ime-select-window-hook)
+ (remove-hook 'set-selected-window-buffer-functions
+ 'w32-ime-set-selected-window-buffer-hook)
+ (define-key global-map [kanji] 'ignore)))
+
+(defun w32-ime-exit-from-minibuffer ()
+ (deactivate-input-method)
+ (when (<= (minibuffer-depth) 1)
+ (remove-hook 'minibuffer-exit-hook 'w32-ime-exit-from-minibuffer)))
+
+(defun w32-ime-state-switch (&optional arg)
+ (if arg
+ (progn
+ (setq deactivate-current-input-method-function
+ 'w32-ime-state-switch)
+ (run-hooks 'input-method-activate-hook)
+ (run-hooks 'w32-ime-on-hook)
+ (setq describe-current-input-method-function nil)
+ (when (eq (selected-window) (minibuffer-window))
+ (add-hook 'minibuffer-exit-hook 'w32-ime-exit-from-minibuffer))
+ (ime-force-on))
+ (setq current-input-method nil)
+ (run-hooks 'input-method-inactivate-hook)
+ (run-hooks 'w32-ime-off-hook)
+ (setq describe-current-input-method-function nil)
+ (ime-force-off))
+ (w32-ime-mode-line-update))
+
+(register-input-method "W32-IME" "Japanese" 'w32-ime-state-switch ""
+ "W32 System IME")
+
+(provide 'w32-ime)
diff -urN emacs-27.1.orig/lisp/loadup.el emacs-27.1/lisp/loadup.el
--- emacs-27.1.orig/lisp/loadup.el 2020-09-14 14:08:51.443421300 +0900
+++ emacs-27.1/lisp/loadup.el 2020-09-14 16:04:19.226276100 +0900
@@ -285,34 +285,47 @@
(load "emacs-lisp/tabulated-list")
(load "buff-menu")
-(if (fboundp 'x-create-frame)
- (progn
- (load "fringe")
- ;; Needed by `imagemagick-register-types'
- (load "emacs-lisp/regexp-opt")
- (load "image")
- (load "international/fontset")
- (load "dnd")
- (load "tool-bar")))
+(unless (equal (member "bootstrap" command-line-args) '("bootstrap"))
+ (if (fboundp 'x-create-frame)
+ (progn
+ (load "fringe")
+ ;; Needed by `imagemagick-register-types'
+ (load "emacs-lisp/regexp-opt")
+ (load "image")
+ (load "international/fontset")
+ (load "dnd")
+ (load "tool-bar")))
-(if (featurep 'dynamic-setting)
- (load "dynamic-setting"))
+ (if (featurep 'dynamic-setting)
+ (load "dynamic-setting"))
-(if (featurep 'x)
- (progn
- (load "x-dnd")
- (load "term/common-win")
- (load "term/x-win")))
+ (if (featurep 'x)
+ (progn
+ (load "x-dnd")
+ (load "term/common-win")
+ (load "term/x-win")))
-(if (or (eq system-type 'windows-nt)
- (featurep 'w32))
- (progn
- (load "term/common-win")
- (load "w32-vars")
- (load "term/w32-win")
- (load "disp-table")
- (when (eq system-type 'windows-nt)
- (load "w32-fns")
+ (if (or (eq system-type 'windows-nt)
+ (featurep 'w32))
+ (progn
+ (load "term/common-win")
+ (load "w32-vars")
+ (load "term/w32-win")
+ (load "disp-table")
+ (load "international/w32-ime")
+ (when (eq system-type 'windows-nt)
+ (load "w32-fns")
+ (load "ls-lisp")
+ (load "dos-w32"))))
+ (if (eq system-type 'ms-dos)
+ (progn
+ (load "dos-w32")
+ (load "dos-fns")
+ (load "dos-vars")
+ ;; Don't load term/common-win: it isn't appropriate for the `pc'
+ ;; ``window system'', which generally behaves like a terminal.
+ (load "term/internal")
+ (load "term/pc-win")
(load "ls-lisp")
(load "dos-w32"))))
(if (eq system-type 'ms-dos)
diff -urN emacs-27.1.orig/src/config.in emacs-27.1/src/config.in
--- emacs-27.1.orig/src/config.in 2020-09-14 14:08:53.453420800 +0900
+++ emacs-27.1/src/config.in 2020-09-14 16:04:19.230273200 +0900
@@ -102,6 +102,9 @@
#endif
+/* Define to support DOCUMENTFEED. */
+#undef DOCUMENTFEED
+
/* Define if process.c does not need to close a pty to make it a controlling
terminal (it is already a controlling terminal of the subprocess, because
we did ioctl TIOCSCTTY). */
@@ -728,6 +731,9 @@
/* Define to 1 if using ImageMagick7. */
#undef HAVE_IMAGEMAGICK7
+/* Define to 1 if you have IMR_DOCUMENTFEED. */
+#undef HAVE_IMR_DOCUMENTFEED
+
/* Define to 1 to use inotify. */
#undef HAVE_INOTIFY
@@ -1000,6 +1006,9 @@
/* Define to 1 if you have the `realpath' function. */
#undef HAVE_REALPATH
+/* Define to 1 if you have RECONVERTSTRING. */
+#undef HAVE_RECONVERTSTRING
+
/* Define to 1 if you have the `recvfrom' function. */
#undef HAVE_RECVFROM
@@ -1594,6 +1603,9 @@
/* Define to 1 if readlink fails to recognize a trailing slash. */
#undef READLINK_TRAILING_SLASH_BUG
+/* Define to support RECONVERSION. */
+#undef RECONVERSION
+
/* Define REL_ALLOC if you want to use the relocating allocator for buffer
space. */
#undef REL_ALLOC
@@ -1833,6 +1845,9 @@
safe for multithreaded apps. */
#undef USE_UNLOCKED_IO
+/* Define to support W32-IME. */
+#undef USE_W32_IME
+
/* Define to 1 if you have the XCB library and X11-XCB library for mixed
X11/XCB programming. */
#undef USE_XCB
diff -urN emacs-27.1.orig/src/frame.c emacs-27.1/src/frame.c
--- emacs-27.1.orig/src/frame.c 2020-09-14 14:08:53.481421900 +0900
+++ emacs-27.1/src/frame.c 2020-09-14 16:04:19.237283100 +0900
@@ -1367,8 +1367,24 @@
The value of NORECORD is passed as argument to Fselect_window. */
+#ifdef USE_W32_IME
+Lisp_Object
+do_switch_frame_0 (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord);
+Lisp_Object
+do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord)
+{
+ int count = SPECPDL_INDEX ();
+
+ specbind (Qw32_ime_buffer_switch_p, Qnil);
+ do_switch_frame_0 (frame, track, for_deletion, norecord);
+ unbind_to (count, Qnil);
+}
+Lisp_Object
+do_switch_frame_0 (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord)
+#else /* !USE_W32_IME */
Lisp_Object
do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord)
+#endif /* !USE_W32_IME */
{
struct frame *sf = SELECTED_FRAME (), *f;
@@ -3761,6 +3777,9 @@
{"fullscreen", SYMBOL_INDEX (Qfullscreen)},
{"font-backend", SYMBOL_INDEX (Qfont_backend)},
{"alpha", SYMBOL_INDEX (Qalpha)},
+#ifdef USE_W32_IME
+ {"ime-font", SYMBOL_INDEX (Qime_font)},
+#endif /* USE_W32_IME */
{"sticky", SYMBOL_INDEX (Qsticky)},
{"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position)},
{"inhibit-double-buffering", SYMBOL_INDEX (Qinhibit_double_buffering)},
diff -urN emacs-27.1.orig/src/keyboard.c emacs-27.1/src/keyboard.c
--- emacs-27.1.orig/src/keyboard.c 2020-09-14 14:08:53.497422200 +0900
+++ emacs-27.1/src/keyboard.c 2020-09-14 16:04:19.251274200 +0900
@@ -331,6 +331,11 @@
static struct timespec timer_last_idleness_start_time;
+#ifdef USE_W32_IME
+static Lisp_Object IME_command_off_flag;
+static Lisp_Object IME_interrupt_flag;
+#endif /* USE_W32_IME */
+
/* Global variable declarations. */
@@ -1247,6 +1252,14 @@
this_command_key_count = 0;
this_single_command_key_start = 0;
+#ifdef USE_W32_IME
+ if (!NILP (IME_command_off_flag))
+ {
+ Fime_force_on (Qnil);
+ IME_command_off_flag = Qnil;
+ }
+#endif /* USE_W32_IME */
+
if (NILP (Vmemory_full))
{
/* Make sure this hook runs after commands that get errors and
@@ -4594,7 +4607,11 @@
"junja", /* VK_JUNJA 0x17 */
"final", /* VK_FINAL 0x18 */
"kanji", /* VK_KANJI/VK_HANJA 0x19 */
+#ifdef USE_W32_IME
+ "compend", /* VK_COMPEND 0x1A */
+#else /* !USE_W32_IME */
0, /* 0x1A */
+#endif /* !USE_W32_IME */
"escape", /* VK_ESCAPE 0x1B */
"convert", /* VK_CONVERT 0x1C */
"non-convert", /* VK_NONCONVERT 0x1D */
@@ -9305,6 +9322,19 @@
{
ptrdiff_t count = SPECPDL_INDEX ();
+#ifdef USE_W32_IME
+ Lisp_Object IME_command_loop_flag = Qnil;
+ IME_command_off_flag = Qnil;
+ if (!NILP (IME_interrupt_flag))
+ {
+ Lisp_Object func = intern ("sime-inactivate-input-method");
+
+ if (!NILP (Ffboundp (func)))
+ call0 (func);
+ IME_interrupt_flag = Qnil;
+ }
+#endif /* USE_W32_IME */
+
/* How many keys there are in the current key sequence. */
int t;
@@ -9426,6 +9456,12 @@
keybuf[0..mock_input] holds the sequence we should reread. */
replay_sequence:
+#ifdef USE_W32_IME
+ /* If key sequences are to replay, IME_loop_flag should not be set.
+ Because event has never been occured. */
+ IME_command_loop_flag = Qnil;
+#endif /* USE_W32_IME */
+
starting_buffer = current_buffer;
first_unbound = READ_KEY_ELTS + 1;
Lisp_Object first_event = mock_input > 0 ? keybuf[0] : Qnil;
@@ -9508,6 +9544,16 @@
goto replay_sequence;
}
+#ifdef USE_W32_IME
+ if (!NILP (IME_command_loop_flag) && NILP (IME_command_off_flag))
+ {
+ IME_command_off_flag = Fime_get_mode ();
+ if (!NILP (IME_command_off_flag))
+ Fime_force_off (Qnil);
+ }
+ IME_command_loop_flag = Qt;
+#endif /* USE_W32_IME */
+
if (t >= READ_KEY_ELTS)
error ("Key sequence too long");
@@ -9624,6 +9670,10 @@
Just return -1. */
if (EQ (key, Qt))
{
+#ifdef USE_W32_IME
+ if (!NILP (IME_command_off_flag))
+ Fime_force_on (Qnil);
+#endif /* USE_W32_IME */
unbind_to (count, Qnil);
return -1;
}
@@ -10192,6 +10242,11 @@
? Fcommand_remapping (read_key_sequence_cmd, Qnil, Qnil)
: Qnil;
+#ifdef USE_W32_IME
+ if (!NILP (IME_command_off_flag))
+ Fime_force_on (Qnil);
+#endif /* USE_W32_IME */
+
unread_switch_frame = delayed_switch_frame;
unbind_to (count, Qnil);
@@ -10962,6 +11017,10 @@
Vunread_command_events = Qnil;
+#ifdef USE_W32_IME
+ IME_interrupt_flag = Qt;
+#endif /* USE_W32_IME */
+
if (FRAMEP (internal_last_event_frame)
&& !EQ (internal_last_event_frame, selected_frame))
do_switch_frame (make_lispy_switch_frame (internal_last_event_frame),
@@ -11378,6 +11437,10 @@
input_pending = false;
interrupt_input_blocked = 0;
pending_signals = false;
+#ifdef USE_W32_IME
+ IME_command_off_flag = Qnil;
+ IME_interrupt_flag = Qnil;
+#endif /* USE_W32_IME */
/* This means that command_loop_1 won't try to select anything the first
time through. */
diff -urN emacs-27.1.orig/src/w32fns.c emacs-27.1/src/w32fns.c
--- emacs-27.1.orig/src/w32fns.c 2020-09-14 14:08:53.582422800 +0900
+++ emacs-27.1/src/w32fns.c 2020-09-14 16:04:19.273277900 +0900
@@ -73,19 +73,87 @@
#include <imm.h>
#include <windowsx.h>
+#ifdef USE_W32_IME
+#include "fontset.h"
+#include "w32font.h"
+#endif /* USE_W32_IME */
+
#ifndef FOF_NO_CONNECTED_ELEMENTS
#define FOF_NO_CONNECTED_ELEMENTS 0x2000
#endif
+#ifdef IME_UNICODE
+#define __T(x) L ## x
+#define _T(x) __T(x)
+#else
+#define _T(x) x
+#endif
+
+void syms_of_w32fns (void);
+void globals_of_w32fns (void);
+
+extern void free_frame_menubar (struct frame *);
extern int w32_console_toggle_lock_key (int, Lisp_Object);
extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
extern void w32_free_menu_strings (HWND);
extern const char *map_w32_filename (const char *, const char **);
+#if defined (RECONVERSION) || defined (DOCUMENTFEED)
+#ifdef IME_UNICODE
+#define CHRSZ sizeof(short)
+#else
+#define CHRSZ sizeof(char)
+#endif
+#endif
+
+#if defined (RECONVERSION)
+#define RECONV_LENG 100
+#define DOCFEED_LENG 100
+static LRESULT w32_get_ime_reconversion_string (HWND, RECONVERTSTRING*);
+static BOOL w32_perform_reconversion (HWND, RECONVERTSTRING*);
+#endif
+
+#if defined (DOCUMENTFEED)
+#define DOCFEED_CSTR_LENG 64
+static LRESULT w32_get_ime_documentfeed_string (HWND, RECONVERTSTRING*);
+#endif
+
#ifndef IDC_HAND
#define IDC_HAND MAKEINTRESOURCE(32649)
#endif
+#ifdef USE_W32_IME
+static int set_ime_font = 0;
+static LOGFONT ime_logfont = {0};
+static int IME_event_off_count;
+const char * const ImmGetOpenStatus_Name = "ImmGetOpenStatus";
+const char * const ImmSetOpenStatus_Name = "ImmSetOpenStatus";
+const char * const ImmGetConversionStatus_Name = "ImmGetConversionStatus";
+const char * const ImmSetConversionStatus_Name = "ImmSetConversionStatus";
+const char * const ImmNotifyIME_Name = "ImmNotifyIME";
+
+const char * const ImmCreateContext_Name = "ImmCreateContext";
+const char * const ImmDestroyContext_Name = "ImmDestroyContext";
+const char * const ImmAssociateContext_Name = "ImmAssociateContext";
+const char * const ImmGetHotKey_Name = "ImmGetHotKey";
+const char * const ImmGetProperty_Name = "ImmGetProperty";
+#ifdef IME_UNICODE
+const char * const ImmSetCompositionString_Name = "ImmSetCompositionStringW";
+const char * const ImmSetCompositionFont_Name = "ImmSetCompositionFontA"; /* LOGFONTA */
+const char * const ImmGetConversionList_Name = "ImmGetConversionListW";
+const char * const ImmConfigureIME_Name = "ImmConfigureIMEW";
+const char * const ImmGetCandidateList_Name = "ImmGetCandidateListW";
+const char * const ImmGetCandidateListCount_Name = "ImmGetCandidateListCountW";
+#else
+const char * const ImmSetCompositionString_Name = "ImmSetCompositionStringA";
+const char * const ImmSetCompositionFont_Name = "ImmSetCompositionFontA";
+const char * const ImmGetConversionList_Name = "ImmGetConversionListA";
+const char * const ImmConfigureIME_Name = "ImmConfigureIMEA";
+const char * const ImmGetCandidateList_Name = "ImmGetCandidateListA";
+const char * const ImmGetCandidateListCount_Name = "ImmGetCandidateListCountA";
+#endif
+#endif /* USE_W32_IME */
+
/* Prefix for system colors. */
#define SYSTEM_COLOR_PREFIX "System"
#define SYSTEM_COLOR_PREFIX_LEN (sizeof (SYSTEM_COLOR_PREFIX) - 1)
@@ -372,6 +440,17 @@
static void w32_set_icon_name (struct frame *, Lisp_Object, Lisp_Object);
static void w32_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
static void w32_set_title (struct frame *, Lisp_Object, Lisp_Object);
+#ifdef USE_W32_IME
+static void w32_set_ime_conv_window (HWND, struct frame *);
+static void w32_set_ime_status (HWND, int);
+static int w32_get_ime_status (HWND);
+static int w32_set_ime_mode (HWND, int, int);
+void w32_set_ime_logfont (HWND, struct frame *);
+static void w32_set_ime_font (HWND);
+static BOOL w32_get_ime_composition_string (HWND);
+static LRESULT CALLBACK conversion_agent_wndproc (HWND, UINT, WPARAM, LPARAM);
+static int initialize_conversion_agent (void);
+#endif /* USE_W32_IME */
/* Store the screen positions of frame F into XPTR and YPTR.
@@ -4377,9 +4456,18 @@
w32_get_key_modifiers (wParam, lParam));
windows_translate = 1;
break;
+ case VK_PROCESSKEY: /* Generated by IME. */
+#ifdef RECONVERSION
+ if (!w32_get_ime_status (hwnd))
+ {
+ Fime_force_on (Qt);
+ my_post_msg (&wmsg, hwnd, VK_PROCESSKEY, wParam, lParam);
+ windows_translate = -1;
+ break;
+ }
+#endif /* RECONVERSION */
case VK_CONTROL:
case VK_SHIFT:
- case VK_PROCESSKEY: /* Generated by IME. */
windows_translate = 1;
break;
case VK_CANCEL:
@@ -4521,6 +4609,24 @@
TranslateMessage (&windows_msg);
goto dflt;
}
+#ifdef USE_W32_IME
+ else
+ {
+ MSG ime_undo_test_msg;
+
+ if (wParam == VK_BACK
+ && ctrl_modifier == w32_get_key_modifiers (wParam, lParam)
+ && w32_get_ime_status (hwnd) != 0
+ && PeekMessage (&ime_undo_test_msg, hwnd, WM_KEYDOWN, WM_KEYDOWN,
+ PM_NOYIELD | PM_NOREMOVE) != 0
+ && ime_undo_test_msg.wParam == VK_BACK
+ && ime_undo_test_msg.lParam == 0x40000001)
+ {
+ post_character_message (hwnd, msg, wParam, lParam, 0);
+ break;
+ }
+ }
+#endif /* USE_W32_IME */
/* Fall through */
FALLTHROUGH;
@@ -4540,6 +4646,7 @@
w32_get_key_modifiers (wParam, lParam));
break;
+#ifndef USE_W32_IME
case WM_UNICHAR:
/* WM_UNICHAR looks promising from the docs, but the exact
circumstances in which TranslateMessage sends it is one of those
@@ -4664,6 +4771,7 @@
case WM_IME_ENDCOMPOSITION:
ignore_ime_char = 0;
goto dflt;
+#endif /* !USE_W32_IME */
/* Simulate middle mouse button events when left and right buttons
are used together, but only if user has two button mouse. */
@@ -5488,7 +5596,84 @@
my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
return 1;
+#ifdef USE_W32_IME
+ case WM_IME_NOTIFY:
+ if (wParam == IMN_SETOPENSTATUS)
+ {
+ if (w32_get_ime_status (hwnd))
+ {
+ struct frame *f = w32_window_to_frame (dpyinfo, hwnd);
+ if (f)
+ {
+ set_ime_font = 0;
+ w32_set_ime_conv_window (hwnd, f);
+ }
+ }
+ if (!IME_event_off_count)
+ my_post_msg (&wmsg, hwnd, WM_MULE_IME_STATUS, 0, 0);
+ else
+ IME_event_off_count--;
+ }
+ goto dflt;
+
+ case WM_IME_STARTCOMPOSITION:
+ {
+ struct frame *f = w32_window_to_frame (dpyinfo, hwnd);
+ if (f && !set_ime_font)
+ {
+ my_post_msg (&wmsg, hwnd, WM_MULE_IME_SET_FONT, (WPARAM) f, 0);
+ set_ime_font = 1;
+ }
+ }
+ goto dflt;
+
+ case WM_IME_SETCONTEXT:
+ set_ime_font = 0;
+ goto dflt;
+
+ case WM_IME_COMPOSITION:
+ if (lParam & GCS_RESULTSTR)
+ if (w32_get_ime_composition_string (hwnd))
+ return 0;
+ else
+ break;
+ goto dflt;
+
+#ifdef RECONVERSION
+ case WM_IME_REQUEST:
+ if (wParam == IMR_RECONVERTSTRING)
+ {
+ if (!ime_enable_reconversion || !w32_get_ime_status (hwnd))
+ return 0;
+ if (lParam)
+ return w32_get_ime_reconversion_string (hwnd,
+ (RECONVERTSTRING*) lParam);
+ else
+ return sizeof (RECONVERTSTRING) + (RECONV_LENG * 2 + 1) * CHRSZ;
+ }
+#ifdef DOCUMENTFEED
+ else if (wParam == IMR_DOCUMENTFEED)