aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-05-03 19:58:10 +0000
committerRichard M. Stallman1997-05-03 19:58:10 +0000
commit41d34bed16caa917a16de46ca1de7e71290e84a0 (patch)
tree2645589d40fdfe9ff81e84b9bdc89b3c4d77bc50
parent94114394685bcb5eedb15288ebe6a715bf1d0eaf (diff)
downloademacs-41d34bed16caa917a16de46ca1de7e71290e84a0.tar.gz
emacs-41d34bed16caa917a16de46ca1de7e71290e84a0.zip
Use defgroup and defcustom.
Many doc fixes. (ffap-next): Fix message.
-rw-r--r--lisp/ffap.el138
1 files changed, 91 insertions, 47 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el
index a4d69ec0eb6..bb4c4612c83 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1,6 +1,6 @@
1;;; ffap.el --- find file or url at point 1;;; ffap.el --- find file or URL at point
2 2
3;; Copyright (C) 1995, 1996 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
4 4
5;; Author: Michelangelo Grigni <mic@mathcs.emory.edu> 5;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
6;; Created: 29 Mar 1993 6;; Created: 29 Mar 1993
@@ -29,7 +29,7 @@
29;; 29;;
30;; Command find-file-at-point replaces find-file. With a prefix, it 30;; Command find-file-at-point replaces find-file. With a prefix, it
31;; behaves exactly like find-file. Without a prefix, it first tries 31;; behaves exactly like find-file. Without a prefix, it first tries
32;; to guess a default file or url from the text around the point 32;; to guess a default file or URL from the text around the point
33;; (`ffap-require-prefix' swaps these behaviors). This is useful for 33;; (`ffap-require-prefix' swaps these behaviors). This is useful for
34;; following references in situations such as mail or news buffers, 34;; following references in situations such as mail or news buffers,
35;; README's, MANIFEST's, and so on. Submit bugs or suggestions with 35;; README's, MANIFEST's, and so on. Submit bugs or suggestions with
@@ -64,12 +64,12 @@
64;; 64;;
65;; (setq ffap-alist nil) ; faster, dumber prompting 65;; (setq ffap-alist nil) ; faster, dumber prompting
66;; (setq ffap-machine-p-known 'accept) ; no pinging 66;; (setq ffap-machine-p-known 'accept) ; no pinging
67;; (setq ffap-url-regexp nil) ; disable url features in ffap 67;; (setq ffap-url-regexp nil) ; disable URL features in ffap
68;; 68;;
69;; ffap uses w3 (if found) or else browse-url to fetch url's. For 69;; ffap uses w3 (if found) or else browse-url to fetch URL's. For
70;; a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site). 70;; a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
71;; Also, you can add `ffap-menu-rescan' to various hooks to fontify 71;; Also, you can add `ffap-menu-rescan' to various hooks to fontify
72;; the file and url references within a buffer. 72;; the file and URL references within a buffer.
73 73
74;;; Todo list: 74;;; Todo list:
75;; * recognize paths inside /usr/bin:/bin:/etc, ./ffap.el:80: 75;; * recognize paths inside /usr/bin:/bin:/etc, ./ffap.el:80:
@@ -101,6 +101,11 @@
101 101
102;;; User Variables: 102;;; User Variables:
103 103
104(defgroup ffap nil
105 "Find file or URL at point."
106 :group 'matching)
107
108
104;; This function is used inside defvars: 109;; This function is used inside defvars:
105(defun ffap-soft-value (name &optional default) 110(defun ffap-soft-value (name &optional default)
106 "Return value of symbol with NAME, if it is interned. 111 "Return value of symbol with NAME, if it is interned.
@@ -110,7 +115,7 @@ Otherwise return nil (or the optional DEFAULT value)."
110 (if (and sym (boundp sym)) (symbol-value sym) default))) 115 (if (and sym (boundp sym)) (symbol-value sym) default)))
111 116
112 117
113(defvar ffap-ftp-regexp 118(defcustom ffap-ftp-regexp
114 (and 119 (and
115 (or (featurep 'ange-ftp) 120 (or (featurep 'ange-ftp)
116 (featurep 'efs) 121 (featurep 'efs)
@@ -119,29 +124,41 @@ Otherwise return nil (or the optional DEFAULT value)."
119 (rassq 'efs-file-handler-function file-name-handler-alist)))) 124 (rassq 'efs-file-handler-function file-name-handler-alist))))
120 ;; Apparently this is good enough for both ange-ftp and efs: 125 ;; Apparently this is good enough for both ange-ftp and efs:
121 "\\`/[^/:]+:") 126 "\\`/[^/:]+:")
122 "*Treat paths matching this as remote ftp paths. Nil to disable. 127 "*Treat paths matching this as remote ftp paths. nil to disable.
123Nil also disables the generation of such paths by ffap.") 128nil also disables the generation of such paths by ffap."
124 129 :type '(choice (const :tag "Disable" nil)
125(defvar ffap-url-unwrap-local t 130 regexp)
126 "*If non-nil, convert \"file:\" url to local path before prompting.") 131 :group 'ffap)
127 132
128(defvar ffap-url-unwrap-remote t 133(defcustom ffap-url-unwrap-local t
129 "*If non-nil, convert \"ftp:\" url to remote path before prompting. 134 "*If non-nil, convert \"file:\" URL to local path before prompting."
130This is ignored if `ffap-ftp-regexp' is nil.") 135 :type 'boolean
131 136 :group 'ffap)
132(defvar ffap-ftp-default-user 137
138(defcustom ffap-url-unwrap-remote t
139 "*If non-nil, convert \"ftp:\" URL to remote path before prompting.
140This is ignored if `ffap-ftp-regexp' is nil."
141 :type 'boolean
142 :group 'ffap)
143
144(defcustom ffap-ftp-default-user
133 (if (or (equal (ffap-soft-value "ange-ftp-default-user") "anonymous") 145 (if (or (equal (ffap-soft-value "ange-ftp-default-user") "anonymous")
134 (equal (ffap-soft-value "efs-default-user") "anonymous")) 146 (equal (ffap-soft-value "efs-default-user") "anonymous"))
135 nil 147 nil
136 "anonymous") 148 "anonymous")
137 "*User name in ftp paths generated by `ffap-host-to-path'. 149 "*User name in ftp paths generated by `ffap-host-to-path'.
138Nil to rely on `efs-default-user' or `ange-ftp-default-user'.") 150nil to rely on `efs-default-user' or `ange-ftp-default-user'."
151 :type '(choice (const :tag "Default" nil)
152 string)
153 :group 'ffap)
139 154
140(defvar ffap-rfs-regexp 155(defcustom ffap-rfs-regexp
141 ;; Remote file access built into file system? HP rfa or Andrew afs: 156 ;; Remote file access built into file system? HP rfa or Andrew afs:
142 "\\`/\\(afs\\|net\\)/." 157 "\\`/\\(afs\\|net\\)/."
143 ;; afs only: (and (file-exists-p "/afs") "\\`/afs/.") 158 ;; afs only: (and (file-exists-p "/afs") "\\`/afs/.")
144 "*Matching paths are treated as remote. Nil to disable.") 159 "*Matching paths are treated as remote. nil to disable."
160 :type 'regexp
161 :group 'ffap)
145 162
146(defvar ffap-url-regexp 163(defvar ffap-url-regexp
147 ;; Could just use `url-nonrelative-link' of w3, if loaded. 164 ;; Could just use `url-nonrelative-link' of w3, if loaded.
@@ -153,11 +170,13 @@ Nil to rely on `efs-default-user' or `ange-ftp-default-user'.")
153 "\\(ftp\\|http\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host 170 "\\(ftp\\|http\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host
154 "\\)." ; require one more character 171 "\\)." ; require one more character
155 ) 172 )
156 "Regexp matching url's. Nil to disable url features in ffap.") 173 "Regexp matching URL's. nil to disable URL features in ffap.")
157 174
158(defvar ffap-foo-at-bar-prefix "mailto" 175(defcustom ffap-foo-at-bar-prefix "mailto"
159 "*Presumed url prefix type of strings like \"<foo.9z@bar>\". 176 "*Presumed URL prefix type of strings like \"<foo.9z@bar>\".
160Sensible values are nil, \"news\", or \"mailto\".") 177Sensible values are nil, \"news\", or \"mailto\"."
178 :type 'string
179 :group 'ffap)
161 180
162 181
163;;; Peanut Gallery: 182;;; Peanut Gallery:
@@ -168,30 +187,39 @@ Sensible values are nil, \"news\", or \"mailto\".")
168;; through this section for features that you like, put an appropriate 187;; through this section for features that you like, put an appropriate
169;; enabler in your .emacs file. 188;; enabler in your .emacs file.
170 189
171(defvar ffap-dired-wildcards nil ; "[*?][^/]*$" 190(defcustom ffap-dired-wildcards nil ; "[*?][^/]*$"
172 ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still 191 ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still
173 ;; available by "C-x C-d <pattern>", and valid filenames may 192 ;; available by "C-x C-d <pattern>", and valid filenames may
174 ;; sometimes contain wildcard characters. 193 ;; sometimes contain wildcard characters.
175 "*A regexp matching filename wildcard characters, or nil. 194 "*A regexp matching filename wildcard characters, or nil.
176If `find-file-at-point' gets a filename matching this pattern, 195If `find-file-at-point' gets a filename matching this pattern,
177it passes it on to `dired' instead of `find-file'.") 196it passes it on to `dired' instead of `find-file'."
197 :type '(choice (const :tag "off" nil)
198 regexp)
199 :group 'ffap)
178 200
179(defvar ffap-newfile-prompt nil ; t 201(defcustom ffap-newfile-prompt nil ; t
180 ;; Suggestion from RHOGEE, 11 Jul 1994. Disabled, I think this is 202 ;; Suggestion from RHOGEE, 11 Jul 1994. Disabled, I think this is
181 ;; better handled by `find-file-not-found-hooks'. 203 ;; better handled by `find-file-not-found-hooks'.
182 "*Whether `find-file-at-point' prompts about a nonexistent file.") 204 "*Whether `find-file-at-point' prompts about a nonexistent file."
205 :type 'boolean
206 :group 'ffap)
183 207
184(defvar ffap-require-prefix nil 208(defcustom ffap-require-prefix nil
185 ;; Suggestion from RHOGEE, 20 Oct 1994. 209 ;; Suggestion from RHOGEE, 20 Oct 1994.
186 "*If set, reverses the prefix argument to `find-file-at-point'. 210 "*If set, reverses the prefix argument to `find-file-at-point'.
187This is nil so neophytes notice ffap. Experts may prefer to disable 211This is nil so neophytes notice ffap. Experts may prefer to disable
188ffap most of the time.") 212ffap most of the time."
189 213 :type 'boolean
190(defvar ffap-file-finder 'find-file 214 :group 'ffap)
191 "*The command called by `find-file-at-point' to find a file.") 215
216(defcustom ffap-file-finder 'find-file
217 "*The command called by `find-file-at-point' to find a file."
218 :type 'function
219 :group 'ffap)
192(put 'ffap-file-finder 'risky-local-variable t) 220(put 'ffap-file-finder 'risky-local-variable t)
193 221
194(defvar ffap-url-fetcher 222(defcustom ffap-url-fetcher
195 (cond ((fboundp 'w3-fetch) 'w3-fetch) 223 (cond ((fboundp 'w3-fetch) 'w3-fetch)
196 ((fboundp 'browse-url-netscape) 'browse-url-netscape) 224 ((fboundp 'browse-url-netscape) 'browse-url-netscape)
197 (t 'w3-fetch)) 225 (t 'w3-fetch))
@@ -200,7 +228,9 @@ ffap most of the time.")
200 ;; http://home.netscape.com/newsref/std/x-remote.html 228 ;; http://home.netscape.com/newsref/std/x-remote.html
201 "*A function of one argument, called by ffap to fetch an URL. 229 "*A function of one argument, called by ffap to fetch an URL.
202Reasonable choices are `w3-fetch' or `browse-url-netscape'. 230Reasonable choices are `w3-fetch' or `browse-url-netscape'.
203For a fancier alternative, get ffap-url.el.") 231For a fancier alternative, get ffap-url.el."
232 :type 'function
233 :group 'ffap)
204(put 'ffap-url-fetcher 'risky-local-variable t) 234(put 'ffap-url-fetcher 'risky-local-variable t)
205 235
206 236
@@ -210,7 +240,7 @@ For a fancier alternative, get ffap-url.el.")
210;; then, broke it up into ffap-next-guess (noninteractive) and 240;; then, broke it up into ffap-next-guess (noninteractive) and
211;; ffap-next (a command). It now work on files as well as url's. 241;; ffap-next (a command). It now work on files as well as url's.
212 242
213(defvar ffap-next-regexp 243(defcustom ffap-next-regexp
214 ;; If you want ffap-next to find URL's only, try this: 244 ;; If you want ffap-next to find URL's only, try this:
215 ;; (and ffap-url-regexp (string-match "\\\\`" ffap-url-regexp) 245 ;; (and ffap-url-regexp (string-match "\\\\`" ffap-url-regexp)
216 ;; (concat "\\<" (substring ffap-url-regexp 2)))) 246 ;; (concat "\\<" (substring ffap-url-regexp 2))))
@@ -218,11 +248,13 @@ For a fancier alternative, get ffap-url.el.")
218 ;; It pays to put a big fancy regexp here, since ffap-guesser is 248 ;; It pays to put a big fancy regexp here, since ffap-guesser is
219 ;; much more time-consuming than regexp searching: 249 ;; much more time-consuming than regexp searching:
220 "[/:.~a-zA-Z]/\\|@[a-zA-Z][-a-zA-Z0-9]*\\." 250 "[/:.~a-zA-Z]/\\|@[a-zA-Z][-a-zA-Z0-9]*\\."
221 "*Regular expression governing movements of `ffap-next'.") 251 "*Regular expression governing movements of `ffap-next'."
252 :type 'regexp
253 :group 'ffap)
222 254
223(defvar ffap-next-guess nil "Last value returned by `ffap-next-guess'.") 255(defvar ffap-next-guess nil "Last value returned by `ffap-next-guess'.")
224(defun ffap-next-guess (&optional back lim) 256(defun ffap-next-guess (&optional back lim)
225 "Move point to next file or url, and return it as a string. 257 "Move point to next file or URL, and return it as a string.
226If nothing is found, leave point at limit and return nil. 258If nothing is found, leave point at limit and return nil.
227Optional BACK argument makes search backwards. 259Optional BACK argument makes search backwards.
228Optional LIM argument limits the search. 260Optional LIM argument limits the search.
@@ -239,7 +271,7 @@ Only considers strings that match `ffap-next-regexp'."
239 271
240;;;###autoload 272;;;###autoload
241(defun ffap-next (&optional back wrap) 273(defun ffap-next (&optional back wrap)
242 "Search buffer for next file or url, and run ffap. 274 "Search buffer for next file or URL, and run ffap.
243Optional argument BACK says to search backwards. 275Optional argument BACK says to search backwards.
244Optional argument WRAP says to try wrapping around if necessary. 276Optional argument WRAP says to try wrapping around if necessary.
245Interactively: use a single prefix to search backwards, 277Interactively: use a single prefix to search backwards,
@@ -259,7 +291,7 @@ Actual search is done by `ffap-next-guess'."
259 (sit-for 0) ; display point movement 291 (sit-for 0) ; display point movement
260 (find-file-at-point (ffap-prompter guess))) 292 (find-file-at-point (ffap-prompter guess)))
261 (goto-char pt) ; restore point 293 (goto-char pt) ; restore point
262 (message "No %sfiles or URL's found." 294 (message "No %sfiles or URL's found"
263 (if wrap "" "more "))))) 295 (if wrap "" "more ")))))
264 296
265(defun ffap-next-url (&optional back wrap) 297(defun ffap-next-url (&optional back wrap)
@@ -301,17 +333,29 @@ Actual search is done by `ffap-next-guess'."
301;; I cannot decide a "best" strategy here, so these are variables. In 333;; I cannot decide a "best" strategy here, so these are variables. In
302;; particular, if `Pinging...' is broken or takes too long on your 334;; particular, if `Pinging...' is broken or takes too long on your
303;; machine, try setting these all to accept or reject. 335;; machine, try setting these all to accept or reject.
304(defvar ffap-machine-p-local 'reject ; this happens often 336(defcustom ffap-machine-p-local 'reject ; this happens often
305 "*A symbol, one of: ping, accept, reject. 337 "*A symbol, one of: ping, accept, reject.
306What `ffap-machine-p' does with hostnames that have no domain.") 338What `ffap-machine-p' does with hostnames that have no domain."
307(defvar ffap-machine-p-known 'ping ; 'accept for speed 339 :type '(choice (const ping)
340 (const accept)
341 (const reject))
342 :group 'ffap)
343(defcustom ffap-machine-p-known 'ping ; 'accept for speed
308 "*A symbol, one of: ping, accept, reject. 344 "*A symbol, one of: ping, accept, reject.
309What `ffap-machine-p' does with hostnames that have a known domain 345What `ffap-machine-p' does with hostnames that have a known domain
310\(see mail-extr.el for the known domains\).") 346\(see mail-extr.el for the known domains\)."
311(defvar ffap-machine-p-unknown 'reject 347 :type '(choice (const ping)
348 (const accept)
349 (const reject))
350 :group 'ffap)
351(defcustom ffap-machine-p-unknown 'reject
312 "*A symbol, one of: ping, accept, reject. 352 "*A symbol, one of: ping, accept, reject.
313What `ffap-machine-p' does with hostnames that have an unknown domain 353What `ffap-machine-p' does with hostnames that have an unknown domain
314\(see mail-extr.el for the known domains\).") 354\(see mail-extr.el for the known domains\)."
355 :type '(choice (const ping)
356 (const accept)
357 (const reject))
358 :group 'ffap)
315 359
316(defun ffap-what-domain (domain) 360(defun ffap-what-domain (domain)
317 ;; Like what-domain in mail-extr.el, returns string or nil. 361 ;; Like what-domain in mail-extr.el, returns string or nil.