Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trouble following symbolic links

1 view
Skip to first unread message

Hunan McNair

unread,
Jan 8, 2001, 6:12:49 PM1/8/01
to
I am using Emacs 20.7 and bash 2.04 under W98. When using symbolic
links to directories, Emacs is not able to resolve the links for file
name completion. I have tried re-synching the directories to no avail.
As a result, I am unable to access the directory within Emacs.

As a workaround, I use a bash window outside emacs to identify the
physical file names.

Can Emacs resolve symbolic links defined in bash?

TIA

Hunan McNair


Sent via Deja.com
http://www.deja.com/

Benjamin Rutt

unread,
Jan 8, 2001, 6:45:35 PM1/8/01
to
Hunan McNair <porsc...@my-deja.com> writes:

> I am using Emacs 20.7 and bash 2.04 under W98. When using symbolic
> links to directories, Emacs is not able to resolve the links for file
> name completion. I have tried re-synching the directories to no avail.
> As a result, I am unable to access the directory within Emacs.
>
> As a workaround, I use a bash window outside emacs to identify the
> physical file names.
>
> Can Emacs resolve symbolic links defined in bash?

I am assuming you mean cygwin bash environment. If you go to a dos
command prompt, you can execute

c:\>type symlink

where symlink is the symlink file. You will see that it contains (as
text) the location of the true file. My theory is that since emacs
makes API calls to windows directly for things like find-file (and
doesn't go through cygwin at all), it cannot possibly know what to do
with a cygnus symlink file, since the windows API knows nothing about
that. Running a bash shell in emacs via M-x shell will work but not
things like find-file AFAIK.

Benjamin

Eli Zaretskii

unread,
Jan 9, 2001, 3:57:49 AM1/9/01
to
Hunan McNair wrote:
>
> I am using Emacs 20.7 and bash 2.04 under W98. When using symbolic
> links to directories, Emacs is not able to resolve the links for file
> name completion. I have tried re-synching the directories to no avail.
> As a result, I am unable to access the directory within Emacs.

The symlink support in Cygwin ports of Bash (and other Unix-born software)
is simulated, since Windows doesn't support symlinks. That simulation is
a Cygwin-only feature; since NTEmacs was not compiled with Cygwin, it
doesn't know about any symlinks.

> Can Emacs resolve symbolic links defined in bash?

No.

As a general rule, I'd suggest not to use symlinks on Windows at your own
initiative, except if you don't have any non-Cygwin programs involved. If
non-Cygwin programs _are_ involved, I suggest to restrict symlink use to
shell scripts and ported programs which create symlinks for their own
use. That should work, at least most of the time.

David Masterson

unread,
Jan 9, 2001, 12:15:44 PM1/9/01
to
>>>>> "Hunan" == Hunan McNair <porsc...@my-deja.com> writes:

> I am using Emacs 20.7 and bash 2.04 under W98. When using symbolic
> links to directories, Emacs is not able to resolve the links for file
> name completion. I have tried re-synching the directories to no avail.
> As a result, I am unable to access the directory within Emacs.

> As a workaround, I use a bash window outside emacs to identify the
> physical file names.

> Can Emacs resolve symbolic links defined in bash?

I haven't fully tested this, but it seems to work. The trick is to
use find-file-hooks to process the file and find-alternate-file:

; make cygwin symlinks accessible
(defun follow-cygwin-symlinks ()
"Put your useful comment here."
(save-excursion
(goto-char 0)
(if (looking-at "!<symlink>")
(progn
(re-search-forward "!<symlink>"\\(.*\\)\0")
(find-alternate-file (match-string 1)))
)))
(add-hook 'find-file-hooks 'follow-cygwin-symlinks)

--
David Masterson (dmas...@rational.com)
Rational Software (but I don't speak for them)

Eli Zaretskii

unread,
Jan 9, 2001, 12:49:44 PM1/9/01
to
David Masterson wrote:
>
> I haven't fully tested this, but it seems to work. The trick is to
> use find-file-hooks to process the file and find-alternate-file:

I'd advise against this. There are primitives in Emacs that work with
files, but don't go through find-file. A notable example is call-process.
It is more confusing and error-prone IMHO to have some feature working
sometimes than having it not working at all.

Simply say NO to symlinks on Windows. They are not there.

Hunan McNair

unread,
Jan 10, 2001, 10:33:18 PM1/10/01
to
In article <3A5B4F38...@is.elta.co.il>,

Consider it done! Thanks for all your input.

0 new messages