Mercurial > emacs
annotate lisp/url/url-dired.el @ 66058:702baea25eb3
(MH-E-SRC): New. Used by mh-autoloads.
(mh-autoloads): New. Builds mh-e/mh-loaddefs.el. Rebuilds if any files
in MH-E-SRC have been updated.
(updates, compile, recompile, bootstrap): Depend on mh-autoloads.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Wed, 12 Oct 2005 23:06:20 +0000 |
parents | 875dcc490074 |
children | eb65acc95303 532e0a9335a9 |
rev | line source |
---|---|
54695 | 1 ;;; url-dired.el --- URL Dired minor mode |
57612 | 2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
57612 | 5 |
54695 | 6 ;; Keywords: comm, files |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64084 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
57612 | 24 |
25 ;;; Code: | |
54695 | 26 |
27 (autoload 'w3-fetch "w3") | |
28 (autoload 'w3-open-local "w3") | |
29 (autoload 'dired-get-filename "dired") | |
30 | |
31 (defvar url-dired-minor-mode-map | |
32 (let ((map (make-sparse-keymap))) | |
33 (define-key map "\C-m" 'url-dired-find-file) | |
34 (if (featurep 'xemacs) | |
35 (define-key map [button2] 'url-dired-find-file-mouse) | |
36 (define-key map [mouse-2] 'url-dired-find-file-mouse)) | |
37 map) | |
38 "Keymap used when browsing directories.") | |
39 | |
40 (defvar url-dired-minor-mode nil | |
41 "Whether we are in url-dired-minor-mode") | |
42 | |
43 (make-variable-buffer-local 'url-dired-minor-mode) | |
44 | |
45 (defun url-dired-find-file () | |
46 "In dired, visit the file or directory named on this line, using Emacs-W3." | |
47 (interactive) | |
48 (let ((filename (dired-get-filename))) | |
49 (cond ((string-match "/\\(.*@.*\\):\\(/.*\\)" filename) | |
50 (w3-fetch (concat "file://" (match-string 1 filename) (match-string 2 filename)))) | |
51 (t | |
52 (w3-open-local filename))))) | |
53 | |
54 (defun url-dired-find-file-mouse (event) | |
55 "In dired, visit the file or directory name you click on, using Emacs-W3." | |
56 (interactive "@e") | |
57 (mouse-set-point event) | |
58 (url-dired-find-file)) | |
59 | |
60 (defun url-dired-minor-mode (&optional arg) | |
61 "Minor mode for directory browsing with Emacs-W3." | |
62 (interactive "P") | |
63 (cond | |
64 ((null arg) | |
65 (setq url-dired-minor-mode (not url-dired-minor-mode))) | |
66 ((equal 0 arg) | |
67 (setq url-dired-minor-mode nil)) | |
68 (t | |
69 (setq url-dired-minor-mode t)))) | |
70 | |
71 (if (not (fboundp 'add-minor-mode)) | |
72 (defun add-minor-mode (toggle name &optional keymap after toggle-fun) | |
73 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'. | |
74 TOGGLE is a symbol which is used as the variable which toggle the minor mode, | |
75 NAME is the name that should appear in the modeline (it should be a string | |
76 beginning with a space), KEYMAP is a keymap to make active when the minor | |
77 mode is active, and AFTER is the toggling symbol used for another minor | |
78 mode. If AFTER is non-nil, then it is used to position the new mode in the | |
79 minor-mode alists. TOGGLE-FUN specifies an interactive function that | |
80 is called to toggle the mode on and off; this affects what appens when | |
81 button2 is pressed on the mode, and when button3 is pressed somewhere | |
82 in the list of modes. If TOGGLE-FUN is nil and TOGGLE names an | |
83 interactive function, TOGGLE is used as the toggle function. | |
84 | |
85 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)" | |
86 (if (not (assq toggle minor-mode-alist)) | |
87 (setq minor-mode-alist (cons (list toggle name) minor-mode-alist))) | |
88 (if (and keymap (not (assq toggle minor-mode-map-alist))) | |
89 (setq minor-mode-map-alist (cons (cons toggle keymap) | |
90 minor-mode-map-alist))))) | |
91 | |
92 (add-minor-mode 'url-dired-minor-mode " URL" url-dired-minor-mode-map) | |
93 | |
94 (defun url-find-file-dired (dir) | |
95 "\"Edit\" directory DIR, but with additional URL-friendly bindings." | |
96 (interactive "DURL Dired (directory): ") | |
97 (find-file dir) | |
98 (url-dired-minor-mode t)) | |
99 | |
100 (provide 'url-dired) | |
54699 | 101 |
102 ;;; arch-tag: 2694f21a-43e1-4391-b3cb-cf6e5349f15f | |
57612 | 103 ;;; url-dired.el ends here |