| 1 |
;;; modulefile-mode.el --- Modulefile editing commands for Emacs -*- lexical-binding: t; -*- |
| 2 |
|
| 3 |
;; Author: Laurent Besson <[email protected]> |
| 4 |
;; Maintainer: Laurent Besson <[email protected]> |
| 5 |
;; Created: June 12, 2025 |
| 6 |
;; Version: 1.0 |
| 7 |
;; Tested with: ((emacs "24") |
| 8 |
;; Keywords: Modules, modulefile |
| 9 |
;; URL: https://modules.readthedocs.io/en/latest/index.html |
| 10 |
|
| 11 |
;; This file is part of Environment Modules |
| 12 |
|
| 13 |
;; This program is free software; you can redistribute it and/or modify |
| 14 |
;; it under the terms of the GNU General Public License as published by |
| 15 |
;; the Free Software Foundation, either version 2 of the License, or |
| 16 |
;; (at your option) any later version. |
| 17 |
|
| 18 |
;; This program is distributed in the hope that it will be useful, |
| 19 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
;; GNU General Public License for more details. |
| 22 |
|
| 23 |
;; You should have received a copy of the GNU General Public License |
| 24 |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 |
|
| 26 |
;;; Commentary: |
| 27 |
|
| 28 |
;; modulefile-mode is a major mode for highlighting modulefile syntax. |
| 29 |
;; It derives from tcl-mode as modulefile is based on this language. |
| 30 |
;; It colorizes modulefile commands and variables: |
| 31 |
;; * font-lock-keyword-face is used to colorize Modulefile commands |
| 32 |
;; * font-lock-preprocessor-face is used to colorize Modulefile specific |
| 33 |
;; variables (these variables will not be highlighted the same way as |
| 34 |
;; regular Tcl variables) |
| 35 |
|
| 36 |
;;; Installation: |
| 37 |
|
| 38 |
;; Copy this file into your Emacs package search directory and add the |
| 39 |
;; following lines to your Emacs configuration file: |
| 40 |
|
| 41 |
;; ;; Use first line of file to recognize file type |
| 42 |
;; (add-to-list 'magic-mode-alist '("#%Module" . modulefile-mode)) |
| 43 |
;; (autoload 'modulefile-mode "modulefile-mode" |
| 44 |
;; "Major mode for editing Modulefile scripts." t) |
| 45 |
|
| 46 |
;;; Code: |
| 47 |
|
| 48 |
(define-derived-mode modulefile-mode tcl-mode "Modulefile" |
| 49 |
"Major mode for editing Modulefile scripts." |
| 50 |
(font-lock-add-keywords 'modulefile-mode |
| 51 |
'(("\\<\\(add-property\\|always-load\\|append-path\\|chdir\\|complete\\|conflict\\|depends-on-any\\|depends-on\\|extensions\\|family\\|getenv\\|getvariant\\|haveDynamicMPATH\\|hide-modulefile\\|hide-version\\|is-avail\\|is-loaded\\|is-saved\\|is-used\\|lsb-release\\|module-alias\\|module-forbid\\|module-help\\|module-hide\\|module-info\\|module-tag\\|module-version\\|module-virtual\\|module-warn\\|module-whatis\\|module\\|modulepath-ignore\\|modulepath-label\\|prepend-path\\|prereq-all\\|prereq-any\\|prereq\\|provide\\|pushenv\\|remove-path\\|reportError\\|reportWarning\\|require-fullname\\|set-alias\\|set-function\\|setenv\\|source-sh\\|system\\|uname\\|uncomplete\\|unset-alias\\|unset-function\\|unsetenv\\|variant\\|versioncmp\\|x-resource\\)\\>" . font-lock-keyword-face)) |
| 52 |
) |
| 53 |
(font-lock-add-keywords 'modulefile-mode |
| 54 |
'(("\\<\\(ModulesVersion\\|ModulesCurrentModulefile\\|ModuleToolVersion\\|ModuleVariant\\|ModuleTool\\)\\>" . font-lock-preprocessor-face)) |
| 55 |
) |
| 56 |
) |
| 57 |
|
| 58 |
(provide 'modulefile-mode) |