Author Topic: Change to current dir variable?  (Read 3774 times)

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Change to current dir variable?
« on: July 03, 2007, 02:49:35 pm »
Hello,

I know there is a variable that says "make the current dir the dir of the current buffer", but I can't remember what it is.  I can't find it in the Help, and Search on this forum seems to ignore underscores (i. e., "_def" is the same as "def").

TIA.

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Change to current dir variable?
« Reply #1 on: July 03, 2007, 04:19:32 pm »
Have a look at your own posting  ;D
http://community.slickedit.com/index.php?topic=298.msg1144#msg1144
(It's def_switchbuf_cd)

HS2

jporkka

  • Senior Community Member
  • Posts: 136
  • Hero Points: 6
Re: Change to current dir variable?
« Reply #2 on: July 03, 2007, 07:31:40 pm »
They way you are supposed to do this is set the macro variable def_switchbuf_cd.
However, this option is very unreliable and there are several ways in which it fails.

Since before version 8 I've been adding this line of code to several SlickEdit functions include gui_open, gui_save_as and gui_find:

   cd(strip_filename(p_buf_name,'N'),'');

This is very effective.
 

I've reported this at least a couple of times to Slickedit before V12, and this is still a problem in VS12 - so I
still have to add this code to guifind, guiopen, etc.

Example: RUn VS. Open C:\foo\bar\a.c
From a cmd window,
   cd C:\blat
   vs Another.c

Now, in VS the current buffer is Another.c
From VS, File->Open
note that the current directory is C:\foo\bar instead of C:\blat

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Change to current dir variable?
« Reply #3 on: July 03, 2007, 11:54:24 pm »
@jporkka:
This could be 'solved' more easily using Slick's callback mechanism and w/o patching product sources.
See (and load or merge with your personal macro collection) the attached module which implements a '_switchbuf_' callback I wrote time ago (some comments inline).
It ensures that the PWD (all dialogs, Open TB, build window,... I hope ;)) follows the curr. buffer.

Have fun,
HS2

Edit: The callback also contains a workaround for the (my preferred) current line box setup 'Syntax indent ruler' for (fundamental) buffers not supporting syntax indentation. For these buffers 'Tab ruler' is used as fallback, which is IMO better than not displaying any ruler ticks.
Just remove the few lines in case it's not what you want.
« Last Edit: July 04, 2007, 12:29:47 am by hs2 »

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Change to current dir variable?
« Reply #4 on: July 04, 2007, 02:02:34 am »
Have a look at your own posting  ;D
http://community.slickedit.com/index.php?topic=298.msg1144#msg1144
(It's def_switchbuf_cd)

HS2

Thanks for the pointer to what I knew I once knew.  As I mentioned, "_def" and "def_" seem to be the same as "def" when searching this forum.  Of course, a search for "def" returns way to too much noise...


hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Change to current dir variable?
« Reply #5 on: July 04, 2007, 09:06:58 am »
@Wanderer: To be honest I digged into the sources to find it's real name, but I knew that it was already mentioned in the forums.
Just out of curiosity I searched for it again ... and found your posting :)

HS2