url-dired.el 1.9 KB

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