Author Topic: Sync'ing the Current Dir (in File Open pane) with a document's path  (Read 10201 times)

JohnGalt

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
It there a built-in command, or an add-in, that will cause the Current Directory (in left-side File Open pane) to be sync'ed with the currently selected document Window?  It would be nice if this could be either automatic or on-demand, but I would be happy with at least one of these.  I am using CUA mode.

Thanks in advance for any help.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #1 on: July 26, 2006, 06:12:06 AM »
I created these 2 macros for that purpose.
cdb == cd to current buffer
cdp == cd to project dir
Code: [Select]
_command void cdb() name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   // @see cd_to_file_dir ()
   _str newdir=strip_filename (p_buf_name,'N');
   if ( last_char (newdir)==FILESEP ) newdir=substr (newdir,1,length (newdir)-1);
   if ( (newdir != '') && (getcwd () != newdir) )
   {
      cd (newdir, 'm');
      // HS2: added to sync with 'Open' tab in project toolbar and process buffer
      _cd_tbopen ();
      _process_cd (newdir);
   }
}

_command void cdp () name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   _str cwd=_ProjectGet_WorkingDir (_ProjectHandle (_project_name));
   if ( cwd != '' )
   {
      cwd=absolute (cwd,strip_filename (_project_name,'n'));
      cd (cwd, 'm');
      // HS2: added to sync with 'Open' tab in project toolbar and process buffer
      _cd_tbopen ();
      _process_cd (cwd);
   }
}
Hope this is what you need.
HS2

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #2 on: July 26, 2006, 12:49:08 PM »
SlickEdit has a capability for this built into the GNU Emacs emulation.  You may also enable this in any emulation by using Set Macro Variable or set-var command, and changing def_switchbuf_cd from 0 to 1.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #3 on: July 26, 2006, 01:08:26 PM »
Yes - I knew this cool setting .. but I prefer to stay in my project root normally.
And for some 'special' situations I just use these little helpers.
Thanks, HS2

JohnGalt

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #4 on: July 26, 2006, 07:21:52 PM »
Lee,

That works great!  Thanks!

HS2.... I would love to try your approach but I am new enough to Slickedit (2 days) that I don't even know how to put that code into Slickedit.  I assume once loaded I can assign them to key-strokes.

Can you give me a simple list of steps to perform?
1. Save your text to file (name?  location?  file extension?)
2. Commands in Slickedit to "load"?
3. Name for key-binding assignments?

I am lacking docs at present.  My purchase has not yet been processed.  Thanks for the help.

John

SlickEdit Support

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 384
  • Hero Points: 29
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #5 on: July 26, 2006, 08:02:04 PM »
All of the documentation comes in pdf form when SlickEdit is installed.  It will be in your SlickEdit_Installation\docs directory.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Sync'ing the Current Dir (in File Open pane) with a document's path
« Reply #6 on: July 27, 2006, 08:12:11 AM »
Just a quick tour ;)
1. Put the code into a <file>.e
2. Add #include 'slick.sh' on top. -> That's your 1st macro module - congrats ;)
3. Maybe put it into <Slick Install dir>\macros dir (where all other macros files reside), but it could be located anywhere
4.a Directly do 'Macros > Load Module -> Select your <file>.e'
4.b Drag'nDrop it into Slick or 'Open' the file and invoke the 'load' command on cmdline.
(If the source file is ok, the macro compiler creates a <file>.ex)
5. Use 'Tools -> Options -> Key Bindings' to (re-)assign shortcuts for all the available macros (yours are now included in the list)

That's it !

Good luck, HS2