esh-module.el 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ;;; esh-module.el --- Eshell modules -*- lexical-binding:t -*-
  2. ;; Copyright (C) 1999-2000, 2002-2015 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'. We use "(progn (defgroup ..." in each file
  29. ;; to force the autoloader into including the entire defgroup, rather
  30. ;; than an abbreviated version.
  31. (load "esh-groups" nil 'nomessage)
  32. ;;; User Variables:
  33. (defcustom eshell-module-unload-hook
  34. '(eshell-unload-extension-modules)
  35. "A hook run when `eshell-module' is unloaded."
  36. :type 'hook
  37. :group 'eshell-module)
  38. (defcustom eshell-modules-list
  39. '(eshell-alias
  40. eshell-banner
  41. eshell-basic
  42. eshell-cmpl
  43. eshell-dirs
  44. eshell-glob
  45. eshell-hist
  46. eshell-ls
  47. eshell-pred
  48. eshell-prompt
  49. eshell-script
  50. eshell-term
  51. eshell-unix)
  52. "A list of optional add-on modules to be loaded by Eshell.
  53. Changes will only take effect in future Eshell buffers."
  54. :type (append
  55. (list 'set ':tag "Supported modules")
  56. (mapcar
  57. (function
  58. (lambda (modname)
  59. (let ((modsym (intern modname)))
  60. (list 'const
  61. ':tag (format "%s -- %s" modname
  62. (get modsym 'custom-tag))
  63. ':link (caar (get modsym 'custom-links))
  64. ':doc (concat "\n" (get modsym 'group-documentation)
  65. "\n ")
  66. modsym))))
  67. (sort (mapcar 'symbol-name
  68. (eshell-subgroups 'eshell-module))
  69. 'string-lessp))
  70. '((repeat :inline t :tag "Other modules" symbol)))
  71. :group 'eshell-module)
  72. ;;; Code:
  73. (defsubst eshell-using-module (module)
  74. "Return non-nil if a certain Eshell MODULE is in use.
  75. The MODULE should be a symbol corresponding to that module's
  76. customization group. Example: `eshell-cmpl' for that module."
  77. (memq module eshell-modules-list))
  78. (defun eshell-unload-extension-modules ()
  79. "Unload any memory resident extension modules."
  80. (dolist (module (eshell-subgroups 'eshell-module))
  81. (if (featurep module)
  82. (ignore-errors
  83. (message "Unloading %s..." (symbol-name module))
  84. (unload-feature module)
  85. (message "Unloading %s...done" (symbol-name module))))))
  86. ;;; esh-module.el ends here