Hi Miguel,
I've looked into this a little bit, and what I discovered is that the
priority of template files in your ~/.srecode directory are equal to the
priority of library template files.
I put the line:
set priority "100"
into the header of the template files in my .srecode directory, and then
the new template started to override the original templates in a fresh
Emacs.
The reason compiling by hand worked is as you suggested, it put the new
template file ahead of the others.
SRecode works by sorting the template files internally based on
priority, but when they are all the same priority, it appears new
templates show up first.
The way it is supposed to work is that built-in templates will have a
low priority. Anything that comes with srecode for the default mode is
30, templates that are mode specific and come with srecode are 40.
Project templates for default are 50, and mode specific project
templates are 60. Personal templates for default are 80, and personal
mode specific templates are 90.
The algorithm for detecting templates shipping with srecode are for the
old file system (as per the last CEDET 1.1 release). The priority of
these templates shows up as 90, matching personal templates. Thus, you
need to goose the priority by hand instead of using the calculated
version. It also means project templates are really broken.
Researching this was easy, as I found a giant TODO comment telling me
what to do when integrating with Emacs. I guess I have something TODO. ;)
Does anyone else on the list know of a clever way to detect if a
template file is in Emacs' "etc" directory? I'm tempted to say any
template that has "etc/srecode" in the directory string is a built-in
template.
I've also noticed that CEDET from bzr templates AND emacs core templates
are all in the MAP. That is something else I'll need to investigate.
Good Luck
Eric
On 12/04/2012 09:34 AM, Miguel Guedes wrote:
> On 04/12/12 02:48, Eric M. Ludlam wrote:
>> This sounds familiar, and back when I fixed that problem, I added a unit
>> test for testing it.
>
> I've managed to understand and isolate the issue I was having further.
> The issue of SRecode templates not being recognized seems to only affect
> templates that have key bind settings.
>
> For instance, I've got the following template definition in
> ~/.srecode/cxx.srt:
>
> context declaration
>
> template class_ :indent :blank
> "Insert a C++ class."
> ----
> class {{?NAME}}
> {
> public:
> {{NAME}}();
> ~{{NAME}}();
>
>
> public:
> {{^}}
>
>
> private:
>
> };
> ----
> bind "c"
>
>
> Template `class_' is recognized when C-/ / is typed and appears under
> the `declaration:' group. However, hitting C-/ c doesn't work and the
> original `class' template is executed instead. It is only when one
> forces compilation of the custom template (in this case
> ~/.srecode/cxx.srt) that the old template bound to the key `c' is
> overriden by the new one.
>
> IOW, it seems to be a case of SRecode loading the built-in templates
> *after* the ones in ~/.srecode and overriding the key bindings.
>
>>
>> Try:
>>
>> C-h v srecode-map-load-path RET
>>
>> and see if your "~/.srecode" directory is in there.
>
> It is, yes. Here's the relevant snippet: (removed only irrelevant
> templates but didn't change the order!)
>
> ("/usr/src/bzr-cedet/etc/srecode" "/usr/share/emacs/24.2/etc/srecode"
> "/home/guedesm/.srecode/")
>
>>
>> If so, try:
>>
>> M-x srecode-get-maps RET
>
> Same as above applies - irrelevant templates removed but order kept:
>
> -- SRecode Global map --
> Mode Filename
> ------ ------------------
> default /usr/src/bzr-cedet/etc/srecode/default.srt
> c++-mode /usr/src/bzr-cedet/etc/srecode/cpp.srt
> default /usr/src/bzr-cedet/etc/srecode/cogre-default.srt
> c-mode /usr/src/bzr-cedet/etc/srecode/c.srt
> default /home/guedesm/.srecode/default.srt
> c++-mode /home/guedesm/.srecode/cxx.srt
> c-mode /home/guedesm/.srecode/c.srt
> default /usr/share/emacs/24.2/etc/srecode/default.srt
> c++-mode /usr/share/emacs/24.2/etc/srecode/cpp.srt
>
>
>>
>> and look at the output to see if any of your template files are in
>> there. SRecode rescans it's path for new templates, and matches them up
>> with different modes. Perhaps your files are being scanned incorrectly?
>>
>> I use CEDET from the BZR repository (of course) and my customizations
>> are currently active in my maps list.
>
> Using latest from the BZR repository too.
>
> Thank you for your time, Eric!
>
|