annotate lisp/efs/efs-fnh.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents
children 8b8b7f3559a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: efs-fnh.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Version: $Revision: 1.3 $
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Description: Look for the emacs version, and install into
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; the file-name-handler-alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; Author: Sandy Rutherford <sandy@ibm550.sissa.it>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;; Although used by efs, these utilities could be of general use to other
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15 ;;; packages too. Keeping them separate from the main efs program
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;;; makes it easier for other programs to require them.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 (provide 'efs-fnh)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 (defconst efs-fnh-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 (concat (substring "$efs release: 1.15 $" 14 -2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 "/"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 (substring "$Revision: 1.3 $" 11 -2)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;;;; ----------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;;;; Loading emacs version files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 ;;;; ----------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (defun efs-handle-emacs-version ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 ;; Load appropriate files for the current emacs version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 (let ((ehev-match-data (match-data)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 (let ((lucidp (string-match "Lucid" emacs-version))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 ver subver)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 (or (string-match "^\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (error "efs does not work with emacs version %s" emacs-version))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 (setq ver (string-to-int (substring emacs-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 (match-beginning 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 (match-end 1)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 subver (string-to-int (substring emacs-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 (match-beginning 2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 (match-end 2))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 ;; Lucid XEmacs (emacs-version looks like \"19.xx XEmacs Lucid\")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (lucidp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 ((and (= ver 19) (>= subver 11) (< subver 15))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (require 'efs-l19\.11))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 ((and (= ver 19) (>= subver 15))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (require 'efs-x19\.15))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 ((= ver 20)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 (require 'efs-x19\.15))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 "efs does not work with emacs version %s" emacs-version))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 ;; Original GNU Emacs from FSF
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 ((and (= ver 19) (<= subver 22))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 (require 'efs-19))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 ((and (= ver 19) (>= subver 23))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 (require 'efs-19\.23))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 ;; GNU Emacs 18-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 ((<= ver 18)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 (require 'efs-18)) ; this file will (require 'emacs-19)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 (t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 (error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 "efs does not work with emacs version %s" emacs-version))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 (store-match-data ehev-match-data))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 ;;;; --------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 ;;;; Stuff for file name handlers.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 ;;;; --------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80 ;;; Need to do this now, to make sure that the file-name-handler-alist is
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 ;;; defined for Emacs 18.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (efs-handle-emacs-version)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 ;; Also defined in efs-cu.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 (defvar efs-path-root-regexp "^/[^/:]+:"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 "Regexp to match the `/user@host:' root of an efs full path.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 (defun efs-file-name-handler-alist-sans-fn (fn)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 ;; Returns a version of file-name-handler-alist without efs.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (delq nil (mapcar
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (lambda (x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (and (not (eq (cdr x) fn)) x)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 file-name-handler-alist)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 (defun efs-root-handler-function (operation &rest args)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 "Function to handle completion in the root directory."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (let ((handler (get operation 'efs-root)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (if handler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (apply handler args)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 (let ((inhibit-file-name-handlers
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (cons 'efs-root-handler-function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 (and (eq inhibit-file-name-operation operation)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 inhibit-file-name-handlers)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 (inhibit-file-name-operation operation))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (apply operation args)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (put 'file-name-completion 'efs-root 'efs-root-file-name-completion)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (put 'file-name-all-completions 'efs-root 'efs-root-file-name-all-completions)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (autoload 'efs-root-file-name-all-completions "efs-netrc")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (autoload 'efs-root-file-name-completion "efs-netrc")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (autoload 'efs-file-handler-function "efs"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 "Function to use efs to handle remote files.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 ;; Install into the file-name-handler-alist.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 ;; If we are already there, remove the old entry, and re-install.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 ;; Remove the ange-ftp entry too.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (setq file-name-handler-alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (let (dired-entry alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 (setq alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 (nconc
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 (cons efs-path-root-regexp 'efs-file-handler-function)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 '("^/$" . efs-root-handler-function))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (delq nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (mapcar
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (lambda (x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 (if (eq (cdr x) 'dired-handler-fn)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (setq dired-entry x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (and (not
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 (memq (cdr x)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 '(efs-file-handler-function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 efs-root-handler-function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 ange-ftp-hook-function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 ange-ftp-completion-hook-function)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 x))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 file-name-handler-alist))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 ;; Make sure that dired is in first.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 (if dired-entry (cons dired-entry alist) alist)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 ;;; end of efs-fnh.el