User forums > Using Code::Blocks

Editor Bug

(1/4) > >>

Max:
Try this: (Windows XP SP2 and latest nightly 3099)

a) define an abbreviation (Settings->Editor->Abbreviations). For example

/*
$a:$
$b:$
$c:$
*/

call it 'test' (or whatever you want)

b) In any opened file type test then Ctrl-J

c) The inserted text will be

/*
:$
$b:$
$c:$
*/

You can try several abbreviation name or contents. The result is always the same:

The first string after the first '$' , including it, will disapper.

I am used to insert RCS header in any file like

/*
  $Author: $
  $Date: $
  $Revision: $
  $Log: $
*/

This bug does not permit any abbreviation of this kind.

The bug appears recently, during the last week. Older nightly worked correctly.

May you confirm?


Bye

Massimo

thomas:
This one is not a real bug, but a feature. Abbrevations support variable expansion since one or two weeks, to  comply with the requests to be able to insert a datestamp or similar.
One consequence of this feature is that things that look like variables are treated as variables, too.

The substring $a will be interpreted as variable (delimited by ':'), and the $ followed by \n will be interpreted as verbatim $ (since there is no variable name following). Since $a is undefined, $a:$ expands to $:$.

There are two possible solutions:
1. Find a way to escape the dollar sign, this has already been tried in another context. It is hard to achieve that without rewriting the whole macros manager.
2. Write $ a: $ instead of $a:$ as this will be interpreted as "dollar-sign a" rather than "variable-a".

Max:

--- Quote from: thomas on October 19, 2006, 03:23:13 pm ---
There are two possible solutions:
1. Find a way to escape the dollar sign, this has already been tried in another context. It is hard to achieve that without rewriting the whole macros manager.
2. Write $ a: $ instead of $a:$ as this will be interpreted as "dollar-sign a" rather than "variable-a".

--- End quote ---

Unfortunately both seem not applicable. The revison control application is waiting for $Author, $<space>Author means
nothing for it.

Anyway there is a workaround. If I insert the RCS header in the "Defalt Code" editor option I am able to insert the whole header in the C/C++ files. It seems that the "default code" is not parsed for macro. Unfortunately creating an header file
the defalt code is ignored (a quite old bug).

Do the developers plan to introduce the macro parsing in the "default code" as well? In that case the only solution is to
write the whole header manually or, better, using a snippet.

Hopefully the snippet will be not parsed for macro in the future!!   :D

Bye

Massimo

mandrav:
I 've been in a similar situation myself.
The easiest thing I can think of to fix this, is to remove $VAR syntax from being a variable. Currently, all the below forms are treated equivalently:

$VAR
$(VAR)
${VAR}
%VAR%

The problem is that although I never use the $VAR form myself, there may be others that do. So while that would solve your problem, it might make things uncomfortable for others.

Another fix that crossed my mind while I was writing this, is to alter the MacrosManager to not substitute unknown macros. So if there is no macro $VAR defined, then no substitution takes place. Any thoughts from other developers on this?

thomas:
Solution 1 would mean that I would need to edit *every* project of mine.

Solution 2 is problematic, since you also want environment variables to be substituted, this won't work any more.

When this issue first came up, my strategy was to esacape '$' with some sequence (for example "$$") and to replace '$$' with some other token that does not occur normally ('\b') as the first thing. After variable expansion, replace the substitute back to '$'.

Actually a trivial thing to do, but it does not work because the macros manager is called multiple times with the same string.  :?

Navigation

[0] Message Index

[#] Next page

Go to full version