diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 53b0a7b4f2..b91e58a83f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -45,6 +45,7 @@ src/USER-MISC/*_grem.* @dstelter92 # tools tools/msi2lmp/* @akohlmey +tools/emacs/* @HaoZeke # cmake cmake/* @junghans @rbberger diff --git a/tools/emacs/README.md b/tools/emacs/README.md new file mode 100644 index 0000000000..75504a7000 --- /dev/null +++ b/tools/emacs/README.md @@ -0,0 +1,82 @@ +# GNU Emacs Syntax Highlighting + +> Copyright (C) 2010-2018 Aidan Thompson +> Copyright (C) 2018 Rohit Goswami + +The `lammps-mode.el` file provided in this directory will enable syntax +highlighting for the lammps script syntax in GNU Emacs. The groupings of +commands were originally copied from `tools/vim`. + +## Installation +**Requirements: GNU Emacs 24.\*** + +### Obtaining the Package + +#### MELPA + +The easiest installation method is via MELPA and it is advisable to use one of +the many [MELPA installation methods](https://melpa.org/#/getting-started). + +For example, with [use-package](https://github.com/jwiegley/use-package) one can +simply use the following: + +``` emacs-lisp +(use-package lammps-mode) +``` + +#### Manually + +Assuming for some reason you have downloaded the file to `~/.emacs.d/lisp` you +would do the following (kanged [from here](http://ergoemacs.org/emacs/emacs_installing_packages.html)): + +``` emacs-lisp +;; Tell emacs where is your personal elisp lib dir +(add-to-list 'load-path "~/.emacs.d/lisp/") + +;; load the package. +(load "lammps-mode") +``` + +### Autoloading \& Auto-recognition + +To automatically turn on the LAMMPS mode for editing your input scripts, +use the following line as the **first** line of your script: +``` +# -*- lammps -*- +``` + +For automatically switching on the LAMMPS mode based on filename patterns, +e.g. for `in.*` and `*.lmp` files, add the following code to your `.emacs`: + +``` emacs-lisp +(autoload 'lammps-mode "lammps-mode.el" "LAMMPS mode." t) +(setq auto-mode-alist (append auto-mode-alist + '(("in\\." . lammps-mode)) + '(("\\.lmp\\'" . lammps-mode)) + )) +``` + +## Status + +By far not all commands are included in the syntax file (lammps-mode.el). You +can easily add new ones to the existing classes. + +## Implementation Details + +`lammps-mode` is derived from `shell-script-mode` which provides some basic +syntax highlighting of strings, comments, etc. + +The MELPA recipe used for this package is simply: + +``` emacs-lisp +(lammps-mode :fetcher github :repo "HaoZeke/lammps-mode") +``` + +## Caveats + +* Does not work with Xemacs [See [this comment](https://github.com/lammps/lammps/pull/1022#issuecomment-408871233)] + +## License + +[GNU GPL v2](https://github.com/HaoZeke/lammps-mode/blob/master/LICENSE). +Check the file for more details. diff --git a/tools/emacs/README.txt b/tools/emacs/README.txt deleted file mode 100644 index 8dfc37cb85..0000000000 --- a/tools/emacs/README.txt +++ /dev/null @@ -1,23 +0,0 @@ -=== Emacs Syntax Highlighting === -Created by Aidan Thompson 12/2010 -=============================== - -The lammps.el file provided in this directory will enable syntax -highlighting for the lammps script syntax in emacs. The groupings -of commands were copied from tools/vim. The simulation scripts have to -end on *.lmp or start with in.* (see lammps.el). By far not all -commands are included in the syntax file (lammps.el). -You can easily add new ones to the existing classes. -'lammps-mode' is derived from 'shell-script-mode' which provides -some basic syntax highlighting of strings, comments, etc. - -=To enable the highlighting: -============================ -(0) Create/edit the emacs init file ~/.emacs to contain: - -(load "~/.emacs.d/lammps") - -This file may also be called ~/.emacs.el, or ~/.emacs.d/init.el - -(1) Copy lammps.el to the directory ~/.emacs.d - diff --git a/tools/emacs/lammps.el b/tools/emacs/lammps-mode.el similarity index 73% rename from tools/emacs/lammps.el rename to tools/emacs/lammps-mode.el index d1ebebbbbf..37e8a32116 100644 --- a/tools/emacs/lammps.el +++ b/tools/emacs/lammps-mode.el @@ -1,7 +1,48 @@ -;; LAMMPS auto-mode +;;; lammps-mode.el --- basic syntax highlighting for LAMMPS files + +;; Copyright (C) 2010-18 Aidan Thompson +;; Copyright (C) 2018 Rohit Goswami + +;; Author: Aidan Thompson +;; Maintainer: Rohit Goswami +;; Created: December 4, 2010 +;; Modified: July 30, 2018 +;; Version: 1.5.0 +;; Keywords: languages, faces +;; Homepage: https://github.com/lammps/lammps/tree/master/tools/emacs +;; Package-Requires: ((emacs "24.4")) + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License along +;; with this program; if not, write to the Free Software Foundation, Inc., +;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +;;; Commentary: ;; translation of keyword classes from tools/vim ;; see http://xahlee.org/emacs/elisp_syntax_coloring.html +;; Put this in your .emacs file to enable autoloading of lammps-mode +;; and auto-recognition of "in.*" and "*.lmp" files: +;; +;; (autoload 'lammps-mode "lammps-mode.el" "LAMMPS mode." t) +;; (setq auto-mode-alist (append auto-mode-alist +;; '(("in\\." . lammps-mode)) +;; '(("\\.lmp\\'" . lammps-mode)) +;; )) +;; + +;;; Code: ;; define several keyword classes (defvar lammps-output '("log" @@ -136,6 +177,8 @@ (defvar lammps-variable-regexp "\\$\\({[a-zA-Z0-9_]+}\\)\\|\\$[A-Za-z]") +(defvar lammps-font-lock-keywords) + ;; clear memory (setq lammps-output nil) (setq lammps-read nil) @@ -151,8 +194,7 @@ ;; create the list for font-lock. ;; each class of keyword is given a particular face -(setq - lammps-font-lock-keywords +(setq lammps-font-lock-keywords `((,lammps-output-regexp . font-lock-function-name-face) (,lammps-read-regexp . font-lock-preprocessor-face) (,lammps-lattice-regexp . font-lock-type-face) @@ -199,12 +241,5 @@ (setq lammps-comment-regexp nil) (setq lammps-variable-regexp nil)) -;; apply it to specified filename patterns -(setq - auto-mode-alist - (append - auto-mode-alist - '(("in\\." . lammps-mode)) - '(("\\.lmp\\'" . lammps-mode)) - )) - +(provide 'lammps-mode) +;;; lammps-mode.el ends here