Author Topic: Two languages: MATLAB identity crisis  (Read 737 times)

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Two languages: MATLAB identity crisis
« on: May 09, 2018, 04:39:09 pm »
Today I needed to edit some MATLAB files in SlickEdit, which I rarely do, so I've never really configured it before.  So I figured I'd get everything just the way I liked it as far as formatting, etc. First oddity: in the managed languages (Options -> Languages -> Language Manager) I have an entry for MATLAB (under Application Languages) and an entry for Matlab (under Miscellaneous Languages). My first thought was that years ago I might have added one of them myself before SlickEdit supported MATLAB.  But both have the SlickEdit icon next to them and won't let me delete.

Also one of them (Matlab) had the keywords correctly specified in the Color Coding section of the options, the other (MATLAB) had none.  SlickEdit appeared to be selecting "MATLAB" for files with the ".m" extension, even though the language options for MATLAB had the "mm" file extension... which isn't a MATLAB file extension, it's an Objective-C extension (I'm told... never touched the stuff myself). So I tried to get SlickEdit to select "Matlab" for documents ending in ".m" (the standard extension), but even when I did it explicitly from the "Document -> Select Mode" entry, it still favored "MATLAB".  I changed the file extension in the MATLAB entry, but no difference.   I managed to get the keywords formatted finally by going to MATLAB in the language options color coding section section and having it use the "Matlab" profile.

OK, next issue was try to get formatting of things like indentation to work.  That's when I realized that the MATLAB entry really thinks it's Objective-C: the formatting options under the profile are full of Objective-C like options.  Maybe what's going on here is that somehow the "Objective-C" options have gotten tagged with the name MATLAB... and also somehow ".m" files get assigned to MATLAB, even though the extension is not the one in the MATLAB options entry.  My best guess is that somehow the name associated with the Objective-C options got overwritten, and that SlickEdit doesn't care about capitalization, so at least in some of its code paths it sees MATLAB and Matlab as the same.  By the way, Objective-C doesn't appear in my Language list at all.

Obviously I'd like to have only one Matlab (or MATLAB, which is what MATLAB's creators prefer, but I really couldn't care) entry, and aside from cosmetics, I'd like to know I have the right options available under that entry.  So my best guess as to a first step would be to change the MATLAB language name to Objective C, but I'm just guessing here, and I don't know where I would do that anyway...

This is SlickEdit 21.0.3.0 with latest hotfix for that version, Debian/Linux 9.3

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Two languages: MATLAB identity crisis
« Reply #1 on: May 09, 2018, 07:02:16 pm »
More info - since I never use objective-c, I didn't realize that ".m" is its default extension also, just like MATLAB.  So that makes it clearer why SlickEdit might map a .m file into the Objective-C settings.  But still not clear why it does so when the Objective-C settings actually are set to use the extension ".mm", and why the settings area might be mislabled "MATLAB" rather than Objective-C.  I am trying a couple minor changes to the objc.e file and rebuilding it.

mrothman

  • Senior Community Member
  • Posts: 120
  • Hero Points: 1
Re: Two languages: MATLAB identity crisis
« Reply #2 on: May 09, 2018, 07:30:14 pm »
Progress, and good enough: I was able to change the Mode name for the "MATLAB" language to "Objective-C" in the language options (don't know how I missed that before).  As soon as I did that, I was able to manually force a source file to be treated as "Matlab" mode, not "MATLAB" (or Objective-C).  However, despite the fact that the options now have the "m" extension assigned to Matlab, and an empty extension for Objective-C, it still doesn't automatically select Matlab on ".m" files, unless I go comment out a line in objc.e which sets the language mode based on 'm'.  So I did that.  I am fully operational again, but if anyone wants to consider it a bug that changing the file extensions in the language options for a given language doesn't seem to make SlickEdit select a different mode for a file with that extension, I would agree.

JimmieC

  • Senior Community Member
  • Posts: 424
  • Hero Points: 16
Re: Two languages: MATLAB identity crisis
« Reply #3 on: May 09, 2018, 08:11:55 pm »
SE's handling of duplicate extensions could be enhanced. I work with several embedded projects with the assembler .asm extension. The keywords & syntax can be somewhat different.

Further, CodeWarrior output files are S-records with the .s extension. SE always thinks it's UNIX assembler (I'm told) so I have to use another editor to view or edit. The guys here helped me re-map .s to plain text. But to remember and reconfigure on each PC\VM or Windows re-install is just not happening.

It would be useful to have several .asm\.s\.m\.mm\whatever extensions language defined. Then when a project is created, the first time a file with multiple language definitions is added, the user gets prompted to select the correct language for this project. In my case, it could be: You have added an .asm file. Which mapping? TI C2000, Freescale S08, Freescale DSC, Microchip, etc...

Not sure how many people would find this useful. I think most SE users are not working with these embedded variants.