Author Topic: Extensionless file types not working  (Read 6486 times)

yonester

  • Community Member
  • Posts: 7
  • Hero Points: 0
Extensionless file types not working
« on: August 24, 2010, 07:13:58 PM »
I want to associate SCons file types with the Python language in SlickEdit, so that they open and color code as if they had a .py extension. Here's what I tried:

    1. Tools > Options > Languages > Extensionless File Manager
    2. Add pattern **\SConscript, Language: Python
    3. Add pattern **\SConstruct, Language: Python
    4. OK

However, files are not made to associate with SlickEdit in Windows, and when I open a file manually (by dragging it into SlickEdit) it doesn't show any color coding scheme at all. Any idea what's going on?

I'm running Windows 7, SlickEdit 15.0.1.3 with "hotfix_se15013_1_cumulative.zip"

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 36
Re: Extensionless file types not working
« Reply #1 on: August 24, 2010, 08:08:30 PM »
Setting up the Extensionless File Manager does not do anything for file associations outside of SlickEdit.  We handle that through Tools > Options > File Options > Associate File Types.  However, there is not currently a way to do this for extensionless files.  That is a good idea, though.  I'm not sure how we would do it, though, since the current mechanism uses the Windows registry.  I'll do a little investigation to see if that is possible.

I was able to reproduce the error with mapping SConscript and SConstruct to Python.  I'll get a fix for that.

Thanks for the bug report!

yonester

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #2 on: August 24, 2010, 08:44:49 PM »
For me, personally, the color coding is more important. You're right about associating extensionless files in Windows. The only way I've found to do that is to associate all such files with a program (see http://bit.ly/b5F260). I.e. AFAIK Windows doesn't have the pattern matching capabilities that SlickEdit does.

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 36
Re: Extensionless file types not working
« Reply #3 on: August 24, 2010, 09:12:12 PM »
I have a fix for the problem, and I'll make sure it gets in the next revision of the hotfix.  Until then, you can always go to Document > Select Mode to specify the language for a file.  That should get you the color coding you want.

yonester

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #4 on: August 24, 2010, 09:18:06 PM »
Thanks for your prompt help. It's nice to see that SlickEdit developers are in touch with the user community.

Out of curiosity, is there an expected date for the next hotfix release?

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 36
Re: Extensionless file types not working
« Reply #5 on: August 25, 2010, 06:08:35 PM »
I am hopeful that the new hot fix will be out this week.  I will update this thread when it comes out.

Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 36
Re: Extensionless file types not working
« Reply #6 on: August 26, 2010, 09:03:03 PM »
And it's out!  You can get the latest hot fix by going here:  http://www.slickedit.com/index.php?option=com_content&view=article&id=260&Itemid=41.  Be sure to read the pre-install requirement.

One little thing - for files which you have already opened in SlickEdit, you will likely end up having to use Document > Select Mode anyway.  Before trying to map files to languages using the Extensionless Files settings, we see if the file was previously opened in the application and use the language that was associated with it before.  However, once you do that, you should be good to go.  And any future files that you open should be right the first time.

Thanks!

yonester

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #7 on: August 26, 2010, 09:19:41 PM »
Works beautifully. Thanks again.

myk

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #8 on: December 01, 2010, 02:14:44 PM »
I have a similar problem on linux (with the aforementioned hotfixes applied): extensionless file types don't work if they contain any '.' chars.  I've tried to associate "**/dirname/**/file.name.cfg" with a custom language and it doesn't work.  I realise file.name.cfg technically does have an extension, but I have several different flavours of .cfg file and it would be nice to have colour coding work for each type (based on the path/filename in question).

As a workaround, is there a way to specify the file mode from the command line?  I have a script that wraps the invocation of /opt/slickedit/bin/vs, so potentially I could detect file.name.cfg there and execute select-mode for it.  I've tried "/opt/slickedit/bin/vs <file> -p select-mode <lang>" but it just says "Invalid option" after loading the file.

Thanks!

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Extensionless file types not working
« Reply #9 on: December 01, 2010, 09:13:36 PM »
@myk: You're better off with this method to resolve e.g. extension ambiguities etc.
You migth also try to search for 'userSelectEditMode' for some other examples.
HS2

myk

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #10 on: December 02, 2010, 01:53:08 PM »
@hs2: Thanks, that's just what I needed!

Although I did have to hack stdcmds.e and cmmode.e to stop a seemingly-builtin call to userSelectEditorLanguage (which was for some COBOL handling, of all things!)

Stu

  • Community Member
  • Posts: 59
  • Hero Points: 0
Re: Extensionless file types not working
« Reply #11 on: December 05, 2010, 03:13:43 PM »
I have for my rakefiles + rantfiles so they assume ruby with no extension.
I did not have to hack stdcmds.e and cmmode.e to make it work.

Code: [Select]
/**
 * User-defined file mode callback.  Whenever _SetEditorLanguage() is called,
 * this function is called.
 *
 * @return int             0 if language mode was set in this callback
 *                         1 if no mode was set and the default actions in
 *                         _SetEditorLanguage should be used
 */
int userSelectEditorLanguage(_str lang, boolean bypass_buffer_setup=false)
{
   // strip out the file name only
   filename := strip_filename(p_buf_name, 'p');

   // determine if this is a ruby build system file (extensionless)
   if (file_eq(filename, 'rakefile') || file_eq(filename, 'rantfile')) {
     _SetEditorLanguage('ruby', bypass_buffer_setup);
     return 0;
   }

   return 1;
}