Author Topic: Problem setting syntax highlighting mode in diff  (Read 6376 times)

skilleter

  • Community Member
  • Posts: 14
  • Hero Points: 0
Problem setting syntax highlighting mode in diff
« on: July 17, 2007, 10:46:37 AM »
Greetings folks,

I'm using Slickedit 12.0.0 on Linux and I've run into an irritating problem with Slickedit's diff.

We use ClearCase for version control which allows you to directly access specific versions of files by appending '@@' and the version information to the filename. This slightly confuses Slickedit's automatic file type detection as, for instance the '.c' is now in the middle of the filename, not at the end and it doesn't recognize the extension and doesn't set the highlighting mode for the file.

I've fixed this by adding a macro (_buffer_add_FixFileType) which auto-runs when a file is loaded (by virtue, I understand, of the _buffer_add prefix to the name), checks the name, strips off any '@@' suffix, and calls select_edit_mode() with the 'real' file extension

This works fine in Slickedit, but doesn't run when you load files into the diff software, so I don't get the highlighting in diffs.

I had a hunt through the Slickedit macro source and discovered that it seems to call a function userSelectEditMode, if it exists, when loading a file into diff, but I've tried writing a function with this name and it doesn't get called. It is in the same source file, and shares the same core code as my _buffer_add_FixFileType macro, which does work, so I'm a bit baffled as to why it doesn't work.

Anyone got any useful ideas?

John Skilleter

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Problem setting syntax highlighting mode in diff
« Reply #1 on: July 17, 2007, 11:43:53 AM »
You could try this solution http://community.slickedit.com/index.php?topic=1221.msg5351#msg5351.
It should work also when diffing 'files@@'.

HS2

skilleter

  • Community Member
  • Posts: 14
  • Hero Points: 0
Re: Problem setting syntax highlighting mode in diff
« Reply #2 on: July 17, 2007, 12:59:54 PM »
Thanks,

That works, although it is something of a hack.

I was hoping for a neater solution that wouldn't risk being lost when I upgrade to the latest version, but I'll settle for a hack that works!

John

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Problem setting syntax highlighting mode in diff
« Reply #3 on: July 17, 2007, 01:09:43 PM »
@SlickTeam: Due to the fact that ClearCase diffing seems to affect quite a number of users I'd propose to add a solution to the product. IMHO the 'get_extension' extension is a reasonable method maybe in conjunction with a 'def_' flag in case it really hits other users also dealing with 'files@@'.

HS2
« Last Edit: July 17, 2007, 01:11:45 PM by hs2 »

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2897
  • Hero Points: 153
Re: Problem setting syntax highlighting mode in diff
« Reply #4 on: July 17, 2007, 01:13:07 PM »
The callbacks do not get called because the diff calls load_files instead of edit.  My first attempts to call these did not work, and I would rather not do this anyway because I worry about getting the close buffer callbacks right.

Do the file extensions always look like "@@cpp", or do they vary?  We have some other callbacks to handle that case.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Problem setting syntax highlighting mode in diff
« Reply #5 on: July 17, 2007, 01:23:10 PM »
IIRC the format is 'file@@version_number'.
HS2

Edit: Found an example:
cleardiff util.c@@\main\LATEST util.c@@\main\rel2_bugfix\LATEST
« Last Edit: July 17, 2007, 01:26:05 PM by hs2 »