emacs-diffs
[Top][All Lists]
Advanced

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

master ee4b6a4a2d6: Update Android port


From: Po Lu
Subject: master ee4b6a4a2d6: Update Android port
Date: Fri, 15 Sep 2023 22:39:06 -0400 (EDT)

branch: master
commit ee4b6a4a2d6b2779cdcf662938b5c81dc2fd2bef
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Update Android port
    
    * java/org/gnu/emacs/EmacsContextMenu.java (display): Return
    false if the list of menu buttons is empty, lest Android cease
    displaying menus on the assumption that Emacs is defective.
    
    * java/org/gnu/emacs/EmacsView.java (popupMenu): Likewise.
    
    * src/fns.c (sort_list): Render sentence motion commands
    functional within commentary
    
    * src/sfntfont.c (sfntfont_list_family): Sort and deduplicate
    the returned family list and make it a list of symbols.
    (syms_of_sfntfont) <Qstring_lessp>: New defsym.
---
 java/org/gnu/emacs/EmacsContextMenu.java |  7 +++++++
 java/org/gnu/emacs/EmacsView.java        |  7 +++++++
 src/fns.c                                |  6 +++---
 src/sfntfont.c                           | 32 +++++++++++++++++++++++++++++---
 4 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/java/org/gnu/emacs/EmacsContextMenu.java 
b/java/org/gnu/emacs/EmacsContextMenu.java
index c5b87aa804a..c415ba59c79 100644
--- a/java/org/gnu/emacs/EmacsContextMenu.java
+++ b/java/org/gnu/emacs/EmacsContextMenu.java
@@ -347,6 +347,13 @@ public final class EmacsContextMenu
     Runnable runnable;
     final EmacsHolder<Boolean> rc;
 
+    /* Android will permanently cease to display any popup menus at
+       all if the list of menu items is empty.  Prevent this by
+       promptly returning if there are no menu items.  */
+
+    if (menuItems.isEmpty ())
+      return false;
+
     rc = new EmacsHolder<Boolean> ();
     rc.thing = false;
 
diff --git a/java/org/gnu/emacs/EmacsView.java 
b/java/org/gnu/emacs/EmacsView.java
index 04c3d824027..0f83af882ae 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -622,6 +622,13 @@ public final class EmacsView extends ViewGroup
     if (popupActive && !force)
       return false;
 
+    /* Android will permanently cease to display any popup menus at
+       all if the list of menu items is empty.  Prevent this by
+       promptly returning if there are no menu items.  */
+
+    if (menu.menuItems.isEmpty ())
+      return false;
+
     contextMenu = menu;
     popupActive = true;
 
diff --git a/src/fns.c b/src/fns.c
index bd1d63a58c4..4731e416125 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2334,9 +2334,9 @@ See also the function `nreverse', which is used more 
often.  */)
 
 
 /* Stably sort LIST ordered by PREDICATE using the TIMSORT
-   algorithm. This converts the list to a vector, sorts the vector,
-   and returns the result converted back to a list.  The input list is
-   destructively reused to hold the sorted result.  */
+   algorithm.  This converts the list to a vector, sorts the vector,
+   and returns the result converted back to a list.  The input list
+   is destructively reused to hold the sorted result.  */
 
 static Lisp_Object
 sort_list (Lisp_Object list, Lisp_Object predicate)
diff --git a/src/sfntfont.c b/src/sfntfont.c
index d6dfa8b6f0d..0696b66d244 100644
--- a/src/sfntfont.c
+++ b/src/sfntfont.c
@@ -3646,8 +3646,9 @@ sfntfont_draw (struct glyph_string *s, int from, int to,
 Lisp_Object
 sfntfont_list_family (struct frame *f)
 {
-  Lisp_Object families;
+  Lisp_Object families, tem, next;
   struct sfnt_font_desc *desc;
+  unsigned short count;
 
   families = Qnil;
 
@@ -3655,8 +3656,30 @@ sfntfont_list_family (struct frame *f)
     /* Add desc->family to the list.  */
     families = Fcons (desc->family, families);
 
-  /* Not sure if deleting duplicates is worth it.  Is this ever
-     called? */
+  /* Sort families in preparation for removing duplicates.  */
+  families = Fsort (families, Qstring_lessp);
+
+  /* Remove each duplicate within families.  */
+
+  tem = families;
+  while (!NILP (tem) && !NILP ((next = XCDR (tem))))
+    {
+      /* If the two strings are equal.  */
+      if (!NILP (Fstring_equal (XCAR (tem), XCAR (next))))
+       /* Set tem's cdr to the cons after the next item.  */
+       XSETCDR (tem, XCDR (next));
+      else
+       /* Otherwise, start considering the next item.  */
+       tem = next;
+    }
+
+  /* Intern each font family.  */
+
+  tem = families;
+
+  FOR_EACH_TAIL (tem)
+    XSETCAR (tem, Fintern (XCAR (tem), Qnil));
+
   return families;
 }
 
@@ -3962,6 +3985,9 @@ syms_of_sfntfont (void)
   /* Default foundry name.  */
   DEFSYM (Qmisc, "misc");
 
+  /* Predicated employed for sorting font family lists.  */
+  DEFSYM (Qstring_lessp, "string-lessp");
+
   /* Set up staticpros.  */
   sfnt_vendor_name = Qnil;
   staticpro (&sfnt_vendor_name);



reply via email to

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