delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/08/10:50:16

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 8 Jul 2002 17:15:52 +0300
Message-Id: <200207081415.g68EFqY15650@unix.simonwiesel.co.il>
From: "Ehud Karni" <ehud AT unix DOT simonwiesel DOT co DOT il>
To: Underwood AT unix DOT simonwiesel DOT co DOT il, Jonathan DOT Underwood AT nrc DOT ca
Cc: F DOT J DOT Wright AT qmul DOT ac DOT uk, swift AT alum DOT mit DOT edu, cygwin AT cygwin DOT com,
help-emacs-windows AT gnu DOT org
Subject: Re: [h-e-w] Re: new-style Cygwin symlinks, NTEmacs' dired mode, and ls-lisp.el
In-reply-to: <4ECDBDADC86CD311AEA20004AC4CA503015DDA52@nrcssxex1.imsb.nrc.ca> (Underwood)
Organization: Mivtach-Simon Insurance agencies
Reply-to: ehud AT unix DOT simonwiesel DOT co DOT il
References: <4ECDBDADC86CD311AEA20004AC4CA503015DDA52 AT nrcssxex1 DOT imsb DOT nrc DOT ca>
MIME-Version: 1.0

On Thu, 4 Jul 2002 18:47:10 -0400 , Underwood, Jonathan <Jonathan DOT Underwood AT nrc DOT ca> 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)
       (interactive)
       (call-process
           "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 *"))
               link)
           (set-buffer sbuf)           ;; work in temp buf
           (set-buffer-multibyte nil)  ;; no multi bytes !!
           (delete-region (point-min) (point-max))     ;; clear it
           (call-process
               "/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)
           link))

(defun file-executable-p (FILENAME)
"Hacked for cygwin bash on W9x/NT by Ehud Karni <ehud AT unix DOT simonwiesel DOT co DOT il>
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)
           t
           (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.


-- 
 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
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:ehud AT unix DOT simonwiesel DOT co DOT il          Better  Safe  Than  Sorry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019