comparison lisp/url/url-handlers.el @ 54829:e38bd75fb54e

(url-handler-mode): New minor mode. (url-setup-file-name-handlers): Remove.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 12 Apr 2004 20:43:39 +0000
parents e8824c4f5f7e
children 2a15e5a02a89 eb7e8d483840
comparison
equal deleted inserted replaced
54828:2eb49bad7ea9 54829:e38bd75fb54e
1 ;;; url-handlers.el --- file-name-handler stuff for URL loading 1 ;;; url-handlers.el --- file-name-handler stuff for URL loading
2
3 ;; Copyright (c) 1996,97,98,1999,2004 Free Software Foundation, Inc.
4 ;; Copyright (c) 1993 - 1996 by William M. Perry <wmperry@cs.indiana.edu>
5
2 ;; Keywords: comm, data, processes, hypermedia 6 ;; Keywords: comm, data, processes, hypermedia
3 7
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 8 ;; This file is part of GNU Emacs.
5 ;;; Copyright (c) 1993 - 1996 by William M. Perry <wmperry@cs.indiana.edu> 9 ;;
6 ;;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc. 10 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;;; 11 ;; it under the terms of the GNU General Public License as published by
8 ;;; This file is part of GNU Emacs. 12 ;; the Free Software Foundation; either version 2, or (at your option)
9 ;;; 13 ;; any later version.
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify 14 ;;
11 ;;; it under the terms of the GNU General Public License as published by 15 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;;; the Free Software Foundation; either version 2, or (at your option) 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; any later version. 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; 18 ;; GNU General Public License for more details.
15 ;;; GNU Emacs is distributed in the hope that it will be useful, 19 ;;
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 ;; You should have received a copy of the GNU General Public License
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
18 ;;; GNU General Public License for more details. 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 ;;; 23 ;; Boston, MA 02111-1307, USA.
20 ;;; You should have received a copy of the GNU General Public License 24
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to the 25 ;;; Commentary:
22 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 26
23 ;;; Boston, MA 02111-1307, USA. 27 ;;; Code:
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 28
26 (require 'url) 29 (require 'url)
27 (require 'url-parse) 30 (require 'url-parse)
28 (require 'url-util) 31 (require 'url-util)
29 (require 'mm-decode) 32 (require 'mm-decode)
90 \(about, data, info, irc, mailto, etc\). This regular expression 93 \(about, data, info, irc, mailto, etc\). This regular expression
91 avoids conflicts with local files that look like URLs \(Gnus is 94 avoids conflicts with local files that look like URLs \(Gnus is
92 particularly bad at this\).") 95 particularly bad at this\).")
93 96
94 ;;;###autoload 97 ;;;###autoload
95 (defun url-setup-file-name-handlers () 98 (define-minor-mode url-handler-mode
96 "Setup file-name handlers." 99 "Use URL to handle URL-like file names."
97 (cond 100 :global t
98 ((not (boundp 'file-name-handler-alist)) 101 (if (not (boundp 'file-name-handler-alist))
99 nil) ; Don't load if no alist 102 ;; Can't be turned ON anyway.
100 ((rassq 'url-file-handler file-name-handler-alist) 103 (setq url-handler-mode nil)
101 nil) ; Don't load twice 104 ;; Remove old entry, if any.
102 (t 105 (setq file-name-handler-alist
103 (push (cons url-handler-regexp 'url-file-handler) 106 (delq (rassq 'url-file-handler file-name-handler-alist)
104 file-name-handler-alist)))) 107 file-name-handler-alist))
108 (if url-handler-mode
109 (push (cons url-handler-regexp 'url-file-handler)
110 file-name-handler-alist))))
105 111
106 (defun url-run-real-handler (operation args) 112 (defun url-run-real-handler (operation args)
107 (let ((inhibit-file-name-handlers (cons 'url-file-handler 113 (let ((inhibit-file-name-handlers (cons 'url-file-handler
108 (if (eq operation inhibit-file-name-operation) 114 (if (eq operation inhibit-file-name-operation)
109 inhibit-file-name-handlers))) 115 inhibit-file-name-handlers)))
246 (string-match url-handler-regexp buffer-file-name) 252 (string-match url-handler-regexp buffer-file-name)
247 (auto-save-mode 0))) 253 (auto-save-mode 0)))
248 254
249 (provide 'url-handlers) 255 (provide 'url-handlers)
250 256
251 ;;; arch-tag: 7300b99c-cc83-42ff-9147-79b2723c62ac 257 ;; arch-tag: 7300b99c-cc83-42ff-9147-79b2723c62ac
258 ;;; url-handlers.el ends here