Re: change dir using a menu command



I did as you advised and added a "%cd" macro, I changed the code to do 2
things:

1. add an environment variable: CDFILE=~/.mc_cdfile
  (I used sprintf(dir_file,"CDFILE=%s/.mc_cdfile", home_dir) in the
   subshell.c file)

2. when the execute_menu_command() sees %cd inside the file it changed
  the variable 'change_dir' to '1' (initial value = 0),
  at the end of the function (after the menu command was executed), it
  searches for the ~/.mc_cdfile, if it exists, then it changes to the
  directory written in it.

I tried to add a remove() command after changing the directory (to
remove the $CDFILE), but for some reason it didn't work (i'm not sure i
did it right).

to use it all one has to write in a menu command is this:

  echo /path/to/new/directory > $CDFILE
  %cd


Anyway, I attached the patch files for subshell.c and user.c for this
feature, I hope this helps, I'm using it for a samba mounter script I 
wrote (also attached to this email).

David E.

On 02:53 Thu 22 Jan     , Pavel Roskin wrote:
On Fri, 16 Jan 2004, David E wrote:

Hi

I've written a samba browser/mounter script, what it does is use
smbclient, to get a list of samba shares, and gives me a list of shares
using 'dialog', when I choose a share it is mounted. I've added a menu
item to the menu file, that will run the program, and I want mc to jump
to the mounted directory, I have looked around, and saw that it was
possible with the $MC_CONTROL_FILE variable, but then I saw that it was
disabled. So I'm wondering how (and if) it is possible.

It's currently impossible.  If you want to add this functionality, see
execute_menu_command() in src/user.c.  You could add a %cd macro in a way
similar to the recently added %view (you'll need the CVS version or
mc-4.6.1-pre1 to see it).  Please note that mc doesn't execute the
commands step by step.  The whole menu entry is put to a script and run as
a whole.

-- 
Regards,
Pavel Roskin
_______________________________________________
Mc mailing list
Mc gnome org
http://mail.gnome.org/mailman/listinfo/mc

Attachment: mc-4.6.1-pre1.patch.subshell_c
Description: Text document

Attachment: mc-4.6.1-pre1.patch.user_c
Description: Text document

Attachment: smb
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]