From: Po Lu Date: Sat, 16 Sep 2023 02:38:46 +0000 (+0800) Subject: Update Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ee4b6a4a2d6b2779cdcf662938b5c81dc2fd2bef;p=emacs.git 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) : New defsym. --- 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 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 (); 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);