emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 517c123 3/3: Merge remote-tracking branch 'savannah/


From: Andrea Corallo
Subject: feature/native-comp 517c123 3/3: Merge remote-tracking branch 'savannah/master' into HEAD
Date: Mon, 13 Apr 2020 13:20:49 -0400 (EDT)

branch: feature/native-comp
commit 517c123fd4b250b570ce6f47ead4c14eac41ab8c
Merge: 9787323 cdbb37f
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    Merge remote-tracking branch 'savannah/master' into HEAD
---
 doc/emacs/display.texi              |  9 +++++
 doc/emacs/msdos.texi                | 15 ++++++++
 doc/emacs/sending.texi              | 35 ++++--------------
 doc/lispintro/emacs-lisp-intro.texi |  3 +-
 doc/lispref/processes.texi          |  2 +-
 doc/lispref/text.texi               |  7 ++++
 etc/NEWS                            |  7 ++++
 etc/NEWS.27                         |  4 ++
 lisp/emacs-lisp/cl-macs.el          |  2 +-
 lisp/emacs-lisp/subr-x.el           |  9 +++++
 lisp/gnus/gnus-sum.el               | 14 +++----
 lisp/mail/sendmail.el               |  2 +-
 lisp/progmodes/elisp-mode.el        |  6 +--
 lisp/progmodes/flymake.el           | 65 +++++++++++++++++---------------
 lisp/simple.el                      |  8 +++-
 lisp/vc/ediff-init.el               | 10 -----
 lisp/vc/ediff-mult.el               |  9 ++---
 src/insdel.c                        |  8 +++-
 src/w32fns.c                        | 74 +++++++++++++++++++++++++++++++++++++
 src/w32term.h                       |  3 +-
 src/xfns.c                          |  4 ++
 21 files changed, 207 insertions(+), 89 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 4ecebc7..cbc00ee 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -141,6 +141,15 @@ default face.  This can cause Emacs to scroll to somewhat 
wrong buffer
 positions when the faces in use are not all the same size, even with
 single (i.e., without auto-repeat) scrolling operations.
 
+@vindex jit-lock-defer-time
+As an alternative to setting @code{fast-but-imprecise-scrolling} you
+might prefer to enable jit-lock deferred fontification (@pxref{Font
+Lock}).  To do this, customize @code{jit-lock-defer-time} to a small
+positive number such as 0.25, or even 0.1 if you type quickly.  This
+gives you less jerky scrolling when you hold down @kbd{C-v}, but the
+window contents after any action which scrolls into a fresh portion of
+the buffer will be momentarily unfontified.
+
 @vindex scroll-up
 @vindex scroll-down
 @findex scroll-up-line
diff --git a/doc/emacs/msdos.texi b/doc/emacs/msdos.texi
index 3275fde..48492ab 100644
--- a/doc/emacs/msdos.texi
+++ b/doc/emacs/msdos.texi
@@ -712,6 +712,21 @@ is @code{t}, which means these keys produce @code{AltGr}; 
setting it
 to @code{nil} causes @key{AltGr} or the equivalent key combination to
 be interpreted as the combination of @key{Ctrl} and @key{Meta}
 modifiers.
+
+@cindex IME, MS-Windows
+@findex w32-set-ime-open-status
+  Some versions of MS-Windows, typically East Asian localized Windows,
+enable the Input Method Manager (@acronym{IMM}) that allows
+applications to communicate with the Input Method Editor
+(@acronym{IME}), the native Windows input method service.  Emacs uses
+the @acronym{IME} when available to allow users to input East Asian
+non-@acronym{ASCII} characters, similarly to Emacs's built-in input
+methods (@pxref{Input Methods}).  However, in some situations the
+@acronym{IME} can get in the way if it interprets simple
+@acronym{ASCII} keys you input as part of a key sequence that
+designates a non-@acronym{ASCII} character.  The @acronym{IME} can be
+temporarily turned off and then on again by using the
+@code{w32-set-ime-open-status} function.
 @end ifnottex
 
 @node Windows Mouse
diff --git a/doc/emacs/sending.texi b/doc/emacs/sending.texi
index 190549a..e3f9fbe 100644
--- a/doc/emacs/sending.texi
+++ b/doc/emacs/sending.texi
@@ -32,13 +32,14 @@ In the mail buffer, send the message and bury the buffer
 
   The mail buffer is an ordinary Emacs buffer, so you can switch to
 other buffers while composing the mail.  If you want to send another
-mail before finishing the current one, type @kbd{C-x m} again to open
-a new mail buffer whose name has a different numeric suffix
-(@pxref{Misc Buffer}).  If you invoke the command with a prefix
-argument, @w{@kbd{C-u C-x m}}, Emacs switches back to the last mail
-buffer, and asks if you want to erase the message in that buffer; if
-you answer no, this lets you pick up editing the message where you
-left off.
+message before finishing the current one, type @kbd{C-x m} again to
+open a new mail buffer whose name has a different numeric suffix
+(@pxref{Misc Buffer}).  (This only works if you use the default
+Message mode to compose email; see @ref{Mail Commands}.)  If you know
+that you'd like to continue composing the unsent message you were
+editing, invoke this command with a prefix argument, @w{@kbd{C-u C-x
+m}}, and Emacs will switch to the last mail buffer you used and let
+you pick up editing the message where you left off.
 
 @kindex C-x 4 m
 @findex compose-mail-other-window
@@ -122,26 +123,6 @@ environment variables (@pxref{General Variables}).  If this
 information is unavailable or wrong, you should customize the
 variables yourself (@pxref{Easy Customization}).
 
-@vindex mail-from-style
-  The value of the variable @code{mail-from-style} specifies how to
-format the contents of the @samp{From} field:
-
-@table @asis
-@item @code{nil}
-Use just the address, as in @samp{king@@grassland.com}.
-@item @code{parens}
-Use both address and full name, as in:@*
-@samp{king@@grassland.com (Elvis Parsley)}.
-@item @code{angles}
-Use both address and full name, as in:@*
-@samp{Elvis Parsley <king@@grassland.com>}.
-@item any other value
-Use @code{angles} normally.  But if the address must be quoted to
-remain syntactically valid under the @code{angles} format but not
-under the @code{parens} format, use @code{parens} instead.  This is
-the default.
-@end table
-
   Apart from @samp{From}, here is a table of commonly-used fields:
 
 @table @samp
diff --git a/doc/lispintro/emacs-lisp-intro.texi 
b/doc/lispintro/emacs-lisp-intro.texi
index 9834952..1726936 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -3667,7 +3667,8 @@ automatically undone when the @code{let} is finished.  
The setting
 only affects expressions that are inside the bounds of the @code{let}
 expression.  In computer science jargon, we would say the binding of
 a symbol is visible only in functions called in the @code{let} form;
-in Emacs Lisp, scoping is dynamic, not lexical.
+in Emacs Lisp, the default scoping is dynamic, not lexical.  (The
+non-default lexical binding is not discussed in this manual.)
 
 @code{let} can create more than one variable at once.  Also,
 @code{let} gives each variable it creates an initial value, either a
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 735e9fd..c6e735a 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -2466,7 +2466,7 @@ If non-@code{nil}, try to make an asynchronous connection.
 @item :coding @var{coding}
 Use this to set the coding systems used by the network process, in
 preference to binding @code{coding-system-for-read} or
-@code{coding-system-for-write}.  @xref{Network Processes} for
+@code{coding-system-for-write}.  @xref{Network Processes}, for
 details.
 
 @item :type @var{type}
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index f027cdf..ffdf952 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -5776,4 +5776,11 @@ code that is itself run from a modification hook, then 
rebind locally
 may cause recursive calls to the modification hooks, so be sure to
 prepare for that (for example, by binding some variable which tells
 your hook to do nothing).
+
+We recommend that you only bind this variable for modifications that
+do not result in lasting changes to buffer text contents (for example
+face changes or temporary modifications).  If you need to delay change
+hooks during a series of changes (typically for performance reasons),
+use @code{combine-change-calls} or @code{combine-after-change-calls}
+instead.
 @end defvar
diff --git a/etc/NEWS b/etc/NEWS
index 9f3e5b6..46f59ab 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -379,6 +379,13 @@ coding-system-for-{read,write} or call 
'set-process-coding-system'.
 'module-file-suffix' now has the value ".dylib" on macOS, but the
 ".so" suffix is supported as well.
 
++++
+** On MS-Windows, Emacs can now toggle the IME.
+A new function 'w32-set-ime-open-status' can now be used to disable
+and enable the MS-Windows native Input Method Editor (IME) at run
+time.  A companion function 'w32-get-ime-open-status' returns the
+current IME activation status.
+
 
 ----------------------------------------------------------------------
 This file is part of GNU Emacs.
diff --git a/etc/NEWS.27 b/etc/NEWS.27
index 44a92ec..f4edfaf 100644
--- a/etc/NEWS.27
+++ b/etc/NEWS.27
@@ -2239,6 +2239,10 @@ The option is useful for two reasons when verifying the 
signature:
     2.2.17 to fully benefit from this feature.  See gpg(1) man page for
     "--auto-key-retrieve".
 
++++
+*** The 'mail-from-style' variable is now obsolete.
+According to RFC 5322, only the 'angles' value is valid.
+
 ---
 ** EasyPG
 
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 45a308e..bb10194 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -3118,7 +3118,7 @@ slots skipped by :initial-offset may appear in the list."
               descs)))
     (nreverse descs)))
 
-(define-error 'cl-struct-unknown-slot "struct %S has no slot %S")
+(define-error 'cl-struct-unknown-slot "struct has no slot")
 
 (defun cl-struct-slot-offset (struct-type slot-name)
   "Return the offset of slot SLOT-NAME in STRUCT-TYPE.
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 044c9aa..9f96ac5 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -236,6 +236,15 @@ REGEXP defaults to  \"[ \\t\\n\\r]+\"."
 TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
   (string-trim-left (string-trim-right string trim-right) trim-left))
 
+;;;###autoload
+(defun string-truncate-left (string length)
+  "Truncate STRING to LENGTH, replacing initial surplus with \"...\"."
+  (let ((strlen (length string)))
+    (if (<= strlen length)
+       string
+      (setq length (max 0 (- length 3)))
+      (concat "..." (substring string (max 0 (- strlen 1 length)))))))
+
 (defsubst string-blank-p (string)
   "Check whether STRING is either empty or only whitespace.
 The following characters count as whitespace here: space, tab, newline and
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index a47e657..6f36769 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9494,15 +9494,15 @@ The 1st element is the button named by 
`gnus-collect-urls-primary-text'."
     (delete-dups urls)))
 
 (defun gnus-shorten-url (url max)
-  "Return an excerpt from URL."
+  "Return an excerpt from URL not exceeding MAX characters."
   (if (<= (length url) max)
       url
-    (let ((parsed (url-generic-parse-url url)))
-      (concat (url-host parsed)
-             "..."
-             (substring (url-filename parsed)
-                        (- (length (url-filename parsed))
-                           (max (- max (length (url-host parsed))) 0)))))))
+    (let* ((parsed (url-generic-parse-url url))
+           (host (url-host parsed))
+           (rest (concat (url-filename parsed)
+                         (when-let ((target (url-target parsed)))
+                           (concat "#" target)))))
+      (concat host (string-truncate-left rest (- max (length host)))))))
 
 (defun gnus-summary-browse-url (&optional external)
   "Scan the current article body for links, and offer to browse them.
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 14adb5a..65d598c 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -73,7 +73,7 @@ Otherwise, most addresses look like `angles', but they look 
like
   :version "27.1")
 (make-obsolete-variable
  'mail-from-style
- "only the `angles' value is valid according to RFC2822." "27.1" 'set)
+ "only the `angles' value is valid according to RFC5322." "27.1" 'set)
 
 ;;;###autoload
 (defcustom mail-specify-envelope-from nil
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 20ec370..f85fd77 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -291,9 +291,9 @@ Blank lines separate paragraphs.  Semicolons start comments.
   (unless
       (let* ((bfname (buffer-file-name))
              (fname (and (stringp bfname) (file-name-nondirectory bfname))))
-        (or (not (stringp fname))
-            (string-match "\\`\\.#" fname)
-            (string-equal dir-locals-file fname)))
+        (and (stringp fname)
+             (or (string-match "\\`\\.#" fname)
+                 (string-equal dir-locals-file fname))))
     (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
     (add-hook 'flymake-diagnostic-functions
               #'elisp-flymake-byte-compile nil t)))
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 25a2152..7fca9da 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1321,35 +1321,42 @@ POS can be a buffer position or a button"
    (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))))
 
 (defun flymake--diagnostics-buffer-entries ()
-  (with-current-buffer flymake--diagnostics-buffer-source
-    (cl-loop for diag in
-             (cl-sort (flymake-diagnostics) #'< :key #'flymake-diagnostic-beg)
-             for (line . col) =
-             (save-excursion
-               (goto-char (flymake--diag-beg diag))
-               (cons (line-number-at-pos)
-                     (- (point)
-                        (line-beginning-position))))
-             for type = (flymake--diag-type diag)
-             collect
-             (list (list :diagnostic diag
-                         :line line
-                         :severity (flymake--lookup-type-property
-                                    type
-                                    'severity (warning-numeric-level :error)))
-                   `[,(format "%s" line)
-                     ,(format "%s" col)
-                     ,(propertize (format "%s"
-                                          (flymake--lookup-type-property
-                                           type 'flymake-type-name type))
-                                  'face (flymake--lookup-type-property
-                                         type 'mode-line-face 'flymake-error))
-                     (,(format "%s" (flymake--diag-text diag))
-                      mouse-face highlight
-                      help-echo "mouse-2: visit this diagnostic"
-                      face nil
-                      action flymake-goto-diagnostic
-                      mouse-action flymake-goto-diagnostic)]))))
+  ;; Do nothing if 'flymake--diagnostics-buffer-source' has not yet
+  ;; been set to a valid buffer.  This could happen when this function
+  ;; is called too early.  For example 'global-display-line-numbers-mode'
+  ;; calls us from its mode hook, when the diagnostic buffer has just
+  ;; been created by 'flymake-show-diagnostics-buffer', but is not yet
+  ;; set up properly.
+  (when (bufferp flymake--diagnostics-buffer-source)
+    (with-current-buffer flymake--diagnostics-buffer-source
+      (cl-loop for diag in
+               (cl-sort (flymake-diagnostics) #'< :key 
#'flymake-diagnostic-beg)
+               for (line . col) =
+               (save-excursion
+                 (goto-char (flymake--diag-beg diag))
+                 (cons (line-number-at-pos)
+                       (- (point)
+                          (line-beginning-position))))
+               for type = (flymake--diag-type diag)
+               collect
+               (list (list :diagnostic diag
+                           :line line
+                           :severity (flymake--lookup-type-property
+                                      type
+                                      'severity (warning-numeric-level 
:error)))
+                     `[,(format "%s" line)
+                       ,(format "%s" col)
+                       ,(propertize (format "%s"
+                                            (flymake--lookup-type-property
+                                             type 'flymake-type-name type))
+                                    'face (flymake--lookup-type-property
+                                           type 'mode-line-face 
'flymake-error))
+                       (,(format "%s" (flymake--diag-text diag))
+                        mouse-face highlight
+                        help-echo "mouse-2: visit this diagnostic"
+                        face nil
+                        action flymake-goto-diagnostic
+                        mouse-action flymake-goto-diagnostic)])))))
 
 (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
   "Flymake diagnostics"
diff --git a/lisp/simple.el b/lisp/simple.el
index 91736a6..7c8ac41 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8057,8 +8057,12 @@ OTHER-HEADERS is an alist specifying additional
 header fields.  Elements look like (HEADER . VALUE) where both
 HEADER and VALUE are strings.
 
-CONTINUE, if non-nil, says to continue editing a message already
-being composed.  Interactively, CONTINUE is the prefix argument.
+By default, if an unsent message is already being composed, this
+command will ask whether to erase the unsent message, and will not
+start a new message if the user doesn't allow erasing.  However, if
+CONTINUE is non-nil, it means to continue editing a message already
+being composed without asking.  Interactively, CONTINUE is the prefix
+argument.
 
 SWITCH-FUNCTION, if non-nil, is a function to use to
 switch to and display the buffer used for mail composition.
diff --git a/lisp/vc/ediff-init.el b/lisp/vc/ediff-init.el
index e59d4b5..da6509b 100644
--- a/lisp/vc/ediff-init.el
+++ b/lisp/vc/ediff-init.el
@@ -1510,16 +1510,6 @@ This default should work without changes."
        (setq dir (substring dir 0 pos)))
     (ediff-abbreviate-file-name (file-name-directory dir))))
 
-(defun ediff-truncate-string-left (str newlen)
-  ;; leave space for ... on the left
-  (let ((len (length str))
-       substr)
-    (if (<= len newlen)
-       str
-      (setq newlen (max 0 (- newlen 3)))
-      (setq substr (substring str (max 0 (- len 1 newlen))))
-      (concat "..." substr))))
-
 (defsubst ediff-nonempty-string-p (string)
   (and (stringp string) (not (string= string ""))))
 
diff --git a/lisp/vc/ediff-mult.el b/lisp/vc/ediff-mult.el
index fee87e8..2b1b079 100644
--- a/lisp/vc/ediff-mult.el
+++ b/lisp/vc/ediff-mult.el
@@ -113,7 +113,6 @@
 (require 'ediff-wind)
 (require 'ediff-util)
 
-
 ;; meta-buffer
 (ediff-defvar-local ediff-meta-buffer nil "")
 (ediff-defvar-local ediff-parent-meta-buffer nil "")
@@ -1172,7 +1171,7 @@ behavior."
          ;; abbreviate the file name, if file exists
          (if (and (not (stringp fname)) (< file-size -1))
              "-------"         ; file doesn't exist
-           (ediff-truncate-string-left
+           (string-truncate-left
             (ediff-abbreviate-file-name fname)
             max-filename-width)))))))
 
@@ -1266,7 +1265,7 @@ Useful commands:
        (if (= (mod membership-code ediff-membership-code1) 0) ; dir1
            (let ((beg (point)))
              (insert (format "%-27s"
-                             (ediff-truncate-string-left
+                             (string-truncate-left
                               (ediff-abbreviate-file-name
                                (if (file-directory-p (concat dir1 file))
                                    (file-name-as-directory file)
@@ -1281,7 +1280,7 @@ Useful commands:
        (if (= (mod membership-code ediff-membership-code2) 0) ; dir2
            (let ((beg (point)))
              (insert (format "%-26s"
-                             (ediff-truncate-string-left
+                             (string-truncate-left
                               (ediff-abbreviate-file-name
                                (if (file-directory-p (concat dir2 file))
                                    (file-name-as-directory file)
@@ -1295,7 +1294,7 @@ Useful commands:
            (if (= (mod membership-code ediff-membership-code3) 0) ; dir3
                (let ((beg (point)))
                  (insert (format " %-25s"
-                                 (ediff-truncate-string-left
+                                 (string-truncate-left
                                   (ediff-abbreviate-file-name
                                    (if (file-directory-p (concat dir3 file))
                                        (file-name-as-directory file)
diff --git a/src/insdel.c b/src/insdel.c
index 21acf0e..dfa1cc3 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -2397,7 +2397,13 @@ This affects `before-change-functions' and 
`after-change-functions',
 as well as hooks attached to text properties and overlays.
 Setting this variable non-nil also inhibits file locks and checks
 whether files are locked by another Emacs session, as well as
-handling of the active region per `select-active-regions'.  */);
+handling of the active region per `select-active-regions'.
+
+To delay change hooks during a series of changes, use
+`combine-change-calls' or `combine-after-change-calls' instead of
+binding this variable.
+
+See also the info node `(elisp) Change Hooks'.  */);
   inhibit_modification_hooks = 0;
   DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks");
 
diff --git a/src/w32fns.c b/src/w32fns.c
index 8d714f0..4f7cbed 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -166,6 +166,10 @@ typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND 
window);
 typedef BOOL (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
 typedef BOOL (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
                                                      IN COMPOSITIONFORM *form);
+/* For toggling IME status.  */
+typedef BOOL (WINAPI * ImmGetOpenStatus_Proc) (IN HIMC);
+typedef BOOL (WINAPI * ImmSetOpenStatus_Proc) (IN HIMC, IN BOOL);
+
 typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD 
flags);
 typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
@@ -185,6 +189,8 @@ typedef HRESULT (WINAPI *SetThreadDescription_Proc)
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
 ImmGetContext_Proc get_ime_context_fn = NULL;
+ImmGetOpenStatus_Proc get_ime_open_status_fn = NULL;
+ImmSetOpenStatus_Proc set_ime_open_status_fn = NULL;
 ImmReleaseContext_Proc release_ime_context_fn = NULL;
 ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
 MonitorFromPoint_Proc monitor_from_point_fn = NULL;
@@ -3305,6 +3311,7 @@ w32_name_of_message (UINT msg)
       M (WM_EMACS_SETCURSOR),
       M (WM_EMACS_SHOWCURSOR),
       M (WM_EMACS_PAINT),
+      M (WM_EMACS_IME_STATUS),
       M (WM_CHAR),
 #undef M
       { 0, 0 }
@@ -3442,6 +3449,21 @@ w32_msg_pump (deferred_msg * msg_buf)
                  emacs_abort ();
              }
              break;
+            case WM_EMACS_IME_STATUS:
+             {
+               focus_window = GetFocus ();
+               if (!set_ime_open_status_fn || !focus_window)
+                 break;
+
+               HIMC context = get_ime_context_fn (focus_window);
+               if (!context)
+                 break;
+
+               set_ime_open_status_fn (context, msg.wParam != 0);
+               release_ime_context_fn (focus_window, context);
+               break;
+             }
+
 #ifdef MSG_DEBUG
              /* Broadcast messages make it here, so you need to be looking
                 for something in particular for this to be useful.  */
@@ -10218,6 +10240,51 @@ DEFUN ("w32-notification-close",
 
 #endif /* WINDOWSNT && !HAVE_DBUS */
 
+DEFUN ("w32-get-ime-open-status",
+       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
+       0, 0, 0,
+       doc: /* Return non-nil if IME is active, otherwise return nil.
+
+IME, the MS-Windows Input Method Editor, can be active or inactive.
+This function returns non-nil if the IME is active, otherwise nil.  */)
+  (void)
+{
+  struct frame *sf =
+    FRAMEP (selected_frame) && FRAME_LIVE_P (XFRAME (selected_frame))
+    ? XFRAME  (selected_frame)
+    : NULL;
+
+  if (sf)
+    {
+      HWND current_window = FRAME_W32_WINDOW (sf);
+      HIMC context = get_ime_context_fn (current_window);
+      if (context)
+       {
+         BOOL retval = get_ime_open_status_fn (context);
+         release_ime_context_fn (current_window, context);
+
+         return retval ? Qt : Qnil;
+       }
+    }
+
+  return Qnil;
+}
+
+DEFUN ("w32-set-ime-open-status",
+       Fw32_set_ime_open_status, Sw32_set_ime_open_status,
+       1, 1, 0,
+       doc: /* Open or close the IME according to STATUS.
+
+This function activates the IME, the MS-Windows Input Method Editor,
+if STATUS is non-nil, otherwise it deactivates the IME.  */)
+  (Lisp_Object status)
+{
+  unsigned ime_status = NILP (status) ? 0 : 1;
+
+  PostThreadMessage (dwWindowsThreadId, WM_EMACS_IME_STATUS, ime_status, 0);
+  return Qnil;
+}
+
 
 #ifdef WINDOWSNT
 /***********************************************************************
@@ -10744,6 +10811,8 @@ tip frame.  */);
   defsubr (&Sw32_notification_notify);
   defsubr (&Sw32_notification_close);
 #endif
+  defsubr (&Sw32_get_ime_open_status);
+  defsubr (&Sw32_set_ime_open_status);
 
 #ifdef WINDOWSNT
   defsubr (&Sw32_read_registry);
@@ -11032,6 +11101,11 @@ globals_of_w32fns (void)
       get_proc_addr (imm32_lib, "ImmReleaseContext");
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
       get_proc_addr (imm32_lib, "ImmSetCompositionWindow");
+
+    get_ime_open_status_fn = (ImmGetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmGetOpenStatus");
+    set_ime_open_status_fn = (ImmSetOpenStatus_Proc)
+      get_proc_addr (imm32_lib, "ImmSetOpenStatus");
   }
 
   HMODULE hm_kernel32 = GetModuleHandle ("kernel32.dll");
diff --git a/src/w32term.h b/src/w32term.h
index f8a8a72..4e9234f 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -670,7 +670,8 @@ do { \
 #define WM_EMACS_BRINGTOTOP            (WM_EMACS_START + 23)
 #define WM_EMACS_INPUT_READY           (WM_EMACS_START + 24)
 #define WM_EMACS_FILENOTIFY            (WM_EMACS_START + 25)
-#define WM_EMACS_END                   (WM_EMACS_START + 26)
+#define WM_EMACS_IME_STATUS            (WM_EMACS_START + 26)
+#define WM_EMACS_END                   (WM_EMACS_START + 27)
 
 #define WND_FONTWIDTH_INDEX    (0)
 #define WND_LINEHEIGHT_INDEX   (4)
diff --git a/src/xfns.c b/src/xfns.c
index 10e1b5e..1f381e2 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -7747,6 +7747,7 @@ Note: Text drawn with the `x' font backend is shown with 
hollow boxes.  */)
 
 #ifdef USE_GTK
 #ifdef HAVE_GTK3
+#if GTK_CHECK_VERSION (3, 14, 0)
 DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1, 0,
        doc: /* Toggle interactive GTK debugging.   */)
   (Lisp_Object enable)
@@ -7759,6 +7760,7 @@ DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1, 0,
 
   return NILP (enable) ? Qnil : Qt;
 }
+#endif /* GTK_CHECK_VERSION (3, 14, 0) */
 #endif /* HAVE_GTK3 */
 #endif /* USE_GTK */
 
@@ -8146,7 +8148,9 @@ eliminated in future versions of Emacs.  */);
 #endif
 #ifdef USE_GTK
 #ifdef HAVE_GTK3
+#if GTK_CHECK_VERSION (3, 14, 0)
   defsubr (&Sx_gtk_debug);
 #endif
 #endif
+#endif
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]