Add lcp-mode for Emacs

Reviewers: mtomic, buda

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1549
This commit is contained in:
Teon Banek 2018-08-21 16:21:30 +02:00
parent 8717eb0734
commit da3630f8a9
2 changed files with 46 additions and 0 deletions

21
tools/emacs-lcp/README.md Normal file
View File

@ -0,0 +1,21 @@
# lcp-mode
Emacs major mode for editing LCP files. It relies on `mmm-mode` for
integrating multiple major modes in a single buffer.
`lcp-mode` is derived from `lisp-mode`, so all your custom bindings for that
mode should work out of the box. Since LCP supports embedding C++ code blocks,
the `lcp-mode` shifts from `lisp-mode` to `c-mode` in such blocks. Therefore,
your `c-mode` bindings should also work. You may wonder why isn't `c++-mode`
used. The reason is that, unfortunately, `c++-mode` has some issues when used
with `mmm-mode`.
Future improvements to this mode may include fixing issues with `c++-mode`,
adding additional syntax highlighting as well as new editing commands.
## Installation
Just put the following somewhere in your Emacs init file. It will
automatically install `mmm-mode` from the ELPA repository if needed.
(require 'lcp-mode "<path-to-memgraph>/tools/emacs-lcp/lcp-mode.el")

View File

@ -0,0 +1,25 @@
(defun require-package (package &optional min-version no-refresh)
"Install PACKAGE with optional MIN-VERSION.
If NO-REFRESH is non NIL, the available package list will not be refreshed."
(if (package-installed-p package min-version)
t
(if (or (assoc package package-archive-contents) no-refresh)
(package-install package)
(package-refresh-contents)
(package-install package))))
(require-package 'mmm-mode)
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(define-derived-mode lcp-mode lisp-mode "LCP" "Mode for editing LCP files at Memgraph."
(setq mmm-submode-decoration-level 0))
(mmm-add-classes '((lcp-c++ :submode c-mode ; c++-mode is buggy
:front "#>cpp" :back "cpp<#")))
(mmm-add-mode-ext-class 'lcp-mode nil 'lcp-c++)
(add-to-list 'auto-mode-alist '("\\.lcp\\'" . lcp-mode))
(provide 'lcp-mode)