mirror of https://github.com/lammps/lammps.git
Added emacs syntax highlighting
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5360 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
a9dd87de56
commit
6c8dd4a34a
|
@ -3,150 +3,208 @@
|
||||||
;; see http://xahlee.org/emacs/elisp_syntax_coloring.html
|
;; see http://xahlee.org/emacs/elisp_syntax_coloring.html
|
||||||
|
|
||||||
;; define several keyword classes
|
;; define several keyword classes
|
||||||
(defvar lammps-output
|
(defvar lammps-output
|
||||||
'("log" "write_restart" "dump" "undump" "thermo" "thermo_modify" "thermo_style" "print")
|
'("log"
|
||||||
"LAMMPS output.")
|
"write_restart"
|
||||||
|
"dump"
|
||||||
|
"undump"
|
||||||
|
"thermo"
|
||||||
|
"thermo_modify"
|
||||||
|
"thermo_style"
|
||||||
|
"print")
|
||||||
|
"LAMMPS output.")
|
||||||
|
|
||||||
(defvar lammps-read
|
(defvar lammps-read
|
||||||
'("include" "read" "read_restart" "read_data")
|
'("include"
|
||||||
"LAMMPS read.")
|
"read"
|
||||||
|
"read_restart"
|
||||||
|
"read_data")
|
||||||
|
"LAMMPS read.")
|
||||||
|
|
||||||
(defvar lammps-lattice
|
(defvar lammps-lattice
|
||||||
'("boundary" "units" "atom_style" "lattice" "region" "create_box" "create_atoms" "dielectric" "delete_atoms" "change_box" "dimension" "replicate")
|
'("boundary"
|
||||||
"LAMMPS lattice.")
|
"units"
|
||||||
|
"atom_style"
|
||||||
|
"lattice"
|
||||||
|
"region"
|
||||||
|
"create_box"
|
||||||
|
"create_atoms"
|
||||||
|
"dielectric"
|
||||||
|
"delete_atoms"
|
||||||
|
"change_box"
|
||||||
|
"dimension"
|
||||||
|
"replicate")
|
||||||
|
"LAMMPS lattice.")
|
||||||
|
|
||||||
(defvar lammps-define
|
(defvar lammps-define
|
||||||
'("variable" "group")
|
'("variable"
|
||||||
"LAMMPS define.")
|
"group")
|
||||||
|
"LAMMPS define.")
|
||||||
|
|
||||||
(defvar lammps-run
|
(defvar lammps-run
|
||||||
'("minimize" "run")
|
'("minimize"
|
||||||
"LAMMPS run.")
|
"run")
|
||||||
|
"LAMMPS run.")
|
||||||
|
|
||||||
(defvar lammps-setup
|
(defvar lammps-setup
|
||||||
'("min_style" "fix_modify" "run_style" "timestep" "neighbor" "neigh_modify" "fix" "unfix" "communicate" "newton" "nthreads" "processors" "reset_timestep")
|
'("min_style"
|
||||||
"LAMMPS setup.")
|
"fix_modify"
|
||||||
|
"run_style"
|
||||||
|
"timestep"
|
||||||
|
"neighbor"
|
||||||
|
"neigh_modify"
|
||||||
|
"fix"
|
||||||
|
"unfix"
|
||||||
|
"communicate"
|
||||||
|
"newton"
|
||||||
|
"nthreads"
|
||||||
|
"processors"
|
||||||
|
"reset_timestep")
|
||||||
|
"LAMMPS setup.")
|
||||||
|
|
||||||
(defvar lammps-particle
|
(defvar lammps-particle
|
||||||
'("pair_coeff" "pair_style" "pair_modify" "mass" "velocity" "angle_coeff" "angle_style" "atom_modify" "atom_style" "bond_coeff" "bond_style" "delete_bonds" "kspace_style" "kspace_modify" "dihedral_style" "dihedral_coeff" "improper_style" "improper_coeff")
|
'("pair_coeff"
|
||||||
"LAMMPS particle.")
|
"pair_style"
|
||||||
|
"pair_modify"
|
||||||
|
"mass"
|
||||||
|
"velocity"
|
||||||
|
"angle_coeff"
|
||||||
|
"angle_style"
|
||||||
|
"atom_modify"
|
||||||
|
"atom_style"
|
||||||
|
"bond_coeff"
|
||||||
|
"bond_style"
|
||||||
|
"delete_bonds"
|
||||||
|
"kspace_style"
|
||||||
|
"kspace_modify"
|
||||||
|
"dihedral_style"
|
||||||
|
"dihedral_coeff"
|
||||||
|
"improper_style"
|
||||||
|
"improper_coeff")
|
||||||
|
"LAMMPS particle.")
|
||||||
|
|
||||||
(defvar lammps-repeat
|
(defvar lammps-repeat
|
||||||
'("jump" "next" "loop")
|
'("jump"
|
||||||
"LAMMPS repeat.")
|
"next"
|
||||||
|
"loop")
|
||||||
|
"LAMMPS repeat.")
|
||||||
|
|
||||||
(defvar lammps-operator
|
(defvar lammps-operator
|
||||||
'("equal" "add" "sub" "mult" "div")
|
'("equal"
|
||||||
"LAMMPS operator.")
|
"add"
|
||||||
|
"sub"
|
||||||
|
"mult"
|
||||||
|
"div")
|
||||||
|
"LAMMPS operator.")
|
||||||
|
|
||||||
(defvar lammps-conditional
|
(defvar lammps-conditional
|
||||||
'("if" "then" "elif" "else")
|
'("if"
|
||||||
"LAMMPS conditional.")
|
"then"
|
||||||
|
"elif"
|
||||||
|
"else")
|
||||||
|
"LAMMPS conditional.")
|
||||||
|
|
||||||
(defvar lammps-special
|
(defvar lammps-special
|
||||||
'("EDGE" "NULL")
|
'("EDGE"
|
||||||
"LAMMPS special.")
|
"NULL")
|
||||||
|
"LAMMPS special.")
|
||||||
|
|
||||||
;; create the regex string for each class of keywords
|
;; create the regex string for each class of keywords
|
||||||
(defvar lammps-output-regexp (regexp-opt lammps-output 'words))
|
(defvar lammps-output-regexp (regexp-opt lammps-output 'words))
|
||||||
(defvar lammps-read-regexp (regexp-opt lammps-read 'words))
|
(defvar lammps-read-regexp (regexp-opt lammps-read 'words))
|
||||||
(defvar lammps-lattice-regexp (regexp-opt lammps-lattice 'words))
|
(defvar lammps-lattice-regexp (regexp-opt lammps-lattice 'words))
|
||||||
(defvar lammps-define-regexp (regexp-opt lammps-define 'words))
|
(defvar lammps-define-regexp (regexp-opt lammps-define 'words))
|
||||||
(defvar lammps-run-regexp (regexp-opt lammps-run 'words))
|
(defvar lammps-run-regexp (regexp-opt lammps-run 'words))
|
||||||
(defvar lammps-setup-regexp (regexp-opt lammps-setup 'words))
|
(defvar lammps-setup-regexp (regexp-opt lammps-setup 'words))
|
||||||
(defvar lammps-particle-regexp (regexp-opt lammps-particle 'words))
|
(defvar lammps-particle-regexp (regexp-opt lammps-particle 'words))
|
||||||
(defvar lammps-repeat-regexp (regexp-opt lammps-repeat 'words))
|
(defvar lammps-repeat-regexp (regexp-opt lammps-repeat 'words))
|
||||||
(defvar lammps-operator-regexp (regexp-opt lammps-operator 'words))
|
(defvar lammps-operator-regexp (regexp-opt lammps-operator 'words))
|
||||||
(defvar lammps-conditional-regexp (regexp-opt lammps-conditional 'words))
|
(defvar lammps-conditional-regexp (regexp-opt lammps-conditional 'words))
|
||||||
(defvar lammps-special-regexp (regexp-opt lammps-special 'words))
|
(defvar lammps-special-regexp (regexp-opt lammps-special 'words))
|
||||||
|
|
||||||
;; Add some more classes using explicit regexp
|
;; Add some more classes using explicit regexp
|
||||||
|
|
||||||
(defvar lammps-number-regexp
|
(defvar lammps-number-regexp
|
||||||
"\\<[0-9]\\>"
|
"\\<[0-9]\\>")
|
||||||
)
|
|
||||||
|
|
||||||
(defvar lammps-float-regexp
|
(defvar lammps-float-regexp
|
||||||
"\\<[0-9-+]+.[0-9-+]*\\>"
|
"\\<[0-9-+]+.[0-9-+]*\\>")
|
||||||
)
|
|
||||||
|
|
||||||
(defvar lammps-comment-regexp
|
(defvar lammps-comment-regexp
|
||||||
"#*"
|
"#*")
|
||||||
)
|
|
||||||
|
|
||||||
(defvar lammps-variable-regexp
|
(defvar lammps-variable-regexp
|
||||||
"\\$\\({[a-zA-Z0-9_]+}\\)\\|\\$[A-Za-z]"
|
"\\$\\({[a-zA-Z0-9_]+}\\)\\|\\$[A-Za-z]")
|
||||||
)
|
|
||||||
|
|
||||||
;; clear memory
|
;; clear memory
|
||||||
(setq lammps-output nil)
|
(setq lammps-output nil)
|
||||||
(setq lammps-read nil)
|
(setq lammps-read nil)
|
||||||
(setq lammps-lattice nil)
|
(setq lammps-lattice nil)
|
||||||
(setq lammps-define nil)
|
(setq lammps-define nil)
|
||||||
(setq lammps-run nil)
|
(setq lammps-run nil)
|
||||||
(setq lammps-setup nil)
|
(setq lammps-setup nil)
|
||||||
(setq lammps-particle nil)
|
(setq lammps-particle nil)
|
||||||
(setq lammps-repeat nil)
|
(setq lammps-repeat nil)
|
||||||
(setq lammps-operator nil)
|
(setq lammps-operator nil)
|
||||||
(setq lammps-conditional nil)
|
(setq lammps-conditional nil)
|
||||||
(setq lammps-special nil)
|
(setq lammps-special nil)
|
||||||
|
|
||||||
;; create the list for font-lock.
|
;; create the list for font-lock.
|
||||||
;; each class of keyword is given a particular face
|
;; 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-output-regexp . font-lock-function-name-face)
|
||||||
(,lammps-read-regexp . font-lock-preprocessor-face)
|
(,lammps-read-regexp . font-lock-preprocessor-face)
|
||||||
(,lammps-lattice-regexp . font-lock-type-face)
|
(,lammps-lattice-regexp . font-lock-type-face)
|
||||||
(,lammps-define-regexp . font-lock-variable-name-face)
|
(,lammps-define-regexp . font-lock-variable-name-face)
|
||||||
(,lammps-run-regexp . font-lock-keyword-face)
|
(,lammps-run-regexp . font-lock-keyword-face)
|
||||||
(,lammps-setup-regexp . font-lock-type-face)
|
(,lammps-setup-regexp . font-lock-type-face)
|
||||||
(,lammps-particle-regexp . font-lock-type-face)
|
(,lammps-particle-regexp . font-lock-type-face)
|
||||||
(,lammps-repeat-regexp . font-lock-string-face)
|
(,lammps-repeat-regexp . font-lock-string-face)
|
||||||
(,lammps-operator-regexp . font-lock-warning-face)
|
(,lammps-operator-regexp . font-lock-warning-face)
|
||||||
(,lammps-conditional-regexp . font-lock-builtin-face)
|
(,lammps-conditional-regexp . font-lock-builtin-face)
|
||||||
(,lammps-special-regexp . font-lock-constant-face)
|
(,lammps-special-regexp . font-lock-constant-face)
|
||||||
(,lammps-float-regexp . font-lock-constant-face)
|
(,lammps-float-regexp . font-lock-constant-face)
|
||||||
(,lammps-number-regexp . font-lock-constant-face)
|
(,lammps-number-regexp . font-lock-constant-face)
|
||||||
(,lammps-comment-regexp . font-lock-constant-face)
|
(,lammps-comment-regexp . font-lock-constant-face)
|
||||||
(,lammps-variable-regexp . font-lock-function-name-face)
|
(,lammps-variable-regexp . font-lock-function-name-face)
|
||||||
;; note: order above matters. lammps-variable-regexp¡ goes last because
|
;; note: order above matters. lammps-variable-regexp¡ goes last because
|
||||||
;; otherwise the keyword ´state¡ in the variable ´state_entry¡
|
;; otherwise the keyword ´state¡ in the variable ´state_entry¡
|
||||||
;; would be highlighted.
|
;; would be highlighted.
|
||||||
))
|
))
|
||||||
|
|
||||||
;; define the mode
|
;; define the mode
|
||||||
(define-derived-mode lammps-mode shell-script-mode
|
(define-derived-mode lammps-mode shell-script-mode
|
||||||
"lammps mode"
|
"lammps mode"
|
||||||
"Major mode for editing LAMMPS input scripts ..."
|
"Major mode for editing LAMMPS input scripts ..."
|
||||||
;; ...
|
;; ...
|
||||||
|
|
||||||
;; code for syntax highlighting
|
;; code for syntax highlighting
|
||||||
(setq font-lock-defaults '((lammps-font-lock-keywords)))
|
(setq font-lock-defaults '((lammps-font-lock-keywords)))
|
||||||
|
|
||||||
;; clear memory
|
;; clear memory
|
||||||
(setq lammps-output-regexp nil)
|
(setq lammps-output-regexp nil)
|
||||||
(setq lammps-read-regexp nil)
|
(setq lammps-read-regexp nil)
|
||||||
(setq lammps-lattice-regexp nil)
|
(setq lammps-lattice-regexp nil)
|
||||||
(setq lammps-define-regexp nil)
|
(setq lammps-define-regexp nil)
|
||||||
(setq lammps-run-regexp nil)
|
(setq lammps-run-regexp nil)
|
||||||
(setq lammps-setup-regexp nil)
|
(setq lammps-setup-regexp nil)
|
||||||
(setq lammps-particle-regexp nil)
|
(setq lammps-particle-regexp nil)
|
||||||
(setq lammps-repeat-regexp nil)
|
(setq lammps-repeat-regexp nil)
|
||||||
(setq lammps-operator-regexp nil)
|
(setq lammps-operator-regexp nil)
|
||||||
(setq lammps-conditional-regexp nil)
|
(setq lammps-conditional-regexp nil)
|
||||||
(setq lammps-special-regexp nil)
|
(setq lammps-special-regexp nil)
|
||||||
(setq lammps-number-regexp nil)
|
(setq lammps-number-regexp nil)
|
||||||
(setq lammps-float-regexp nil)
|
(setq lammps-float-regexp nil)
|
||||||
(setq lammps-comment-regexp nil)
|
(setq lammps-comment-regexp nil)
|
||||||
(setq lammps-variable-regexp nil)
|
(setq lammps-variable-regexp nil))
|
||||||
)
|
|
||||||
|
|
||||||
;; apply it to specified filename patterns
|
;; apply it to specified filename patterns
|
||||||
(setq auto-mode-alist
|
(setq
|
||||||
(append auto-mode-alist
|
auto-mode-alist
|
||||||
'(("in\\." . lammps-mode))
|
(append
|
||||||
'(("\\.lmp\\'" . lammps-mode))
|
auto-mode-alist
|
||||||
)
|
'(("in\\." . lammps-mode))
|
||||||
)
|
'(("\\.lmp\\'" . lammps-mode))
|
||||||
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue