From 82fc3b99d9049bbd98ec2fd55ffebfd58f823c29 Mon Sep 17 00:00:00 2001 From: HaoZeke Date: Mon, 30 Jul 2018 16:59:25 +0530 Subject: [PATCH 1/5] emacs: Update mode file This is a squashed commit including the following changes: 1) Update mode header 2) Clean up white-space 3) Fix free variable warning 4) Add proper file ending stuff 5) Rename to keep conventional naming scheme 6) Updates to the readme 7) Update to conform to `package-lint` criteria 8) Add license header 9) Add in-file instructions --- tools/emacs/README.txt | 36 +++++++++++++- tools/emacs/{lammps.el => lammps-mode.el} | 57 ++++++++++++++++++++--- 2 files changed, 84 insertions(+), 9 deletions(-) rename tools/emacs/{lammps.el => lammps-mode.el} (73%) diff --git a/tools/emacs/README.txt b/tools/emacs/README.txt index 8dfc37cb85..43add16505 100644 --- a/tools/emacs/README.txt +++ b/tools/emacs/README.txt @@ -1,6 +1,7 @@ === Emacs Syntax Highlighting === Created by Aidan Thompson 12/2010 =============================== +Updated by Roit Goswami Mon Jul 30 2018 The lammps.el file provided in this directory will enable syntax highlighting for the lammps script syntax in emacs. The groupings @@ -15,9 +16,40 @@ some basic syntax highlighting of strings, comments, etc. ============================ (0) Create/edit the emacs init file ~/.emacs to contain: -(load "~/.emacs.d/lammps") +(load "~/.emacs.d/lammps-mode.el") This file may also be called ~/.emacs.el, or ~/.emacs.d/init.el -(1) Copy lammps.el to the directory ~/.emacs.d +(1) Copy lammps-mode.el to the directory ~/.emacs.d +=Update: +======== + +The package may now also be installed by a MELPA style recipe, namely: + +```lisp +(lammps-mode :fetcher github :repo "HaoZeke/lammps-mode") +``` + +For a simpler installation with `use-package` simply add: + +```lisp +(use-package lammps-mode) +``` + +The latest version of the package will be kept in sync as a squashed update on +the lammps repository as well. + +It is advisable to use the MELPA installation methods listed here: +https://melpa.org/#/getting-started + +For autoloading and auto-recognizing "in.*" and "*.lmp" files add the following +to `.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)) + )) +``` 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..9dfd119d0a 100644 --- a/tools/emacs/lammps.el +++ b/tools/emacs/lammps-mode.el @@ -1,7 +1,49 @@ -;; 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 file 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 3, or (at your option) +;; any later version. + +;; This file 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 GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, 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 +178,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 +195,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) @@ -200,11 +243,11 @@ (setq lammps-variable-regexp nil)) ;; apply it to specified filename patterns -(setq - auto-mode-alist - (append - auto-mode-alist +(setq auto-mode-alist + (append auto-mode-alist '(("in\\." . lammps-mode)) '(("\\.lmp\\'" . lammps-mode)) )) +(provide 'lammps-mode) +;;; lammps-mode.el ends here From 2c9e96be116bafca79671625fa7fb2539343a334 Mon Sep 17 00:00:00 2001 From: HaoZeke Date: Mon, 30 Jul 2018 19:58:18 +0530 Subject: [PATCH 2/5] emacs: Stop forcing filename patterns --- tools/emacs/lammps-mode.el | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/emacs/lammps-mode.el b/tools/emacs/lammps-mode.el index 9dfd119d0a..9ba2669982 100644 --- a/tools/emacs/lammps-mode.el +++ b/tools/emacs/lammps-mode.el @@ -242,12 +242,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 From a00d7becc30ae782fe3d991e7cc8693ae5ed5b9b Mon Sep 17 00:00:00 2001 From: HaoZeke Date: Mon, 30 Jul 2018 20:10:29 +0530 Subject: [PATCH 3/5] emacs: Major readme update and refactor Also update the license and switch to GPL v2 like lammps --- tools/emacs/README.md | 76 ++++++++++++++++++++++++++++++++++++++ tools/emacs/README.txt | 55 --------------------------- tools/emacs/lammps-mode.el | 15 ++++---- 3 files changed, 83 insertions(+), 63 deletions(-) create mode 100644 tools/emacs/README.md delete mode 100644 tools/emacs/README.txt diff --git a/tools/emacs/README.md b/tools/emacs/README.md new file mode 100644 index 0000000000..ce502a27e3 --- /dev/null +++ b/tools/emacs/README.md @@ -0,0 +1,76 @@ +# 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 + +For autoloading and auto-recognizing `in.*` and `*.lmp` files add the following +to `.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 43add16505..0000000000 --- a/tools/emacs/README.txt +++ /dev/null @@ -1,55 +0,0 @@ -=== Emacs Syntax Highlighting === -Created by Aidan Thompson 12/2010 -=============================== -Updated by Roit Goswami Mon Jul 30 2018 - -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-mode.el") - -This file may also be called ~/.emacs.el, or ~/.emacs.d/init.el - -(1) Copy lammps-mode.el to the directory ~/.emacs.d - -=Update: -======== - -The package may now also be installed by a MELPA style recipe, namely: - -```lisp -(lammps-mode :fetcher github :repo "HaoZeke/lammps-mode") -``` - -For a simpler installation with `use-package` simply add: - -```lisp -(use-package lammps-mode) -``` - -The latest version of the package will be kept in sync as a squashed update on -the lammps repository as well. - -It is advisable to use the MELPA installation methods listed here: -https://melpa.org/#/getting-started - -For autoloading and auto-recognizing "in.*" and "*.lmp" files add the following -to `.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)) - )) -``` diff --git a/tools/emacs/lammps-mode.el b/tools/emacs/lammps-mode.el index 9ba2669982..37e8a32116 100644 --- a/tools/emacs/lammps-mode.el +++ b/tools/emacs/lammps-mode.el @@ -14,20 +14,19 @@ ;; This file is not part of GNU Emacs. -;; This file is free software; you can redistribute it and/or modify +;; 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 3, or (at your option) -;; any later version. +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. -;; This file is distributed in the hope that it will be useful, +;; 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 GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; 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 From 50fe2097822785f596d98e2750a40e2224af0fae Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 31 Jul 2018 10:24:36 +0200 Subject: [PATCH 4/5] mention -*- cookie for switching emacs modes and clarify file pattern text --- tools/emacs/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/emacs/README.md b/tools/emacs/README.md index ce502a27e3..75504a7000 100644 --- a/tools/emacs/README.md +++ b/tools/emacs/README.md @@ -39,8 +39,14 @@ would do the following (kanged [from here](http://ergoemacs.org/emacs/emacs_inst ### Autoloading \& Auto-recognition -For autoloading and auto-recognizing `in.*` and `*.lmp` files add the following -to `.emacs`: +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) From 6dad2f59d8bc4ecc68604b712d0072c303e3f2e9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 31 Jul 2018 11:06:09 +0200 Subject: [PATCH 5/5] list @HaoZeke as (new) owner of the LAMMPS emacs mode list code --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 75b79443c3..7f32281192 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -44,6 +44,7 @@ src/USER-MISC/*_grem.* @dstelter92 # tools tools/msi2lmp/* @akohlmey +tools/emacs/* @HaoZeke # cmake cmake/* @junghans @rbberger