annotate lisp/efs/efs-fnh.el @ 205:92f8ad5d0d3f r20-4b1

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