Author Topic: Newbie screwup (but it still kind of a bug (I think))  (Read 6655 times)

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Newbie screwup (but it still kind of a bug (I think))
« on: December 29, 2006, 03:05:18 am »
Well, chalk this one up to "a little knowledge is dangerous".

I'm evaluating slickedit as a replacement for codewright, with brief key mapping. I didn't realize that Alt-E was already mapped to the quick non-gui edit (which doesn't *always* show up). So, I went about trying to record a macro that would be like it and I named it "edit" and I mapped it to Alt-E. Well, if you try doing so, the next time se is loaded you'll get "Procedure edit not found file restore.ex 91 offset=3794".

I readily acknowledge I shouldn't have done what I did, but, the only way I saw a way out was re-installing.

On a separate topic, the only think stopping me from buying se is if I can't modify the quick edit dialog such that it expand environment variables (which I did in Codewright). Using the examples below, would this be possible?

Thank (the product is great!).

HOME=c:/usr1/dir
VARA=c:/xxx
VARB=yyy

edit $HOME/foo.java === c:/usr1/dir/foo.java
edit $VARA/$VARB/abc.java == c:/xxx/yyy/abc.java




Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #1 on: December 29, 2006, 06:18:22 am »

I'm not sure what you mean by the "quick edit dialog" but you can use the ed command below on the slickedit command line.

As you found out, edit (aka e) is an existing function, so I've used ed for the name.  Not sure what name_info attributes I need so I haven't put any.  I think the help file is missing the info on what 'parse' does but you can find it here
http://community.slickedit.com/index.php?topic=181.msg644#msg644

The string sequence '[/\\],'U'  specifies a Unix regular expression that matches either forward or backslash.
One way to find if a function name has already been used is to type fp somename on the command line and slick will take you to the somename function if it exists - or use find_index.

Code: [Select]
_command void ed() name_info(',')
{
   _str s1 = arg(1);
   _str r2 = '';
   _str r1, s2;
   while(1)
   {
      parse s1 with r1 '$' s2 '[/\\]','U' s1;
      if (s2 != '') {
         r2 = r2 :+ r1 :+ get_env(s2) :+ '/';
      }
      else
         break;
   }
   r2 = r2 :+ r1;
   edit(maybe_quote_filename(r2));
}

Graeme

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #2 on: December 29, 2006, 08:11:47 am »

Forgot to mention, to load this code, add it to vusrmacs.e in your configuration directory (see help about for the name) and load vusrmacs.e using the load module command on the macro menu. 
Also, add the line
#include "slick.sh"
at the start of vusrmacs.e, if it's not already there.

Graeme

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #3 on: December 29, 2006, 03:08:22 pm »
Graeme,

Thank you very much for the code. What I meant by "quick edit" is the "edit" command in Bind Command to Key. Speaking of your code, using XP, is there an easy way to universally set se such that it can use forward slash just as easily as backslash when trying to open/save a file? If fact, se works correctly if you use a drive letter - c:/foo/abc.java - but doesn't work if you just say /foo/abc.java.

Steve

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #4 on: December 29, 2006, 09:24:15 pm »
Graeme,

Thank you very much for the code. What I meant by "quick edit" is the "edit" command in Bind Command to Key. Speaking of your code, using XP, is there an easy way to universally set se such that it can use forward slash just as easily as backslash when trying to open/save a file? If fact, se works correctly if you use a drive letter - c:/foo/abc.java - but doesn't work if you just say /foo/abc.java.

Steve

The default file open and save dialogs are provided by Windows where leading forward slash doesn't get you to the root of the drive as you say.  You can change to the alternative open and save dialogs from Tools -> options -> general -> "more tab" -> windows 3.1 style open dialog but this also doesn't treat leading forward slash the same as leading backslash  - but you can modify slick code to change this if you're really keen  e.g. in frmopen.e _openfn.on_change you can probably manipulate the 'text' string  - but I think it's too much trouble for too little gain.  You could try a Windows newsgroup about this  - maybe there's a registry setting that affects this.

You can easily change the code I wrote to convert a leading forward slash to backslash - check the pos, strip and substr functions in the help - or see the "string functions" topic in the help - it's under "macro functions by category" in the "contents".

Graeme

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #5 on: December 29, 2006, 09:34:23 pm »
Graeme,

Actually you code works fine thank you - with / or \ ! I'm so very conflicted regarding / on Windows because I use MKS Toolkit, which has unix-like Korn shell. So, a forward slash is very natural (and better  ;D). But I suspect I'm part of a minority, so cest la vie.

Now, this maybe asking too much from you, but what's missing (I did this in Codewright) is that I can't do tab expansion of the string, e.g., ed $HOME/[tab] === edit c:/usr/abc/[tab] or $HOME/s[tab] === edit c:/usr/abc/s[tab]. So close ...

Thanks again for you help.

Steve

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #6 on: December 29, 2006, 10:05:02 pm »

You've lost me - how do you get from ed $HOME/[tab]   to   edit c:/usr/abc/[tab]

Does tab cycle through possible completions as it does in Win XP "DOS box" cmd.exe shell - or what is it doing?

BTW - you could also look at _unix_expansion function in SE  - try setting the def_unix_expansion variable to one (type set-var on the SE cmd line, then the name def_unix_expansion, then the value 1)  -  don't know if it's what you want - it affects more than just the edit command.

Graeme

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #7 on: December 29, 2006, 10:26:41 pm »
I'm sorry about my poor explanation. If using CUA, I type Alt-E c:/usr2/park/S[tab], SE brings a dialog "Select Command Parameter", showing files that start with S. Likewise, if HOME=c:/usr2/park, then I'd like ed $HOME/S[tab] to do the same thing. See attached

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #8 on: December 29, 2006, 10:47:57 pm »

Try enabling def_unix_expansion that I mentioned before.  It seems to do what you want  - if not, you could experiment with adding a call to "prompt" (as the SE edit function does) to the code I wrote.  I don't know what to would take to get this to work - it looks a bit "involved".

Graeme

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #9 on: December 29, 2006, 11:07:29 pm »
The tab prompting issue is *nix/dos independent (I will try def_unix_expression). I did try using prompt but to no avail. I do agree that it looks quite involved, so I give up. The ability to use environment variables is *really nice* to have in other commands, e.g., chdir $dir/x.java, write $var/y.java. And given that I'm navigating all over the place, this might be one of those "so close yet so far" regarding walking away from Codewright. Thanks again.




Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #10 on: December 29, 2006, 11:14:56 pm »
If you're evaluating SE, their official support would be worth a try.  I think they're always interested to hear what CodeWright can do that SE can't.

Graeme

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: Newbie screwup (but it still kind of a bug (I think))
« Reply #11 on: December 29, 2006, 11:36:35 pm »
Will do ...