esh-module.el 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; esh-module.el --- Eshell modules
  2. ;; Copyright (C) 1999-2000, 2002-2012 Free Software Foundation, Inc.
  3. ;; Author: John Wiegley <johnw@gnu.org>
  4. ;; Keywords: processes
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Code:
  17. (provide 'esh-module)
  18. (require 'eshell)
  19. (require 'esh-util)
  20. (defgroup eshell-module nil
  21. "The `eshell-module' group is for Eshell extension modules, which
  22. provide optional behavior which the user can enable or disable by
  23. customizing the variable `eshell-modules-list'."
  24. :tag "Extension modules"
  25. :group 'eshell)
  26. ;; load the defgroup's for the standard extension modules, so that
  27. ;; documentation can be provided when the user customize's
  28. ;; `eshell-modules-list'.
  29. (load "esh-groups" nil 'nomessage)
  30. ;;; User Variables:
  31. (defcustom eshell-module-unload-hook
  32. '(eshell-unload-extension-modules)
  33. "A hook run when `eshell-module' is unloaded."
  34. :type 'hook
  35. :group 'eshell-module)
  36. (defcustom eshell-modules-list
  37. '(eshell-alias
  38. eshell-banner
  39. eshell-basic
  40. eshell-cmpl
  41. eshell-dirs
  42. eshell-glob
  43. eshell-hist
  44. eshell-ls
  45. eshell-pred
  46. eshell-prompt
  47. eshell-script
  48. eshell-term
  49. eshell-unix)
  50. "A list of optional add-on modules to be loaded by Eshell.
  51. Changes will only take effect in future Eshell buffers."
  52. :type (append
  53. (list 'set ':tag "Supported modules")
  54. (mapcar
  55. (function
  56. (lambda (modname)
  57. (let ((modsym (intern modname)))
  58. (list 'const
  59. ':tag (format "%s -- %s" modname
  60. (get modsym 'custom-tag))
  61. ':link (caar (get modsym 'custom-links))
  62. ':doc (concat "\n" (get modsym 'group-documentation)
  63. "\n ")
  64. modsym))))
  65. (sort (mapcar 'symbol-name
  66. (eshell-subgroups 'eshell-module))
  67. 'string-lessp))
  68. '((repeat :inline t :tag "Other modules" symbol)))
  69. :group 'eshell-module)
  70. ;;; Code:
  71. (defsubst eshell-using-module (module)
  72. "Return non-nil if a certain Eshell MODULE is in use.
  73. The MODULE should be a symbol corresponding to that module's
  74. customization group. Example: `eshell-cmpl' for that module."
  75. (memq module eshell-modules-list))
  76. (defun eshell-unload-extension-modules ()
  77. "Unload any memory resident extension modules."
  78. (dolist (module (eshell-subgroups 'eshell-module))
  79. (if (featurep module)
  80. (ignore-errors
  81. (message "Unloading %s..." (symbol-name module))
  82. (unload-feature module)
  83. (message "Unloading %s...done" (symbol-name module))))))
  84. ;;; esh-module.el ends here