Edit: It doesn’t work because the first s is substituted since there is no preceding s. So, because the first s has become long s already, when it moves on to the second s, there is no preceding s (therefore it becomes longs too).
So the code should be like this:
ignore sub longs s’;
sub s’ by longs;
Alternatively, you can do it in two steps. First, you substitute all s’s with longs, then substitute some back to normal s. In the case of double-s situation, the code looks like this:
Why? This should be for the user to decide. That is, of course, unless you have a very specific application for this contextual substitution.
Secondly, I recommend you use /s.hist as a name rather than /longs because this feature is expected to change only on the glyph level, not on the character level. And /longs is connected to a different Unicode value (017F) than /s (0073). You can quickly make a component copy by typing “longs=s.hist” into the dialog that appears after Font > Add Glyphs.