SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: Paul Gilmartin on December 18, 2014, 07:30:21 AM

Title: filetype not in filename
Post by: Paul Gilmartin on December 18, 2014, 07:30:21 AM
We're using Slickedit with a competitor's CM system (IBM Rational CM Synergy).
This keeps archival versions under generated names ("/CM/Archive/12345678")
The Synergy DB tells us that that's "foo.c" but we must edit it as "12345678".
How can we tell Slickedit to use filetype ".c" for syntax highlighting?
I'd imagine something on the command line such as

    vs -type ".c" /CM/Archive/12345678

Thanks,
gil
Title: Re: filetype not in filename
Post by: hs2 on December 18, 2014, 11:00:42 AM
This should work:
Code: [Select]
vs /CM/Archive/12345678 "-#select-mode C/C++"'select-mode' is the underlying command of 'Document>Select Mode'
See also 'Help>Index:Invocation Options'.
HS2
Title: Re: filetype not in filename
Post by: Graeme on December 18, 2014, 12:00:05 PM
See also "Extensionless file manager" in the help.
You could set up a pattern that treats any file whose name starts with a "1" as mapping to c/c++.
You could also write a macro that scanned a file when it's first opened and selected the mode based on the content of the file.
Title: Re: filetype not in filename
Post by: Dennis on December 18, 2014, 06:19:38 PM
If you have other languages mixed in there, and if you can retrieve the real file name from the database based on the mangled name, you could write a macro that gets the real file name and then selects the mode:

Code: [Select]
   _str synergy_cm_get_real_filename(_str f) {
      // call out to shell to get result
      return _PipeShellResult("whatever_command_it_takes " :+ _maybe_quote_filename(f));
   }
   _command void synergy_cm_select_mode()
                           name_info(MODENAME_ARG','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
   {
       f := synergy_cm_get_real_filename(p_buf_name);
       lang := _Filename2LangId(f);
       if (lang != "") _SetEditorLanguage(lang);
       p_DocumentName = f;  // optional
   }

Then you can use -#synergy_cm_select_mode on the command line.
Title: Re: filetype not in filename
Post by: Paul Gilmartin on December 18, 2014, 09:09:42 PM
This should work:
Code: [Select]
vs /CM/Archive/12345678 "-#select-mode C/C++"'select-mode' is the underlying command of 'Document>Select Mode'
See also 'Help>Index:Invocation Options'.
HS2

The best suggestion I've received.  Thanks!  I issue the command:
    vs "-#select_mode Makefile" 221314
... and sure enough, it opens it as a Makefile.  *But*, I get
a dialog:
o Just map this file to Makefile
o Map all files named "221314" to Makefile
o Map all extensionless files in /foo/bar to Makefile
|_| Do not ask me to map file names or directories to languages again.

Clearly the last is what I want.  I exit and try again.  Same
dialog.  Did I neglect to save my profile?

(The better option would be, "Ask me only when I haven't told you".)

Also, I note that one of the languages I want to use has a space in
its name.  Do I need to quote that (how?) in the select_mode?

Thanks again,
gil
Title: Re: filetype not in filename
Post by: Clark on December 18, 2014, 10:08:40 PM
The select_mode command argument does not need to be quoted (i.e. "-#select bourne shell" will work fine).

As for that check box, it appears that there's a bug. The work around is to check that box at start up and change some other option so that the configuration gets saved. The option is getting set but not saved. That's the bug.

Clark
Title: Re: filetype not in filename
Post by: Paul Gilmartin on December 18, 2014, 10:56:32 PM
The select_mode command argument does not need to be quoted (i.e. "-#select bourne shell" will work fine).

As for that check box, it appears that there's a bug. The work around is to check that box at start up and change some other option so that the configuration gets saved. The option is getting set but not saved. That's the bug.

Clark
Now, this is weird.  I got the "do not ask" button checked and saved;
I don't know what I did.  Now, for the command:
    vs +#select_mode Makefile 314745
the file opens as "Plain Text".  I exit Slick and issue
the same command again, and the file comes up as
"Makefile".  Another bug?  Does it only remember the
type when I Exit, not when I Open?

Thanks,
gil
Title: Re: filetype not in filename
Post by: hs2 on December 18, 2014, 11:20:44 PM
Not sure, but the correct syntax and acc. to the docs is:
Code: [Select]
vs 314745 "-#select-mode Makefile"It worked for me with SEv19.0.1 RC.
I think the language mode of files in the MRU list (File menu) is also saved and restored for convenience reasons.
HS2
Title: Re: filetype not in filename
Post by: Dennis on December 19, 2014, 04:33:04 PM
Just to clarify on the quoting.  The -#<command args> argument does need to be quoted, but the mode name itself does not need to be quoted, even if it includes spaces.

Example:
Code: [Select]
  vs +new /CM/Archive/12345678 "-#select-mode Bourne Shell"
Title: Re: filetype not in filename
Post by: Paul Gilmartin on December 19, 2014, 05:48:28 PM
Just to clarify on the quoting.  The -#<command args> argument does need to be quoted, but the mode name itself does not need to be quoted, even if it includes spaces.

Example:
Code: [Select]
  vs +new /CM/Archive/12345678 "-#select-mode Bourne Shell"

Aren't you describing POSIX Shell syntax, rather than vs
argument syntax?

But I'm so POSIX-oriented that I automatically put the option
before the command argument.  Must the order be reversed, in fact?

Hmmm.  The "select" links in each ply of this display give
"Javascript void(0)" on both Safari 5.1.10 and Firefox 34.0.5
on OS X 10.6.8.

Thanks,
gil
Title: Re: filetype not in filename
Post by: Dennis on December 20, 2014, 12:06:04 AM
Things happen in the order they are specified on the command line, so yes, the -#select-mode needs to be after the filename.  Otherwise, you are running select-mode before opening the file.  It has to be this way so that you can specify multiple -# commands on the command line.

Even POSIX shell syntax has notable exceptions where necessary, such as the arguments to 'find' and 'xargs'
Title: Re: filetype not in filename
Post by: hs2 on December 20, 2014, 01:12:57 AM
Quote
Things happen in the order they are specified on the command line
Exactly. Just like editing a file in SE as usual and invoking a sequence of commands.
HS2
Title: Re: filetype not in filename
Post by: jporkkahtc on December 20, 2014, 03:28:25 PM
It would be great if Slick could have an "automatic" type that used the equivalent of the linux "file" command.
"file" has a bunch of hueristics to determine the type of the file, be it binary or C or whatever.




I'd really like slick to at least have some "binary" autodetect - so that I can more easily recursively search without having to enumerate all good/bad file extensions to try to get slick to not search thru the many binary files (*.o;*.ilk;*.a;*.lib;*.pdb;*.etc....)


Having it use this to automatically determine the type of extensionless files would be icing on the cake.
Title: Re: filetype not in filename
Post by: Paul Gilmartin on December 20, 2014, 07:51:24 PM
It would be great if Slick could have an "automatic" type that used the equivalent of the linux "file" command.
"file" has a bunch of hueristics to determine the type of the file, be it binary or C or whatever.
<snip!>

I'm already working on a shell script to bridge from CM Synergy
to Slick (Works much better now that I understand about command
sequence -- thanks!)

Such a script might invoke "file" in command substitution; parse
it's output; edit with the "-#select-mode [whatever]" command.
You'd still need a massive "case/switch" statement to convert
"file"'s returned values to Slick modes.

Now, the hard one:  CM Synergy may pass my wrapper strings such as:

    "306440" "View asm370 - source (SWSRDMG.s,I16926760)"

I know that "306440" means a filename in the current directory,
and "SWSRDMG.s,I16926760" are the name the programmer knows
and our issue tracking number and I can convert "asm370" to
"-#select_mode IBM HLASM"  But the title bar and file tabs show
"306440"; not very useful to the programmer.  Can these values
be overridden so the file tabs show "SWSRDMG.s,I16926760"?
(I'm not very hopeful.)

I like this forum's user interface.  Much better than others I deal with.

Thanks,
gil
Title: Re: filetype not in filename
Post by: Clark on December 20, 2014, 09:34:48 PM
Try the docname command on the SlickEdit command line. It allows you to set the display name without effecting the filename on disk. You can append another "-#docname the name" argument to the invocation.
Title: Re: filetype not in filename
Post by: hs2 on December 20, 2014, 11:37:03 PM
docname is nice :) New in v19 ?
HS2
Title: Re: filetype not in filename
Post by: Clark on December 21, 2014, 01:37:23 PM
No. It's very old. Originally it was for OEM customers that were pulling file data out of data bases and not opening files.
Title: Compare Buffers (was: filetype not in filename)
Post by: Paul Gilmartin on May 26, 2015, 07:54:13 PM
I've been silent since December because:
o I got very satisfactory solutions, to use docname and
  -#selectmode.
o We were on V.16, probably stale.  Now on V.19, so:

I open two buffers where docname has only a very tenuous
relation to actual path.  Then I attempt tools->File Difference.
On each buffer, from the rightmost small icon, "Choose a
Buffer", I select one of my buffers and click "OK".  Then I
click "OK" at the lower left of the dialog window.  Fails with:

    Could not open file
    '(docname is displayed)
    (File)'

    New file

I could hope that when I select two buffers to compare,
VSlick would compare the contents of the buffers, and not
treat the docnames as paths.

Is there a way to make this work?

Thanks,
gil






Title: Re: filetype not in filename
Post by: Dan on May 27, 2015, 01:48:09 PM
This will be fixed for the next hotfix.
Title: Re: filetype not in filename
Post by: Clark on May 27, 2015, 02:43:41 PM
The "Path 2" text box seems to handle doc names correctly but not the "Path 1" text box. This won't help you if both files specify doc names.
Title: Re: filetype not in filename
Post by: Paul Gilmartin on May 27, 2015, 03:16:17 PM
Thanks for your swift reply.

How quickly do hotfixes become available?  (Of course, "it depends" ...)
Do I get notified?  Will the prior cumulative hotfix (Feb. 12) be prerequisite?

This is not mission critical for us.  Our users are accustomed to extracting
to regular files for diffing; I was just trying to shortcut the procedure
for them.

Thanks again,
gil
Title: Re: filetype not in filename
Post by: Paul Gilmartin on November 24, 2015, 01:20:36 AM
Wondering ... Is the hotfix for this available yet?

Thanks,
gil
Title: Re: filetype not in filename
Post by: Dan on November 24, 2015, 01:38:47 PM
This is fixed on our 19.0.1 branch and should be in the latest hotfix.  It's in v20 as well (if you have maintenance).