From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: find-file, file-name-handler-alist, and FTP URLs Date: Fri, 12 May 2006 11:36:54 -0400 Organization: disorganization Message-ID: Reply-To: sds@podval.org NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: sea.gmane.org 1147448342 12963 80.91.229.2 (12 May 2006 15:39:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 12 May 2006 15:39:02 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 12 17:39:00 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FeZj3-0002F0-2h for ged-emacs-devel@m.gmane.org; Fri, 12 May 2006 17:38:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FeZj2-0006G3-LH for ged-emacs-devel@m.gmane.org; Fri, 12 May 2006 11:38:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FeZhn-0005aP-77 for emacs-devel@gnu.org; Fri, 12 May 2006 11:37:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FeZhl-0005ZE-QW for emacs-devel@gnu.org; Fri, 12 May 2006 11:37:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FeZhl-0005Yr-GZ for emacs-devel@gnu.org; Fri, 12 May 2006 11:37:25 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FeZjW-0001kE-IM for emacs-devel@gnu.org; Fri, 12 May 2006 11:39:14 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FeZhR-0001vz-E3 for emacs-devel@gnu.org; Fri, 12 May 2006 17:37:05 +0200 Original-Received: from 209.213.205.130 ([209.213.205.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 May 2006 17:37:05 +0200 Original-Received: from sds by 209.213.205.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 May 2006 17:37:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-To: emacs-devel@gnu.org Original-Lines: 49 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 209.213.205.130 Mail-Copies-To: never X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:I7SXKj6mFrd+8V/f8ATYd9k+SrA= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54341 Archived-At: Emacs does not handle FTP URLs correctly: (find-file "ftp://ftp.gnu.org/pub/") results in Use M-x make-directory RET RET to create the directory and its parents # the expected behavior is obviously equivalent to (find-file "/ftp.gnu.org:/pub/") here is what I use: (defun sds-url-to-ange-format (str) "Translate from the URL format to ange-ftp/efs format. `\\(ftp\\|file\\)://user:pwd@host:port/path' ==> `/user@host#port:/path'. Only `host' is required. If STR doesn't look like a URL, return STR." (let ((hre "[-a-zA-Z.0-9]+")) (if (string-match (concat "^\\(ftp://\\|file://\\)\\(" hre "\\(:" hre "\\)?@\\)?\\(" hre "\\)\\(:[0-9]+\\)?\\(/[^/]*\\)?") str) (concat "/" (if (match-beginning 2) (concat (substring str (match-beginning 2) (or (match-beginning 3) (- (match-end 2) 1))) "@")) (match-string 4 str) (if (match-beginning 5) (concat "#" (substring str (1+ (match-beginning 5)) (match-end 5)))) ":" (if (match-beginning 6) (substring str (match-beginning 6)))) str))) (defun sds-find-file-url-handler (function filename &rest ignore) (funcall function (sds-url-to-ange-format filename))) (push '("\\`\\(ftp://\\|file://\\)" . find-file-url-handler) sds-file-name-handler-alist) any objections to adding something like that (without the sds prefix, of course)? -- Sam Steingold (http://www.podval.org/~sds) on Fedora Core release 5 (Bordeaux) http://palestinefacts.org http://ffii.org http://honestreporting.com http://jihadwatch.org http://truepeace.org http://camera.org Single tasking: Just Say No.