Skip to content

Commit

Permalink
refactor(emoji): rewrite script w/ Python and update emojis (ohmyzsh#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeb authored and amkirby committed Mar 9, 2022
1 parent 014e5d7 commit c7e7c87
Show file tree
Hide file tree
Showing 7 changed files with 32,823 additions and 2,591 deletions.
40 changes: 16 additions & 24 deletions plugins/emoji/README.md
Expand Up @@ -10,7 +10,7 @@ This plugin provides support for working with Unicode emoji characters in `zsh`

Variable | Description
----------------- | --------------------------------
$emoji | Maps emoji names to characters
$emoji | Maps emoji names to characters (except flags)
$emoji_flags | Maps country names to flag characters (using region indicators)
$emoji_groups | Named groups of emoji. Keys are group names; values are whitespace-separated lists of character names

Expand Down Expand Up @@ -55,10 +55,8 @@ The defined group names can be found with `echo ${(k)emoji_groups}`.
To list all available emoji with their names, use:
```
$> display_emoji
$> display_emoji fruits
$> display_emoji animals
$> display_emoji vehicles
$> display_emoji faces
$> display_emoji people
```

To use emoji in a prompt:
Expand All @@ -73,13 +71,13 @@ PROMPT="$surfer > "

The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at https://www.unicode.org/reports/tr51/index.html.

The group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke)
The group definitions are added by this OMZ plugin. They are not based on external definitions.

The values in the `$emoji*` maps are the emoji characters themselves, not escape sequences or other forms that require interpretation. They can be used in any context and do not require escape sequence support from commands like `echo` or `print`.

The emoji in the main `$emoji` map are standalone character sequences which can all be output on their own, without worrying about combining characters. The values may actually be multi-code-point sequences, instead of a single code point, and may include combining characters in those sequences. But they're arranged so their effects do not extend beyond that sequence.

The exception to this is the skin tone variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.)
The exception to this is the skin tone / hair style variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.)


## Experimental Features
Expand All @@ -90,7 +88,6 @@ Variables:

Variable | Description
----------------- | --------------------------------
$emoji2 | Auxiliary and combining characters
$emoji_skintone | Skin tone modifiers (from Unicode 8.0)


Expand All @@ -105,31 +102,26 @@ The "variation selectors" are combining characters which change the appearance o
The `$emoji_skintone` associative array maps skin tone IDs to the variation selector characters. To use one, output it immediately following a smiley or other human emoji.

```
echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]"
echo $emoji[waving_hand]$emoji_skintone[5]
```

Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](https://www.unicode.org/reports/tr51/index.html#Diversity) for details.

## TODO

These are things that could be enhanced in future revisions of the plugin.

* Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji)
* Incorporate `gemoji` data
* Country codes for flags
* ZWJ combining function?

#### Gemoji support

The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. (I'm saying this just from looking at the google results for "emoji short names" and related searches. -apjanke)
The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. So, our list of emojis incorporates some of their aliases to make your life more convenient:

If this plugin is updated to provide short names, CLDR sorting data, and similar stuff, it should probably be changed to use the Gemoji project, and the `update_emoji.pl` script be rewritten in Ruby so it can use the Gemoji library directly instead of parsing its data files.
```
echo $emoji[grinning_face_with_smiling_eyes]
echo $emoji[smile]
```

This does *not* mean that it should use Gemoji at run time. None of the `zsh` plugin stuff should call Gemoji or Ruby code. Rather, the "build time" `update_emoji.pl` script should be rewritten to use Gemoji to generate a pure-native-`zsh` character definition file which would be checked in to the repo and can be called by OMZ users without having Gemoji installed.
These two commands yield the same emoji (😄). The first name is the official one, in the Unicode reference, and the second one is the alias that was in Gemoji's database.

#### ZWJ combining function
## TODO

One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](https://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences).
These are things that could be enhanced in future revisions of the plugin.

These are a pain to write out (and probably worse to read), and it might be convenient to have a couple functions for concisely composing them, if wider support for them appears.
* Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji)
* ZWJ combining function?

0 comments on commit c7e7c87

Please sign in to comment.