annotate src/capnproto-0.6.0/highlighting/emacs/capnp-mode.el @ 79:91c729825bca pa_catalina

Update build for AUDIO_COMPONENT_FIX
author Chris Cannam
date Wed, 30 Oct 2019 12:40:34 +0000
parents 0994c39f1e94
children
rev   line source
cannam@62 1 ;;; capnp-mode.el --- major mode for editing Capn' Proto Files
cannam@62 2
cannam@62 3 ;; This is free and unencumbered software released into the public domain.
cannam@62 4
cannam@62 5 ;; Author: Brian Taylor <el.wubo@gmail.com>
cannam@62 6 ;; Version: 1.0.0
cannam@62 7
cannam@62 8 ;;; Commentary:
cannam@62 9
cannam@62 10 ;; Provides basic syntax highlighting for capnp files.
cannam@62 11 ;;
cannam@62 12 ;; To use:
cannam@62 13 ;;
cannam@62 14 ;; Add something like this to your .emacs file:
cannam@62 15 ;;
cannam@62 16 ;; (add-to-list 'load-path "~/src/capnproto/highlighting/emacs")
cannam@62 17 ;; (require 'capnp-mode)
cannam@62 18 ;; (add-to-list 'auto-mode-alist '("\\.capnp\\'" . capnp-mode))
cannam@62 19 ;;
cannam@62 20
cannam@62 21 ;;; Code:
cannam@62 22
cannam@62 23 ;; command to comment/uncomment text
cannam@62 24 (defun capnp-comment-dwim (arg)
cannam@62 25 "Comment or uncomment current line or region in a smart way.
cannam@62 26 For detail, see `comment-dwim'."
cannam@62 27 (interactive "*P")
cannam@62 28 (require 'newcomment)
cannam@62 29 (let (
cannam@62 30 (comment-start "#") (comment-end "")
cannam@62 31 )
cannam@62 32 (comment-dwim arg)))
cannam@62 33
cannam@62 34 (defvar capnp--syntax-table
cannam@62 35 (let ((syn-table (make-syntax-table)))
cannam@62 36
cannam@62 37 ;; bash style comment: “# …”
cannam@62 38 (modify-syntax-entry ?# "< b" syn-table)
cannam@62 39 (modify-syntax-entry ?\n "> b" syn-table)
cannam@62 40
cannam@62 41 syn-table)
cannam@62 42 "Syntax table for `capnp-mode'.")
cannam@62 43
cannam@62 44 (defvar capnp--keywords
cannam@62 45 '("struct" "enum" "interface" "union" "import"
cannam@62 46 "using" "const" "annotation" "extends" "in"
cannam@62 47 "of" "on" "as" "with" "from" "fixed")
cannam@62 48 "Keywords in `capnp-mode'.")
cannam@62 49
cannam@62 50 (defvar capnp--types
cannam@62 51 '("union" "group" "Void" "Bool" "Int8" "Int16"
cannam@62 52 "Int32" "Int64" "UInt8" "UInt16" "UInt32"
cannam@62 53 "UInt64" "Float32" "Float64" "Text" "Data"
cannam@62 54 "AnyPointer" "AnyStruct" "Capability" "List")
cannam@62 55 "Types in `capnp-mode'.")
cannam@62 56
cannam@62 57 (defvar capnp--font-lock-keywords
cannam@62 58 `(
cannam@62 59 (,(regexp-opt capnp--keywords 'words) . font-lock-keyword-face)
cannam@62 60 (,(regexp-opt capnp--types 'words) . font-lock-type-face)
cannam@62 61 ("@\\w+" . font-lock-constant-face))
cannam@62 62 "Font lock definitions in `capnp-mode'.")
cannam@62 63
cannam@62 64 ;;;###autoload
cannam@62 65 (define-derived-mode capnp-mode prog-mode
cannam@62 66 "capn-mode is a major mode for editing capnp protocol files"
cannam@62 67 :syntax-table capnp--syntax-table
cannam@62 68
cannam@62 69 (setq font-lock-defaults '((capnp--font-lock-keywords)))
cannam@62 70
cannam@62 71
cannam@62 72 (setq mode-name "capnp")
cannam@62 73 (define-key capnp-mode-map [remap comment-dwim] 'capnp-comment-dwim))
cannam@62 74
cannam@62 75 (provide 'capnp-mode)