[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
find-file, file-name-handler-alist, and FTP URLs
From: |
Sam Steingold |
Subject: |
find-file, file-name-handler-alist, and FTP URLs |
Date: |
Fri, 12 May 2006 11:36:54 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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
#<buffer ~/Mail/ftp:/ftp.gnu.org/pub/>
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:address@hidden:port/path' ==> `/address@hidden:/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
"\\)address@hidden)?\\(" 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.
- find-file, file-name-handler-alist, and FTP URLs,
Sam Steingold <=