Author Topic: GNUmakefile is recognised as "fundamental" not "mak"  (Read 6128 times)

jfoell

  • Community Member
  • Posts: 19
  • Hero Points: 0
GNUmakefile is recognised as "fundamental" not "mak"
« on: January 13, 2008, 05:52:55 pm »
Because of some legacy compile tools, I cannot name my use the name "Makefile" (which SE recognizes correctly and applies the "mak" extension options).  I would like to use the name "GNUmakefile", but SE applies the "fundamental" extension options.  How do add the name "GNUmakefile" to the lexer recognition?   My main concern is the color coding and TABs settings.

SE: v10.0.03 /WinXP

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: GNUmakefile is recognised as "fundamental" not "mak"
« Reply #1 on: January 13, 2008, 07:57:35 pm »
You can do that by supplying a proper implementation of the 'userSelectEditMode' callback used in 'select_edit_mode()'.
Working example:
Code: [Select]
// @see example in 'cmmode.e'
int userSelectEditMode(_str origExt, boolean origBypassBufferSetup)
{
   // message ("userSelectEditMode: bname:" p_buf_name " stripped:" strip_filename( p_buf_name, 'PD' ));
   if ( strip_filename( p_buf_name, 'PD' ) == 'GNUMakefile' ) {
      select_edit_mode( 'mak', origBypassBufferSetup );
      return (0);
   }
   return (1);
}
Just add that to your 'vusrmacs.e' module and reload.
Have fun,
HS2

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: GNUmakefile is recognised as "fundamental" not "mak"
« Reply #2 on: January 13, 2008, 08:48:16 pm »
Yet another very useful but undocumented feature in SlickEdit.  It looks like userSelectEditMode is the right way to do this - I have been hooking using a _buffer_add_ macro, which I think is documented.  I have attached the macro I use, as it is more capable and generic, for people like me who need to override lots of different sorts of files in different ways.  If I find the time, I will look at updating it to use userSelectEditMode, but for now it works fine as is.

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: GNUmakefile is recognised as "fundamental" not "mak"
« Reply #3 on: January 13, 2008, 09:42:40 pm »
I also hooked _buffer_add .. until I accidentally found userSelectEditMode().
I think (didn't verify) that _buffer_add it's not called e.g. if you just (re)name a buffer.
HS2

jfoell

  • Community Member
  • Posts: 19
  • Hero Points: 0
Re: GNUmakefile is recognised as "fundamental" not "mak"
« Reply #4 on: January 14, 2008, 12:19:25 am »
@hs2:
Thank you!
I made one small change to your macro code.   Changed 'GNUMakefile' to 'GNUmakefile' (lowercase m), just cause that is what is recognized by GNU make.   

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: GNUmakefile is recognised as "fundamental" not "mak"
« Reply #5 on: January 14, 2008, 12:31:47 am »
Oh yes - was just a typo.
Thanks, HS2