This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [h-e-w] Re: new-style Cygwin symlinks, NTEmacs' dired mode, and ls-lisp.el

On Thu, 4 Jul 2002 18:47:10 -0400 , Underwood, Jonathan <> wrote:
> I've not really tried hard using it, but doesn't something like 
> 	(setq ls-lisp-use-insert-directory-program t) 
> make emacs use cygwin ls for dired, which by it's nature would understand
> cygwin symlinks? 
> (as long as emacs knows where to find ls)
> No doubt i'm missing lots of subtelties with this though :)

I'm using Cygwin's `ls' instead of NTemacs ls-lisp (It is slower).

To overcome some (not ALL) of the subtleties I wrote these functions
that replace built-in commands:

(defun make-symbolic-link (FILENAME LINKNAME &optional OK-IF-EXISTS)
           "ln"                        ;; ln command
           nil nil nil                 ;; input / buffer / re-display
           "-s" FILENAME LINKNAME))    ;; ln arguments (-s from to)

;; note the my function ignores OK-IF-EXISTS completely 
;;         i.e. It never overwrite existing symbolic link

(defun file-symlink-p (FILENAME)       ;; replacement for cygwin32
  "Return non-nil if file FILENAME is the name of a symbolic link.
The value is the name of the file to which it is linked.
Otherwise returns nil."
       (if (not (stringp FILENAME))
           (error "File name must be a string"))
       (let* ((sv-buf (current-buffer))
              (sbuf (get-buffer-create " * symbolic-check *"))
           (set-buffer sbuf)           ;; work in temp buf
           (set-buffer-multibyte nil)  ;; no multi bytes !!
           (delete-region (point-min) (point-max))     ;; clear it
               "/bin/ls"               ;; ls command
               nil sbuf nil            ;; input / buffer / re-display
               "-al" FILENAME)         ;; ln arguments (-s from to)
           (goto-char (point-min))
           (and (looking-at "l")
                (search-forward " -> " nil t)
                (re-search-forward ".*$" nil t)
                (setq link (buffer-substring (match-beginning 0) (match-end 0))))
           (set-buffer sv-buf)
           (kill-buffer sbuf)

(defun file-executable-p (FILENAME)
"Hacked for cygwin bash on W9x/NT by Ehud Karni <>
Return t if FILENAME can be executed by you.
For a directory, this means you can access files in that directory."
       (if (boundp 'file-executable-p-called)
           (let ((file-executable-p-called 'on))
               (if (= (call-process "test"     ;; bash test command
                           nil nil nil         ;; input / buffer / re-display
                           "-x" FILENAME)      ;; test arguments
                           0)                  ;; exit status 0 - executable
                   t nil))))

;; this does not solve the call-process (scripts are not identified) problem


 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail  FAX:  1-815-5509341  / \          Better  Safe  Than  Sorry

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]