Re: [CEDET-devel] SRecode Strange Priority Behavior/Bug?
Brought to you by:
zappo
From: Brian F. <ter...@ca...> - 2012-02-24 04:56:16
|
Hi Eric, Thanks for figuring this one out and providing the patch. I verified it working in both trunk and newtrunk. In case anyone needs it, I pasted my bzr diff output for your patch in the newtrunk branch. Thanks again! Brian terranpro@lannister:~/code/cedet-newtrunk/lisp/cedet/srecode$ bzr diff === modified file 'lisp/cedet/srecode/dictionary.el' --- lisp/cedet/srecode/dictionary.el 2011-10-25 18:55:21 +0000 +++ lisp/cedet/srecode/dictionary.el 2012-02-24 04:34:55 +0000 @@ -220,7 +220,10 @@ "Insert into DICT the variables found in table TPL. TPL is an object representing a compiled template file." (when tpl - (let ((tabs (oref tpl :tables))) + ;; Tables are sorted with highest priority first, useful for looking + ;; up templates, but this means we need to install the variables in + ;; reverse order so higher priority variables override lower ones. + (let ((tabs (reverse (oref tpl :tables)))) (require 'srecode/find) ; For srecode-template-table-in-project-p (while tabs (when (srecode-template-table-in-project-p (car tabs)) "Eric M. Ludlam" <eri...@gm...> writes: > Hi Brian, > > A fascinating problem which took me by surprise, but I was able > identify what is probably going on and verify a fix. > > SRecode handles priority by keeping all the parsed template files in > sorted order. When a template is looked up, it starts at the top of > the list, and keeps going till it finds a match. > > When creating a dictionary, it uses the same list, and starts adding > all the variables to the dictionary without stopping. Thus, low > priority variables overrode higher ones. > > The attached patch should fix it by just reversing the order in > which variables are added. > > Let me know if this works for you. > > On a side note, a "project" variable was added a while ago to handle > the per-project question. Just add a line such as: > > set project "/home/me/myproject" > > to make a file unique to some project. Such a template file would go > in your ~/.srecode directory. > > Eric > > On 02/20/2012 04:04 AM, Brian Fransioli wrote: >> Hello again CEDETers, >> >> I'm having a blast using CEDET, but I have found another issue which I >> would like to mention. I was dabbling with SRecode to do virtually the >> same thing as the user from the post below was doing - overriding >> variables like COPYRIGHT for the file:empty template. >> >> http://sourceforge.net/mailarchive/message.php?msg_id=24567448 >> >> The difference between us though, is that I also reset variables like >> comment_start and comment_prefix and comment_end. I also tried to >> override my header_guard to upcase the filename. I read in several >> places that the notion of priority was user files chosen over system >> files, and that higher priority wins out. >> >> With the template file shown below, COPYRIGHT is overriden as expected >> *BUT* comment_start, etc. are still the defaults from cpp.srt in the >> etc/srecode/ directory. Also, header_guard is overriden. >> >> Changing priority to "50", (lower than my system value of 70) results in >> comment_start, comment_end, etc. being overriden, along with COPYRIGHT. >> *HOWEVER*, header_guard is NOT overriden. It uses the version from >> etc/srecode/cpp.srt. >> >> Am I doing something wrong here? I feel that I've found a bug here... >> >> Perhaps I should mention I'm working in *newtrunk*. Also, when I modify >> my template, I perform<C-c C-c> to recompile it, and then<C-c / /> in >> my test cpp header file. >> >> Again, in short, my point is I can't seem to override *BOTH* >> header_guard *AND* comment_start, comment_end, comment_prefix >> simultaneously. Changing priority results in overriding either one *OR* >> the other. >> >> Thanks, >> Brian >> >> /home/terranpro/.srecode/mycpp.srt >> ========== >> set mode "c++-mode" >> >> set comment_start "//" >> set comment_end "//" >> set comment_prefix "//" >> >> set COPYRIGHT "Brian's Copyright...BLAH" >> >> set priority "100" >> >> context file >> >> template empty :time :user :file :cpp >> "Optional docstring." >> ---- >> {{>:filecomment}} >> >> {{#NOTHEADER}} >> >> {{^}} >> {{/NOTHEADER}} >> {{#HEADER}} >> {{>:header_guard}} >> {{/HEADER}} >> ---- >> >> template header_guard :file :blank >> ---- >> #ifndef {{FILENAME_SYMBOL:upcase}} >> #define {{FILENAME_SYMBOL:upcase}} >> >> {{^}} >> >> #endif // {{FILENAME_SYMBOL:upcase}} >> ---- >> >> ------------------------------------------------------------------------------ >> Try before you buy = See our experts in action! >> The most comprehensive online learning library for Microsoft developers >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >> Metro Style Apps, more. Free future releases when you subscribe now! >> http://p.sf.net/sfu/learndevnow-dev2 >> _______________________________________________ >> Cedet-devel mailing list >> Ced...@li... >> https://lists.sourceforge.net/lists/listinfo/cedet-devel >> |