Re: Relative symlinks
- From: Anton Monroe <akm meer net>
- To: MC development <mc-devel gnome org>
- Subject: Re: Relative symlinks
- Date: Thu, 13 Apr 2006 17:39:17 -0500
On Thu, Apr 13, 2006 at 06:16:14PM +0200, Leonard den Ottolander wrote:
> Same problem ;) . Please resubmit with the patch as an attachment.
> Thanks.
Try this;
--- doc/mc.1.in
+++ doc/mc.1.in
@@ -297,6 +297,13 @@
.B C-x s
run the symbolic link command.
.TP
+.B C-x v
+run the relative symbolic link command. See the
+.\"LINK2"
+File Menu
+.\"File Menu"
+section for more information about symbolic links.
+.TP
.B C-x i
set the other panel display mode to information.
.TP
@@ -973,6 +980,23 @@
option is enabled. Use symbolic links when you want to avoid the
confusion that can be caused by hard links.
.PP
+When you press (C-x s) Midnight Commander will automatically fill in the
+complete path+filename of the original file and suggest a name for the link.
+You can change either one.
+.PP
+Sometimes you may want to change the absolute path of the original into
+a relative path. An absolute path starts from the root directory:
+.PP
+.I /home/frodo/mc/mc -> /home/frodo/new/mc
+.PP
+A relative link describes the original file's location starting from the
+location of the link itself:
+.PP
+.I /home/frodo/mc/mc -> ../new/mc
+.PP
+You can force Midnight Commander to suggest a relative path by pressing
+(C-x v) instead of (C-x s).
+.PP
.B Rename/Move (F6, F16)
.PP
Press F6 to pop up an input dialog to copy the currently selected file (or
--- src/cmd.c
+++ src/cmd.c
@@ -914,7 +914,8 @@ do_link (int symbolic_link, const char *
char *s;
char *d;
- /* suggest the full path for symlink */
+ /* suggest the full path for symlink, and either the full or
+ relative path to the file it points to */
s = concat_dir_and_file (current_panel->cwd, fname);
if (get_other_type () == view_listing) {
@@ -923,6 +924,10 @@ do_link (int symbolic_link, const char *
d = g_strdup (fname);
}
+ if ( 2 == symbolic_link) {
+ s = diff_two_paths ((other_panel->cwd),s);
+ }
+
symlink_dialog (s, d, &dest, &src);
g_free (d);
g_free (s);
@@ -957,6 +962,16 @@ void symlink_cmd (void)
}
}
+void relative_symlink_cmd (void)
+{
+ char *filename = NULL;
+ filename = selection (current_panel)->fname;
+
+ if (filename) {
+ do_link (2, filename);
+ }
+}
+
void edit_symlink_cmd (void)
{
if (S_ISLNK (selection (current_panel)->st.st_mode)) {
--- src/cmd.h
+++ src/cmd.h
@@ -40,6 +40,7 @@
void tree_cmd (void);
void link_cmd (void);
void symlink_cmd (void);
+void relative_symlink_cmd (void);
void edit_symlink_cmd (void);
void reverse_selection_cmd (void);
void unselect_cmd (void);
--- src/main.c
+++ src/main.c
@@ -1235,6 +1235,7 @@ static const key_map ctl_x_map[] = {
{XCTRL ('r'), copy_other_readlink},
{'l', link_cmd},
{'s', symlink_cmd},
+ {'v', relative_symlink_cmd},
{XCTRL ('s'), edit_symlink_cmd},
{'i', info_cmd_no_menu},
{'q', quick_cmd_no_menu},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]