]> git.eshelyaron.com Git - emacs.git/commitdiff
Further fixes for emojis in the "people" categories
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 19 Dec 2021 18:53:04 +0000 (19:53 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 19 Dec 2021 18:53:08 +0000 (19:53 +0100)
* lisp/international/emoji.el (emoji--base-name): Get more derived
categories right.

lisp/international/emoji.el

index d0e906848cbeba441471fcfb5bf2cd19434ff4fa..4375a6344c59390c9dc52f5e96cd4ae86710c4c5 100644 (file)
@@ -412,18 +412,26 @@ the name is not known."
     (write-region (point-min) (point-max) file)))
 
 (defun emoji--base-name (name derivations)
-  (let* ((base (replace-regexp-in-string ":.*" "" name))
-         (non-binary (replace-regexp-in-string "\\`\\(man\\|woman\\) " ""
-                                               base)))
-    ;; If we have (for instance) "person golfing", and we're adding
-    ;; "man golfing", make the latter a derivation of the former.
-    (cond
-     ((gethash (concat "person " non-binary) derivations)
-      (concat "person " non-binary))
-     ((gethash non-binary derivations)
-      non-binary)
-     (t
-      base))))
+  (let* ((base (replace-regexp-in-string ":.*" "" name)))
+    (catch 'found
+      ;; If we have (for instance) "person golfing", and we're adding
+      ;; "man golfing", make the latter a derivation of the former.
+      (let ((non-binary (replace-regexp-in-string
+                         "\\`\\(m[ae]n\\|wom[ae]n\\) " "" base)))
+        (dolist (prefix '("person " "people " ""))
+          (let ((key (concat prefix non-binary)))
+            (when (gethash key derivations)
+              (throw 'found key)))))
+      ;; We can also have the gender at the end of the string, like
+      ;; "merman" and "pregnant woman".
+      (let ((non-binary (replace-regexp-in-string
+                         "\\(m[ae]n\\|wom[ae]n\\|maid\\)\\'" "" base)))
+        (dolist (suffix '(" person" "person" ""))
+          (let ((key (concat non-binary suffix)))
+            (when (gethash key derivations)
+              (throw 'found key)))))
+      ;; Just return the base.
+      base)))
 
 (defun emoji--split-subgroup (subgroup)
   (let ((prefixes '("face" "hand" "person" "animal" "plant"