emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 6dc9a3eeb75: Merge remote-tracking branch 'origin/master


From: Po Lu
Subject: feature/android 6dc9a3eeb75: Merge remote-tracking branch 'origin/master' into feature/android
Date: Mon, 22 May 2023 09:00:51 -0400 (EDT)

branch: feature/android
commit 6dc9a3eeb755b5b0047b39f2bd7ebdefb10a1dc4
Merge: d341adadc8a 438b1205c54
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge remote-tracking branch 'origin/master' into feature/android
---
 etc/ERC-NEWS                                    |   4 +-
 lisp/erc/erc-join.el                            |   9 +-
 lisp/erc/erc-netsplit.el                        |   4 +-
 src/image.c                                     |  14 ++-
 src/xfns.c                                      |  56 ++++-----
 src/xterm.c                                     | 156 ++++++++++++++++--------
 src/xterm.h                                     |  11 +-
 test/lisp/erc/resources/erc-scenarios-common.el |   2 +-
 test/lisp/filenotify-tests.el                   |   2 +-
 9 files changed, 160 insertions(+), 98 deletions(-)

diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 1aa445c5b9c..d257bdcbf51 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -366,8 +366,8 @@ In an effort to help further tame ERC's complexity, the 
variable
 'erc-default-recipients' is now expected to hold but a single target.
 As a consequence, functions like 'erc-add-default-channel' that
 imagine an alternate, aspirational model of buffer-target relations
-have been deprecated.  Grep for their names in ChangeLog.4 for
-details.
+have been deprecated.  For specifics, see entries in Emacs'
+ChangeLog.4 from around June 30, 2022.
 
 A number of less consequential deprecations also debut in this
 release.  For example, the function 'erc-auto-query' was deemed too
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index 17104da1a8b..45cfd565f89 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -78,10 +78,11 @@ keeps track of what channels you are on, and will join them
 again when you get disconnected.  When you restart Emacs, however,
 those changes are lost, and the customization you saved the last
 time is used again."
-  :type '(repeat (cons :tag "Server"
-                      (regexp :tag "Name")
-                      (repeat :tag "Channels"
-                              (string :tag "Name")))))
+  :type '(alist :options (Libera.Chat)
+                :key-type (choice :tag "Server"
+                                  (symbol :tag "Network")
+                                  (regexp :tag "Host or domain"))
+                :value-type (repeat :tag "Channels" (string :tag "Name"))))
 
 (defcustom erc-autojoin-timing 'connect
   "When ERC should attempt to autojoin a channel.
diff --git a/lisp/erc/erc-netsplit.el b/lisp/erc/erc-netsplit.el
index f3572014f27..5dd11ab1869 100644
--- a/lisp/erc/erc-netsplit.el
+++ b/lisp/erc/erc-netsplit.el
@@ -117,7 +117,9 @@ join from that split has been detected or not.")
                   parsed 'notice (process-buffer proc)
                   'netjoin-done ?s (car elt))
                  (setq erc-netsplit-list (delq elt erc-netsplit-list)))
-             (delete nick elt))
+              ;; Avoid `ignored-return-value' warning for `delete'.
+              (let ((tail (nthcdr 2 elt))) ; (t n1 ... nN)
+                (setcdr tail (delete nick (cdr tail)))))
            (setq no-next-hook t))))
     no-next-hook))
 
diff --git a/src/image.c b/src/image.c
index 689ff882728..7501838d8c4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -958,9 +958,17 @@ static void
 free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm)
 {
 #ifdef HAVE_X_WINDOWS
-  XFreePixmap (dpyinfo->display, bm->pixmap);
-  if (bm->have_mask)
-    XFreePixmap (dpyinfo->display, bm->mask);
+  /* Free the pixmap and mask.  Only do this if DPYINFO->display is
+     still set, which may not be the case if the connection has
+     already been closed in response to an IO error.  */
+
+  if (dpyinfo->display)
+    {
+      XFreePixmap (dpyinfo->display, bm->pixmap);
+      if (bm->have_mask)
+       XFreePixmap (dpyinfo->display, bm->mask);
+    }
+
 #ifdef USE_CAIRO
   if (bm->stipple)
     cairo_pattern_destroy (bm->stipple);
diff --git a/src/xfns.c b/src/xfns.c
index b7000462e84..057d0436ebe 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4252,9 +4252,9 @@ x_window (struct frame *f, long window_prompting)
 
 #ifdef HAVE_X_I18N
   FRAME_XIC (f) = NULL;
-  if (use_xim)
+  if (FRAME_DISPLAY_INFO (f)->use_xim)
     create_frame_xic (f);
-#endif
+#endif /* HAVE_X_I18N */
 
   f->output_data.x->wm_hints.input = True;
   f->output_data.x->wm_hints.flags |= InputHint;
@@ -4355,32 +4355,32 @@ x_window (struct frame *f)
 
 #ifdef HAVE_X_I18N
   FRAME_XIC (f) = NULL;
-  if (use_xim)
-  {
-    block_input ();
-    create_frame_xic (f);
-    if (FRAME_XIC (f))
-      {
-       /* XIM server might require some X events. */
-       unsigned long fevent = NoEventMask;
-       XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
+  if (FRAME_DISPLAY_INFO (f)->use_xim)
+    {
+      block_input ();
+      create_frame_xic (f);
+      if (FRAME_XIC (f))
+       {
+         /* XIM server might require some X events. */
+         unsigned long fevent = NoEventMask;
+         XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
 
-       if (fevent != NoEventMask)
-         {
-           XSetWindowAttributes attributes;
-           XWindowAttributes wattr;
-           unsigned long attribute_mask;
-
-           XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                                 &wattr);
-           attributes.event_mask = wattr.your_event_mask | fevent;
-           attribute_mask = CWEventMask;
-           XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                                    attribute_mask, &attributes);
-         }
-      }
-    unblock_input ();
-  }
+         if (fevent != NoEventMask)
+           {
+             XSetWindowAttributes attributes;
+             XWindowAttributes wattr;
+             unsigned long attribute_mask;
+
+             XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                   &wattr);
+             attributes.event_mask = wattr.your_event_mask | fevent;
+             attribute_mask = CWEventMask;
+             XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                                      attribute_mask, &attributes);
+           }
+       }
+      unblock_input ();
+    }
 #endif
 
   append_wm_protocols (FRAME_DISPLAY_INFO (f), f);
@@ -4427,7 +4427,7 @@ x_window (struct frame *f)
   initial_set_up_x_back_buffer (f);
 
 #ifdef HAVE_X_I18N
-  if (use_xim)
+  if (FRAME_DISPLAY_INFO (f)->use_xim)
     {
       create_frame_xic (f);
       if (FRAME_XIC (f))
diff --git a/src/xterm.c b/src/xterm.c
index 111e4ede2c2..37fabc15e3a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -798,13 +798,6 @@ typedef int (*Emacs_XIOErrorHandler) (Display *);
 #define USE_CAIRO_XCB_SURFACE
 #endif
 
-/* Default to using XIM if available.  */
-#ifdef USE_XIM
-bool use_xim = true;
-#else
-bool use_xim = false;  /* configure --without-xim */
-#endif
-
 #if XCB_SHAPE_MAJOR_VERSION > 1              \
   || (XCB_SHAPE_MAJOR_VERSION == 1 && \
       XCB_SHAPE_MINOR_VERSION >= 1)
@@ -26702,7 +26695,12 @@ xim_destroy_callback (XIM xim, XPointer client_data, 
XPointer call_data)
 
   /* No need to call XCloseIM.  */
   dpyinfo->xim = NULL;
-  XFree (dpyinfo->xim_styles);
+
+  /* Also free IM values; those are allocated separately upon
+     XGetIMValues.  */
+  if (dpyinfo->xim_styles)
+    XFree (dpyinfo->xim_styles);
+  dpyinfo->xim_styles = NULL;
   unblock_input ();
 }
 
@@ -26720,10 +26718,20 @@ xim_open_dpy (struct x_display_info *dpyinfo, char 
*resource_name)
   XIM xim;
   const char *locale;
 
-  if (use_xim)
+  if (dpyinfo->use_xim)
     {
       if (dpyinfo->xim)
-       XCloseIM (dpyinfo->xim);
+       {
+         XCloseIM (dpyinfo->xim);
+
+         /* Free values left over from the last time the IM
+            connection was established.  */
+
+         if (dpyinfo->xim_styles)
+           XFree (dpyinfo->xim_styles);
+         dpyinfo->xim_styles = NULL;
+       }
+
       xim = XOpenIM (dpyinfo->display, dpyinfo->rdb, resource_name,
                     emacs_class);
       dpyinfo->xim = xim;
@@ -26752,7 +26760,6 @@ xim_open_dpy (struct x_display_info *dpyinfo, char 
*resource_name)
                                            build_string (locale));
        }
     }
-
   else
 #endif /* HAVE_XIM */
     dpyinfo->xim = NULL;
@@ -26821,7 +26828,7 @@ xim_initialize (struct x_display_info *dpyinfo, char 
*resource_name)
 {
   dpyinfo->xim = NULL;
 #ifdef HAVE_XIM
-  if (use_xim)
+  if (dpyinfo->use_xim)
     {
 #ifdef HAVE_X11R6_XIM
       struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
@@ -26830,15 +26837,19 @@ xim_initialize (struct x_display_info *dpyinfo, char 
*resource_name)
       dpyinfo->xim_callback_data = xim_inst;
       xim_inst->dpyinfo = dpyinfo;
       xim_inst->resource_name = xstrdup (resource_name);
-      ret = XRegisterIMInstantiateCallback
-       (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
-        emacs_class, xim_instantiate_callback,
-        /* This is XPointer in XFree86 but (XPointer *) on Tru64, at
-           least, but the configure test doesn't work because
-           xim_instantiate_callback can either be XIMProc or
-           XIDProc, so just cast to void *.  */
-        (void *) xim_inst);
-      eassert (ret == True);
+
+      /* The last argument is XPointer in XFree86 but (XPointer *) on
+        Tru64, at least, but the configure test doesn't work because
+        xim_instantiate_callback can either be XIMProc or XIDProc, so
+        just cast to void *.  */
+
+      ret = XRegisterIMInstantiateCallback (dpyinfo->display,
+                                           dpyinfo->rdb,
+                                           xim_inst->resource_name,
+                                           emacs_class,
+                                           xim_instantiate_callback,
+                                           (void *) xim_inst);
+      eassert (ret);
 #else /* not HAVE_X11R6_XIM */
       xim_open_dpy (dpyinfo, resource_name);
 #endif /* not HAVE_X11R6_XIM */
@@ -26847,32 +26858,56 @@ xim_initialize (struct x_display_info *dpyinfo, char 
*resource_name)
 }
 
 
-/* Close the connection to the XIM server on display DPYINFO. */
+/* Close the connection to the XIM server on display DPYINFO.
+   Unregister any IM instantiation callback previously installed,
+   close the connection to the IM server if possible, and free any
+   retrieved IM values.  */
 
 static void
 xim_close_dpy (struct x_display_info *dpyinfo)
 {
 #ifdef HAVE_XIM
-  if (use_xim)
-    {
 #ifdef HAVE_X11R6_XIM
-      struct xim_inst_t *xim_inst = dpyinfo->xim_callback_data;
+  struct xim_inst_t *xim_inst;
+  Bool rc;
+
+  /* If dpyinfo->xim_callback_data is not set, then IM support wasn't
+     initialized, which can happen if Xlib doesn't understand the C
+     locale being used.  */
+
+  if (dpyinfo->xim_callback_data)
+    {
+      xim_inst = dpyinfo->xim_callback_data;
 
       if (dpyinfo->display)
        {
-         Bool ret = XUnregisterIMInstantiateCallback
-           (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
-            emacs_class, xim_instantiate_callback, (void *) xim_inst);
-         eassert (ret == True);
+         rc = XUnregisterIMInstantiateCallback (dpyinfo->display,
+                                                dpyinfo->rdb,
+                                                xim_inst->resource_name,
+                                                emacs_class,
+                                                xim_instantiate_callback,
+                                                (void *) xim_inst);
+         eassert (rc);
        }
+
       xfree (xim_inst->resource_name);
       xfree (xim_inst);
-#endif /* HAVE_X11R6_XIM */
-      if (dpyinfo->display)
-       XCloseIM (dpyinfo->xim);
-      dpyinfo->xim = NULL;
-      XFree (dpyinfo->xim_styles);
     }
+#endif /* HAVE_X11R6_XIM */
+
+  /* Now close the connection to the input method server.  This may
+     access the display connection, and isn't safe if the display has
+     already been closed.  */
+
+  if (dpyinfo->display && dpyinfo->xim)
+    XCloseIM (dpyinfo->xim);
+  dpyinfo->xim = NULL;
+
+  /* Free the list of XIM styles retrieved.  */
+
+  if (dpyinfo->xim_styles)
+    XFree (dpyinfo->xim_styles);
+  dpyinfo->xim_styles = NULL;
 #endif /* HAVE_XIM */
 }
 
@@ -30825,14 +30860,6 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   dpyinfo->fixes_pointer_blanking = (egetenv ("EMACS_XFIXES") != NULL);
 #endif
 
-#ifdef HAVE_X_I18N
-  /* Avoid initializing input methods if the X library does not
-     support Emacs's locale.  When the current locale is not
-     supported, decoding input method strings becomes undefined.  */
-  if (XSupportsLocale ())
-    xim_initialize (dpyinfo, resource_name);
-#endif
-
   xsettings_initialize (dpyinfo);
 
   /* This is only needed for distinguishing keyboard and process input.  */
@@ -30891,25 +30918,33 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
       XSynchronize (dpyinfo->display, True);
   }
 
+#ifdef HAVE_X_I18N
   {
     AUTO_STRING (useXIM, "useXIM");
     AUTO_STRING (UseXIM, "UseXIM");
     Lisp_Object value = gui_display_get_resource (dpyinfo, useXIM, UseXIM,
                                                   Qnil, Qnil);
+
+    /* `USE_XIM' controls whether Emacs should use X input methods by
+       default, not whether or not XIM is available.  */
+
 #ifdef USE_XIM
+    dpyinfo->use_xim = true;
+
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "false")
            || !strcmp (SSDATA (value), "off")))
-      use_xim = false;
-#else
+      dpyinfo->use_xim = false;
+#else /* !USE_XIM */
+    dpyinfo->use_xim = false;
+
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "true")
            || !strcmp (SSDATA (value), "on")))
-      use_xim = true;
-#endif
+      dpyinfo->use_xim = true;
+#endif /* USE_XIM */
   }
 
-#ifdef HAVE_X_I18N
   {
     AUTO_STRING (inputStyle, "inputStyle");
     AUTO_STRING (InputStyle, "InputStyle");
@@ -30931,10 +30966,19 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 #ifdef USE_GTK
        else if (!strcmp (SSDATA (value), "native"))
          dpyinfo->prefer_native_input = true;
-#endif
+#endif /* HAVE_GTK */
       }
   }
-#endif
+
+  /* Now that defaults have been set up, initialize input method
+     support.  */
+
+  /* Avoid initializing input methods if the X library does not
+     support Emacs's locale.  When the current locale is not
+     supported, decoding input method strings becomes undefined.  */
+  if (XSupportsLocale ())
+    xim_initialize (dpyinfo, resource_name);
+#endif /* HAVE_X_I18N */
 
 #ifdef HAVE_X_SM
   /* Only do this for the very first display in the Emacs session.
@@ -31327,14 +31371,22 @@ x_delete_terminal (struct terminal *terminal)
 #ifdef HAVE_X_I18N
   /* We must close our connection to the XIM server before closing the
      X display.  */
-  if (dpyinfo->xim)
-    xim_close_dpy (dpyinfo);
+  xim_close_dpy (dpyinfo);
 #endif
 
+  /* Destroy all bitmap images created on the display.  */
+  image_destroy_all_bitmaps (dpyinfo);
+
+  /* Free the storage allocated to hold bitmap records.  */
+  xfree (dpyinfo->bitmaps);
+
+  /* In case someone decides to use `bitmaps' again... */
+  dpyinfo->bitmaps = NULL;
+  dpyinfo->bitmaps_last = 0;
+
   /* Normally, the display is available...  */
   if (dpyinfo->display)
     {
-      image_destroy_all_bitmaps (dpyinfo);
       XSetCloseDownMode (dpyinfo->display, DestroyAll);
 
       /* Delete the scratch cursor GC, should it exist.  */
diff --git a/src/xterm.h b/src/xterm.h
index 406a7c5c060..e7171ba072f 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -649,7 +649,11 @@ struct x_display_info
 
   /* The named coding system to use for this input method.  */
   Lisp_Object xim_coding;
-#endif
+
+  /* Whether or not X input methods should be used on this
+     display.  */
+  bool use_xim;
+#endif /* HAVE_X_I18N */
 
   /* A cache mapping color names to RGB values.  */
   struct color_name_cache_entry **color_names;
@@ -929,11 +933,6 @@ struct x_display_info
   Time quit_keysym_time;
 };
 
-#ifdef HAVE_X_I18N
-/* Whether or not to use XIM if we have it.  */
-extern bool use_xim;
-#endif
-
 #ifdef HAVE_XINPUT2
 /* Defined in xmenu.c. */
 extern int popup_activated_flag;
diff --git a/test/lisp/erc/resources/erc-scenarios-common.el 
b/test/lisp/erc/resources/erc-scenarios-common.el
index f259c88594b..32e7556d602 100644
--- a/test/lisp/erc/resources/erc-scenarios-common.el
+++ b/test/lisp/erc/resources/erc-scenarios-common.el
@@ -51,7 +51,7 @@
 ;; argument, a `let*'-style VAR-LIST.  Relying on such a macro is
 ;; unfortunate because in many ways it actually hampers readability by
 ;; favoring magic over verbosity.  But without it (or something
-;; similar), any failing test would cause all subsequent tests in this
+;; similar), any failing test would cause all subsequent tests in a
 ;; file to fail like dominoes (making all but the first backtrace
 ;; useless).
 ;;
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index bc094345ffe..97b7c46c689 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -1032,7 +1032,7 @@ delivered."
       (file-notify--test-cleanup))))
 
 (file-notify--deftest-remote file-notify-test04-autorevert
-  "Check autorevert via file notification for remote files.")
+  "Check autorevert via file notification for remote files." t)
 
 (ert-deftest file-notify-test05-file-validity ()
   "Check `file-notify-valid-p' for files."



reply via email to

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