More efficient code

I have the following code which is repeating a number of times and the number of permutations can increased because there can be multiple diacritics on one letter:

pos lamed @wide' <30 0 0 0> finalpe;
pos lamed @diacritics @wide' <30 0 0 0> finalpe;
pos lamed @wide' <30 0 0 0> @diacritics finalpe;

or even a simple line here where I want to move the diacritics under one letter to the right and another to the left:

pos yod @thin resh qubuts' <10 0 0 0>; 
pos yod @thin' <30 0 0 0>  resh qubuts; 

Is there a way of writing this more efficiently?

What is the difference between the first two lines? All situations in line 2 are already covered in line 1.

Try this:

lookupflag IgnoreMarks RightToLeft;
pos lamed @wide' <30 0 0 0> finalpe;

My class names are not very helpful if I don’t explain!

Hebrew has two levels of diacritic marks, the niqud which are secondary marks and include marks such as the patah-hb and qamats-hb and the tertiary marks such as the telisha gedola and pazer which are the cantillation marks. In this particularly job, the Hebrew font needs extra Arabic marks such as the shadda-ar and kasratan-ar.

Now to make things even more confusing there are marks such as the dagesh, meteg and the dots on the shin and sin that are technically secondary marks but you can have a letter like a shin which has a shin dot, dagesh, qamats-hb and meteg!

Now to the example above, I have defined 4 of the niqud, the qamats, segol, tsere, patah, to have a class called “wide” because, well they are wide :slight_smile:

Now these niqud collide with the finalpe, so I need to move them to the right. That is line one. However, it’s possible that as well as there being a wide niqud under the lamed, there might be a tertiary diacritic mark above the lamed as well. Hence line 2. And just for fun, the client often typed the tertiary diacritic before the niqud hence line 3.

Surely the lookupflag will ignore not only the fact that there might be marks from the class named “diacritics” but also the class named “wide” which contains 4 marks meaning that the niqud won’t move to the right?

I would work with MarkFilteringSet then. It ignores all marks that are not in the filtering set.

The issue with line 1 and line 2 is that line 2 can never be reached because all cases of line 2 are already covered by 1. So if you leave out line 2, the code still works exactly the same way.