Created
July 23, 2015 06:21
-
-
Save pranavcode/2a81274fcb2e737424ba to your computer and use it in GitHub Desktop.
INSILICO input file mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; command to comment/uncomment text | |
(defun insilico-mode-comment-dwim (arg) | |
"Comment or uncomment current line or region in a smart way. For detail, see comment-dwim'." | |
(interactive "*P") | |
(require 'newcomment) | |
(let ((comment-start "\"") (comment-end "\"") (comment-padding nil)) | |
(comment-dwim arg))) | |
;; A custom mode for editing insilico isf files | |
;; keywords for syntax coloring | |
(setq insilico-mode-keywords | |
`(( ,(regexp-opt '("dxdt" "pre" "post" "," ":" ";" "\"") 'word) . font-lock-constant-face))) | |
;; syntax table | |
(defvar insilico-mode-syntax-table nil "Syntax table for `insilico-mode'.") | |
(setq insilico-mode-syntax-table | |
(let ((synTable (make-syntax-table))) | |
(modify-syntax-entry ?\" "< b" synTable) | |
(modify-syntax-entry ?\" "> b" synTable) | |
synTable)) | |
;; define the major mode. | |
(define-derived-mode insilico-mode fundamental-mode | |
"insilico-mode is a major mode for editing insilico files." | |
:syntax-table insilico-mode-syntax-table | |
(setq font-lock-defaults '(insilico-mode-keywords)) | |
(setq mode-name "insilico-mode") | |
;; modify the keymap | |
(define-key insilico-mode-map [remap comment-dwim] 'insilico-mode-comment-dwim)) | |
;; Associate insilico's isf filename by suffix | |
;; setup files ending in ".insilico" to open in insilico-mode | |
(add-to-list 'auto-mode-alist '("\\.isf\\'" . insilico-mode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment