User forums > General (but related to Code::Blocks)

Problem with '%' in editor abbreviations

(1/5) > >>

Pecan:
I cannot seem to get an editor abbreviation to print a '%s" etc.
It wants to do a substitution.

How can I get an abbreviation to print, say: printf(wxT("%s %d"));
Right now, it substitutes as: printf(wxT(""));

thanks
pecan

thomas:
Currently, and in the near, predictable future, you can't.

A working hack to work around the substitution problem (not only relating to % but also $) at least in the autocomplete box would be to add a checkbox "substitute variables" to enable substitution.

There is unluckily no way to make it really work.

I was previously under the assumption that escaping the control chars % and $ did not work because the replacement process runs recursively due to an error of mine.
However, the truth is that although this originally indeed was an error, it is also a feature, since because of that "error", it accidentially behaves the way people want it to, which it otherwise wouldn't...
Therefore, there is not only no easy way to fix it (as I claimed earlier), there is no way at all.

mandrav:

--- Quote from: thomas on November 13, 2006, 01:39:53 pm ---Therefore, there is not only no easy way to fix it (as I claimed earlier), there is no way at all.

--- End quote ---

Actually, Thomas, why does it make the substitution if no such macro is found? If it just left it untouched in this case, then this problem would be mostly fixed, no?

thomas:
Apparently, the regex matches %s %d, taking ' ' and '"' as delimiters (though I don't see why, it shouldn't). We could try a regex that is a lot more complicated (with, what's it called, lookback?).

That would solve the problem in the particular example by Pecan, but not in general. The general problem persists, and cannot be solved, as people expect stuff like $($(TARGET_NAME)_OUTPUT_FILE) to work. This only works because macro replacement (errornously) runs recursively. As long as this is true, we cannot escape the control chars :(

mandrav:
You probably misunderstood me.
What I 'm saying is what if instead of replacing the macro (whatever that is) with an empty string (in case it's not defined), just let it untouched.

Navigation

[0] Message Index

[#] Next page

Go to full version