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.
This commit is contained in:
Po Lu 2023-09-16 10:38:46 +08:00
parent bc25d76650
commit ee4b6a4a2d
4 changed files with 46 additions and 6 deletions

View file

@ -347,6 +347,13 @@ private static final class Item implements MenuItem.OnMenuItemClickListener
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;

View file

@ -622,6 +622,13 @@ else if (child.getVisibility () != GONE)
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;

View file

@ -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)

View file

@ -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);