Author Topic: Opening a file  (Read 3273 times)

mcarlson

  • Community Member
  • Posts: 15
  • Hero Points: 0
Opening a file
« on: September 05, 2008, 08:10:39 pm »
I'm curious if there is a way to have the 'edit' command use the current buffer rather than the last file opened.

What I mean:
Ctrl-x Ctrl-f is bound to the edit command.
I use this to open /user/local/path/foo.c and the file is opened in a new buffer
I then switch to buffer bar.c (/some/other/path/bar.c)
I then want to open a file in the same dir as bar.c

I hit Ctrl-x Ctrl-f and get
Edit: /user/local/path/foo.c (which I have to erase and start over.)

I would like:
Edit: /some/other/path/bar.c (which I would like to be the default.)

Is there some setting I'm missing to make this happen?

So far I've been able to set most anything else imaginable, so I'm feeling a bit foolish for not being able to find this one.

Thank you for your help,
Matt Carlson

Graeme

  • Senior Community Member
  • Posts: 2210
  • Hero Points: 272
Re: Opening a file
« Reply #1 on: September 05, 2008, 09:31:27 pm »
You can make your own ed command like this

Code: [Select]
#include "slick.sh"

#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)


_str _retrieve;

_command void ed() name_info(',')
{
   _str line;
   _str msg = '';
   _str arg_type;
   if (!_no_child_windows()) {
      _retrieve = false;
      msg = _mdi.p_child.p_buf_name;
      //msg = strip_filename(_mdi.p_child.p_buf_name, 'N');
      arg_type = '-FILE';
   } else {
      _retrieve = true;
      arg_type = '-.Ed';
   }
   typeless status=get_string(line,'Ed : ',arg_type, msg);
   if (status == 0) {
      edit(maybe_quote_filename(line));
   }
}


Graeme