Skip to content

Instantly share code, notes, and snippets.

@pprince
Last active March 20, 2016 23:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pprince/f2c5879242d3d5ef1929 to your computer and use it in GitHub Desktop.
Save pprince/f2c5879242d3d5ef1929 to your computer and use it in GitHub Desktop.
XCompose: A New Hope
⎄² — ComposeNG
==============
Next-Generation syntax for XCompose files
Motivation
----------
I am working on a personal project that will involve a *lot* of manipulation of
XCompose-format files. The traditional XCompose format is quite unwieldy
to edit by hand. Consider the following short excerpt:
# Multi-key sequence... Char Keysym Standard Comment
#------------------------------------------- ----- --------- ----------------
<Multi_key> <o> <c> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <o> <C> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <O> <c> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <O> <C> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <C> <o> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <C> <O> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <parenleft> <c> <parenright> : "©" copyright # COPYRIGHT SIGN
<Multi_key> <parenleft> <C> <parenright> : "©" copyright # COPYRIGHT SIGN
1. The field order is not ideal.
(I would prefer that the output character occur first, and not later.)
2. Maintaining vertical alignment of fields is a huge amount of work.
(And, opting not to align fields vertically results in a *far* less
readable file.)
3. The format is not “DRY”:
a. The end-of-line comments containing the unicode character names (and also
usually the Unicode codepoint) are a pain to enter manually, and could
be auto-generated. (They are useful when reading the file, though.)
b. The XKeysym field is redundant and need not be specified.¹
3. The format is overly verbose, requiring lots of angle brackets, and typing
strings like “parenleft” instead of “(”.
Some Very Preliminary Thoughts on Syntax
----------------------------------------
Imagine, instead, if the above eight-line XCompose file could be written as:
© ↤ ⎄⟪↕co⟫ ∪ ⎄(↕c)
or:
© ↤ ⎄⟪↕co⟫
⎄(↕c)
### Possible Super-Compact Unicode-Enabled Syntax ideas...
Permute Case:
↕c ↕c x ↕c ↕o
↳ c C ↳ cx Cx ↳ co cO Co CO
Combinations:
⟪a b⟫ ↕⟪a b⟫ ↕⟪a b c⟫
↳ ab ba ↳ ab bc AB BA ↳ abc acb bac bca cab cba
More examples/thoughts...
⟪↕c ↕o⟫ ⟪ab ↕cd⟫
↳ co cO Co CO oc Oc oC OC ↳ abcd abCd abcD abCD cdab Cdab cDab CDab
### Possible Python-ish syntax...
[('c','C'),('o', 'O')] → ['co', 'cO', 'Co', 'CO']
[('c','C'),('o', 'O'), 'a'] → ['coa', 'cOa', 'Coa', 'COa']
[('c','C'), ('o','O'), 'a', ('b','B')]
↳ ['coab', 'cOab', 'Coab', 'COab', 'coaB', 'cOaB', 'CoaB', 'COaB']
Maybe...
{} = Set = alternation/permutations
() = Tuple = combinations
[] = List = list...
[({'c','C'},{'o','O'}), 'a']
↳ ['coa', 'cOa', 'Coa', 'COa', 'oca', 'Oca', 'oCa', 'OCa']
More thoughts...
[({'cC'},{'oO'}), 'a']
↳ ['coa', 'cOa', 'Coa', 'COa', 'oca', 'Oca', 'oCa', 'OCa']
[('cC'),('oO')] -> ['co', 'cO', 'Co', 'CO']
['cC', 'oO'] -> ['co', 'cO', 'Co', 'CO']
### Perl6 Example
<psch> m: say [X~] (<c C>, <o O>, <a>, <b B>)
<camelia> …OUTPUT«(coab coaB cOab cOaB Coab CoaB COab COaB)␤»
Endnotes
========
¹ I think. Or at least, in most cases. I need more info about when this is
useful to specify, rather than permit the default behavior. Even in (most of)
those cases, though, it should still be possible for this to be generated by my
program, rather than specified manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment