How to set the syntax highlighting for files without extension

General questions about using ExamDiff Pro, ideas for new features, bug reports, and usage tips.
Post Reply
kajman
New Member
Posts: 3
Joined: Thu Dec 14, 2017 4:45 am

How to set the syntax highlighting for files without extension

Post by kajman »

My editor create two files ('Editor', 'Database') without extension before run ExamDiff. Is any way to set automicaly SQL syntax for it?

Change Extensions to 'sql,Editor,Database' has no efect. And I did not find this option in the command line options. Every time I compare it, I have to manually set it up.
Last edited by kajman on Tue Jan 02, 2018 5:01 am, edited 1 time in total.
JeremyNicoll
Expert Member
Posts: 108
Joined: Sun May 02, 2010 12:00 pm
Location: Edinburgh

Re: How to set the syntax hightlighting for files without extension

Post by JeremyNicoll »

Even if there's a way to do this, there might need to be a way to limit its effect so that extensionless files elsewhere on the system are not also seen as having this type of contents.

I've used two programmers' text editors which allow syntax highlighting to be applied to files based not only on their extension (if any) but also on the parent/grandparent (etc) folder structure they inhabit, or on literals found in the first one or two KB of their contents. I'm not saying that something so complex is a good idea for EDP, just pointing out that other products solve this problem in a variety of ways.

So for example, in one of those editors, a plain text file in ...\Project23\SQLfiles\temp\...\...\ might be treated in a different way. In another editor any file containing "ThatEditorsName$mode=XYZ" in its first few KB of text would be treated as a ".XYZ" file regardless of its actual extension, if any. I used to use the latter system so that specific listings produced by a particular application (which I'd written) would have the relevant listing-type written into it as a header line, then when the file was opened by the editor concerned it would be syntax-highlighted in a fashion that suited the type of listing. (It went further than that with editor toolbars and macros loaded according to the same virtual filetype, so a user coulkd do listing-specific things to it in the editor.)
kajman
New Member
Posts: 3
Joined: Thu Dec 14, 2017 4:45 am

Re: How to set the syntax hightlighting for files without extension

Post by kajman »

If I change the syntax mode manually in my text editor, it will remember it the next time, until the file is in the history of opened files.

I tried to create a batch file between the database editor and the EDP that will add the missing extension for files in TEMP directory.

Code: Select all

@echo off
set file1=%~1
set file2=%~2
set extension=sql
if not "%~3"=="" (
	set extension=%~3
)

echo "%file1%" | findstr "%TEMP%" 1>nul
if not errorlevel 1 (
	echo "%file1%" | findstr "\." 1>nul
	if errorlevel 1 (
		copy "%file1%" "%file1%.%extension%"
		set file1=%file1%.%extension%
	)
)

echo "%file2%" | findstr "%TEMP%" 1>nul
if not errorlevel 1 (
	echo "%file2%" | findstr "\." 1>nul
	if errorlevel 1 (
		copy "%file2%" "%file2%.%extension%"
		set file2=%file2%.%extension%
	)
)

start "edp sql" /B "C:\dev\programs\examdiff\ExamDiff.exe" "%file1%" "%file2%"
JeremyNicoll
Expert Member
Posts: 108
Joined: Sun May 02, 2010 12:00 pm
Location: Edinburgh

Re: How to set the syntax hightlighting for files without extension

Post by JeremyNicoll »

So... with this batch file... have you changed your text editor so that instead of calling EDP directly, it calls the batch file and passes the names of the two files it just wrote into %TEMP% ?

Do the files have to be left in %TEMP% afterwards? If not it might be better to delete them.

Rather than copying the extensionless files to create an .sql -named file as well, why don't you just rename them (unless that causes some other problem?). It'd certainly be quicker.
kajman
New Member
Posts: 3
Joined: Thu Dec 14, 2017 4:45 am

Re: How to set the syntax hightlighting for files without extension

Post by kajman »

Yes, the PL/SQL Developer creates in some cases files in TEMP without a .suffix in filename (i only saw files Editor, Database and Window).

The Developer does not wait for the diff program to complete and close the application. Files in the TEMP keeps also do not even offer to load back the changes saved to the file %TEMP%/Editor.

The command "move" can be used instead of "copy", but in my case (TEMP is on a ramdisk) speed is not important.

The easiest way would be if the EDP supported a switch in the command line to handle the files as if they had the extension specified by the parameter :-)
Post Reply