* Re: Recognising Symbolic Links under Windows XP
@ 2005-07-19 10:20 LENNART BORGMAN
0 siblings, 0 replies; 4+ messages in thread
From: LENNART BORGMAN @ 2005-07-19 10:20 UTC (permalink / raw)
Cc: help-gnu-emacs
From: davin.pearson@gmail.com
> To Richard Stallman and others...
>
> I have been using Emacs for years and in my opinion it is
> something of
> a religion!
>
> I was recently using Emacs under Gnu/Linux where I learnt about
> symbolic links and how useful they are.
>
> These days I am mainly using Emacs under Windows XP so I wondered if
> it was possible for Emacs to recognise Windows-style symbolic links
> (*.lnk files)
>
> The Cygwin shell and the Windows Explorer recognises *.lnk files
> so I
> thought it would be a good thing if Emacs could be made to recognise
> *.lnk files.
Did you see WThirtyTwoSymlinks on EmacsWiki:
http://www.emacswiki.org/cgi-bin/wiki/WThirtyTwoSymlinks
There also a discussion about symlinks here:
http://lists.trolltech.com/qt-interest/2003-08/thread00550-0.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Recognising Symbolic Links under Windows XP
@ 2005-07-19 9:43 davin.pearson
2005-07-19 11:20 ` Mathias Dahl
0 siblings, 1 reply; 4+ messages in thread
From: davin.pearson @ 2005-07-19 9:43 UTC (permalink / raw)
To Richard Stallman and others...
I have been using Emacs for years and in my opinion it is something of
a religion!
I was recently using Emacs under Gnu/Linux where I learnt about
symbolic links and how useful they are.
These days I am mainly using Emacs under Windows XP so I wondered if
it was possible for Emacs to recognise Windows-style symbolic links
(*.lnk files)
The Cygwin shell and the Windows Explorer recognises *.lnk files so I
thought it would be a good thing if Emacs could be made to recognise
*.lnk files.
After a little bit of C++ and Lisp coding a came up with a solution.
All that you need is a C/C++ program that parses the *.lnk file and
returns via stdout the name of the file/directory that the link points
to.
Suppose that the name of the C/C++ program is d:/bin/lnk.exe.
Then the following snippet of Lisp code achieves the result of taking
you (inside Emacs) to the target of the *.lnk file:
The following code snippet is inside a "cond" form:
((string-match "\\.lnk$" filename)
(shell-command (concat "d:/bin/lnk.exe \"" filename "\""))
(setq buf (set-buffer "*Shell Command Output*"))
(goto-char (point-min))
(setq output (my-find--current-line))
(cond ((string-match "Usage:" output)
(message output))
((file-exists-p output)
(find-file output))
(t
(message "Cannot find file: %s" output)))
(kill-buffer buf))
This is all good for my own private purposes but I realise that for my
idea to be included in the standard Gnu Emacs that it must also be
robust.
I have no idea what the format of the *.lnk files is, and a robust
program would have to support all possible examples.
Here is the source code to my lnk.exe file:
> #include "../../2003/noio/io.hh"
>
> int main(int argc, char** argv)
> {
> const char* usage = "Usage: lnk FILENAME.LNK\n";
>
> if (argc != 2) {
> std::cout << usage;
> exit(EXIT_FAILURE);
> }
>
> const char* filename = argv[1];
> int len = strlen(filename);
>
> const char* last_four = filename + len - 1 - 4;
> if (0 == strcmp(last_four, ".lnk")) {
> std::cout << usage;
> exit(EXIT_FAILURE);
> }
>
> FILE* f = fopen(filename,"rb");
>
> string_buffer sb;
> int ch;
> while ((ch = fgetc(f)) != -1) {
> if ((ch >= 0x20) && (ch <= 0x7f)) {
> sb << (char)ch;
> }
> }
>
> int i = index_of(sb, ":\\") - 1;
>
> ASSERT(i != -1);
>
> string link = substring(sb, i, sb.get_length());
>
> cout << link << '\n';
>
> exit(EXIT_SUCCESS);
> }
> END_OF_MAIN();
>
Sorry about the usage of my non-standard I/O library, but it would not
be to hard to rewrite this code to use either C or C++ I/O libraries.
Please tell me if you think my idea is a good one!
-*-
P.S. Another idea for making Emacs better would be for dabbrev-expand
to search through the kill ring for possible completions.
Regards,
Davin Pearson http://www.davinpearson.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recognising Symbolic Links under Windows XP
2005-07-19 9:43 davin.pearson
@ 2005-07-19 11:20 ` Mathias Dahl
0 siblings, 0 replies; 4+ messages in thread
From: Mathias Dahl @ 2005-07-19 11:20 UTC (permalink / raw)
davin.pearson@gmail.com writes:
> I was recently using Emacs under Gnu/Linux where I learnt about
> symbolic links and how useful they are.
>
> These days I am mainly using Emacs under Windows XP so I wondered if
> it was possible for Emacs to recognise Windows-style symbolic links
> (*.lnk files)
FYI, there is something called "junctions" that NTFS supports. It
works more or less like symbolic links on GNU/Linux or Unix
systems. You need a special command line tool to create them.
You can find one such tool here:
http://www.sysinternals.com/Utilities/Junction.html
I use it to make a symbolic link from my "emacs-22.xyz..." to a folder
with the simpler name "emacs", and it works great.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-07-21 6:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.977.1121768789.20277.help-gnu-emacs@gnu.org>
2005-07-21 6:53 ` Recognising Symbolic Links under Windows XP davin.pearson
2005-07-19 10:20 LENNART BORGMAN
-- strict thread matches above, loose matches on Subject: below --
2005-07-19 9:43 davin.pearson
2005-07-19 11:20 ` Mathias Dahl
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.