-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates: Macro Expansion to Specified Size #27
Comments
I agree, this would be nice. And I will try to add this at the weekend. I can probably do it really fast, so there is no need for you to do it yourself. Would you really cut of the text, or just let it use more space in case the inserted text is longer? Eg.
Would result in (as it should) [Example 1]:
Which is really useful and therefore should be included. But if the name is to long [Example 2],
it would actually break the format (on purpose, see below). Compare C's sprintf. The format specifier would also completely display text, even if it is longer than 20 characters:
This is a question of design philosophy. In designing all of this, my approach is that editing stuff is easier than adding new stuff. So I would rather break the format and insert the full name, seeing how this would be easy to fix. Secondly, if it breaks the format, that's easy to spot, while an incompletely inserted variable name, date, ... would be much harder to notice at a glance. You would of course still get the benefit of all the cases where it works correctly, which would hopefully be the vast majority of cases. So I really like your suggestion, I'm just unsure about the "exception handling". What do you think? |
By exceptions do you mean text expanded which would be larger than specified macro? Were it possible, in those cases, symbols like '|' or '-' could be used after the first '|' in the macro expansion to specify whether the expanded text should be cutoff. If one of those symbols were included then it would cutoff the text else it would just proceed as normal expanding the whole text even if it pushed the rest of the line further. For example without '-':
Would expand to ->
And with '-':
Would expand to ->
I think one can also cutoff text with C's sprintf by adding '.20' after the '20' to make the string no longer than 20 characters, but also occupy 20 characters if less characters are specified by text.
I don't want to push any work on you, because I don't know how difficult it would be to implement this in your code, or whether this would break syntax or other stuff. But I think this is how I would change this. Thanks for replying 👍 PS: You are right that date, times and those types would be difficult to debug if they were cutoff |
Is in the works. I'll push tomorrow. |
I've pushed a version of the format specifiers: See the documentation:
|
Your template now could look like this:
|
Nice, I just read the documentation. I will try your changes this afternoon. The changes on the documentation look awesome 😃 |
Thanks! Your new changes are awesome 😄 I will keep on testing them and will let you know of anything I find. But your changes exceeded my expectations. Thank you so much |
Your welcome. I plan to release the plug-ins with the new template version after Christmas. Until then the behavior may still change. So suggestions (and bug reports) are highly welcome. |
Hi,
Is there a way to expand a macro to a specific size? Right now macros expand and much all of the characters after it like so:
Suppose NAME is 'Morgan Stanley' then the macro will expand like this ->
After expansion
I though it would be really nice if a macro expansion could specify a maximum size to which it could expand and fill the non expanded space with spaces. For example above the ending comments don't line up anymore.
So is there something like the following?
Eg.
After expansion
Thanks,
PS: If there isn't something like that, it would be awesome if someone could give me a hint on where in the mmtemplates I could modify this to do it.
The text was updated successfully, but these errors were encountered: