From ange-ftp-lovers-request%anorman.hpl.hp.com@hplb.hpl.hp.com Thu Oct 1 10:29:36 1992 Received: from hplb.hpl.hp.com by lysator.liu.se with SMTP (5.65c8/1.34/Lysator-3.1) id AA06307; Thu, 1 Oct 1992 10:29:32 +0100 Received: from anorman.hpl.hp.com by hplb.hpl.hp.com; Thu, 1 Oct 92 10:20:05 +0100 Received: from ange-ftp-lovers (list exploder) by anorman.hpl.hp.com (15.11/15.6+ISC) id AA11705; Thu, 1 Oct 92 10:19:12 bst Message-Id: <9210010918.AA11693@anorman.hpl.hp.com> To: ange-ftp-lovers-announce%anorman.hpl.hp.com@hplb.hpl.hp.com Subject: ange-ftp-auto.el v1.5: autoload ability for ange-ftp Date: Thu, 01 Oct 92 10:18:40 BST From: Andy Norman Sender: ange-ftp-lovers-request%anorman.hpl.hp.com@hplb.hpl.hp.com Status: R Included below is the latest version of ange-ftp-auto.el. [ Regulars on the ange-ftp-lovers mailing list will have seen an earlier version of this code. ] If you normally put something like: (require 'ange-ftp) in your .emacs, but don't really want the expense of loading and having ange-ftp around until you really need it, put the replacement line: (require 'ange-ftp-auto) in your .emacs instead. ange-ftp-auto will detect (in nearly all) cases when ange-ftp is wanted, and load it seamlessly, throwing itself away in the process. Packages that explicitly need ange-ftp functionality, like archie.el for example, should continue loading the full ange-ftp as before. As always, please report bugs to either me or ange-ftp-lovers. Thanks. -- ange -- <>< -------------------------------------------------------------------------------- ; -*-Emacs-Lisp-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; File: ange-ftp-auto.el ; RCS: $Header: ange-ftp-auto.el,v 1.5 92/10/01 09:43:57 ange Exp $ ; Description: Simple way of autoloading ange-ftp ; Author: Andy Norman, Dawn ; Created: Thu Sep 24 09:50:08 1992 ; Modified: Thu Oct 1 09:43:47 1992 (Andy Norman) ange@hplb.hpl.hp.com ; Language: Emacs-Lisp ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar ange-ftp-auto-path-format "^/[^/]*[:@]" "*Regular expression possibly matching part of an ange-ftp pathname. If a filename given to `expand-file-name' matches this regexp then ange-ftp will be loaded if needed.") (defun ange-ftp-auto-restore-functions () (if (eq (symbol-function 'ange-ftp-real-expand-file-name) (symbol-function 'ange-ftp-auto-expand-file-name)) (fset 'ange-ftp-real-expand-file-name (symbol-function 'ange-ftp-auto-real-expand-file-name))) (if (eq (symbol-function 'ange-ftp-real-read-file-name-internal) (symbol-function 'ange-ftp-auto-read-file-name-internal)) (fset 'ange-ftp-real-read-file-name-internal (symbol-function 'ange-ftp-auto-real-read-file-name-internal))) ) (defun ange-ftp-auto-read-file-name-internal (string dir action) "Documented as original." (expand-file-name string dir) ;load ange-ftp if needed (if (fboundp 'ange-ftp-real-read-file-name-internal) (read-file-name-internal string dir action) (ange-ftp-auto-real-read-file-name-internal string dir action))) (defun ange-ftp-auto-expand-file-name (file &optional dir) "Documented as original." ;; See if ange-ftp has been loaded by somebody else. If so, nuke us ;; from the calling chain. (if (fboundp 'ange-ftp-real-expand-file-name) (progn (ange-ftp-auto-restore-functions) (ange-ftp-auto-real-expand-file-name file dir)) (let ((match-data (match-data))) (unwind-protect (let ((result (ange-ftp-auto-real-expand-file-name file dir))) (if (or (and (stringp result) (string-match ange-ftp-auto-path-format result)) (and (stringp file) (string-match ange-ftp-auto-path-format file)) (and (stringp dir) (string-match ange-ftp-auto-path-format dir))) (progn (require 'ange-ftp) (ange-ftp-auto-restore-functions) (expand-file-name file dir)) result)) (store-match-data match-data))))) (if (or (featurep 'ange-ftp) (featurep 'ange-ftp-auto)) nil ;; replace expand-file-name (fset 'ange-ftp-auto-real-expand-file-name (symbol-function 'expand-file-name)) (setcar (nthcdr 2 (symbol-function 'ange-ftp-auto-expand-file-name)) (documentation 'ange-ftp-auto-real-expand-file-name)) (fset 'expand-file-name (symbol-function 'ange-ftp-auto-expand-file-name)) ;; replace read-file-name-internal (fset 'ange-ftp-auto-real-read-file-name-internal (symbol-function 'read-file-name-internal)) (setcar (nthcdr 2 (symbol-function 'ange-ftp-auto-read-file-name-internal)) (documentation 'ange-ftp-auto-real-read-file-name-internal)) (fset 'read-file-name-internal (symbol-function 'ange-ftp-auto-read-file-name-internal)) ) (provide 'ange-ftp-auto)