Initial Commit
[packages] / xemacs-packages / w3 / lisp / url-dired.el
1 ;;; url-dired.el --- URL Dired minor mode
2
3 ;; Copyright (C) 1996-1999, 2004-2012 Free Software Foundation, Inc.
4
5 ;; Keywords: comm, files
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Code:
23
24 (autoload 'dired-get-filename "dired")
25
26 (defvar url-dired-minor-mode-map
27   (let ((map (make-sparse-keymap)))
28     (define-key map "\C-m" 'url-dired-find-file)
29     (define-key map [mouse-2] 'url-dired-find-file-mouse)
30     map)
31   "Keymap used when browsing directories.")
32
33 (defun url-dired-find-file ()
34   "In dired, visit the file or directory named on this line."
35   (interactive)
36   (let ((filename (dired-get-filename)))
37     (find-file filename)))
38
39 (defun url-dired-find-file-mouse (event)
40   "In dired, visit the file or directory name you click on."
41   (interactive "@e")
42   (mouse-set-point event)
43   (url-dired-find-file))
44
45 (define-minor-mode url-dired-minor-mode
46   "Minor mode for directory browsing.
47 With a prefix argument ARG, enable the mode if ARG is positive,
48 and disable it otherwise.  If called from Lisp, enable the mode
49 if ARG is omitted or nil."
50   :lighter " URL" :keymap url-dired-minor-mode-map)
51
52 (defun url-find-file-dired (dir)
53   "\"Edit\" directory DIR, but with additional URL-friendly bindings."
54   (interactive "DURL Dired (directory): ")
55   (find-file dir)
56   (url-dired-minor-mode t))
57
58 (provide 'url-dired)
59
60 ;;; url-dired.el ends here