Skip to content

Instantly share code, notes, and snippets.

@dongweiming
Last active August 29, 2015 14:05
Show Gist options
  • Save dongweiming/67cceb80748c091f85d3 to your computer and use it in GitHub Desktop.
Save dongweiming/67cceb80748c091f85d3 to your computer and use it in GitHub Desktop.
A Major mode for demo
;;; pli.el --- A Major mode for demo
;; Description: A Major mode for demo
;; Created: 2014-09-01 01:12
;; Author: dongweiming [email protected]
;; URL: http://github.com/dongweiming/pli-mode
;; Keywords: test, emacs
;; Version: 1.0
;; Copyright (C) 2014, dongweiming, all rights reserved.
;; 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 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, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(defgroup pli nil
"Major mode for A test."
:prefix "pli-"
:group 'pli
:link '(url-link "http://github.com/dongweiming/pli-mode"))
(defgroup pli-faces nil
"Faces used in pli-mode"
:group 'pli
:group 'faces)
(defcustom pli-mode-hook nil
"Normal hook run when entering pli-mode."
:type 'hook
:group 'pli)
(defvar pli-mode-map
(let ((map (make-sparse-keymap)))
;; Element insertion
(define-key map (kbd "q") 'quit-window)
(define-key map (kbd "h") 'describe-mode)
map)
"Keymap for Pli major mode.")
(defvar pli-keywords
"Pli keywords")
(defvar pli-fuction-face 'pli-fuction-face)
(defface pli-fuction-face '((t (:background "#729fcf"
:foreground "#f590ae")))
"Pli function face."
:group 'pli-faces)
;; define several class of keywords
(setq pli-keywords '("break" "try" "do" "else" "for" "if" "return" "when" "while" "continue"))
(setq pli-types '("float" "integer" "key" "list" "string"))
(setq pli-constants '("DOUBAN" "AB" "T2" "T3"))
(setq pli-events '("at_rot_target" "at_target" "attach"))
(setq pli-functions '("class" "def"))
(defvar pli-font-lock-keywords
`(
(,(regexp-opt pli-keywords 'words) . font-lock-type-face)
(,(regexp-opt pli-types 'words) . font-lock-constant-face)
(,(regexp-opt pli-constants 'words) . font-lock-builtin-face)
(,(regexp-opt pli-events 'words) . pli-fuction-face)
(,(regexp-opt pli-functions 'words) . font-lock-keyword-face)))
(define-derived-mode pli-mode fundamental-mode "Pli"
"Major mode named Pli."
(set (make-local-variable 'buffer-read-only) t)
;; code for syntax highlighting
(setq font-lock-defaults '((pli-font-lock-keywords))))
(provide 'pli)
;; Local Variables:
;; coding: utf-8
;; End:
;;; pli.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment