forked from zellio/j-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
j-mode.el
122 lines (99 loc) · 3.66 KB
/
j-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
;;; j-mode.el --- Major mode for editing J programs
;; Copyright (C) 2012 Zachary Elliott
;;
;; Authors: Zachary Elliott <[email protected]>
;; URL: https://github.com/zellio/j-mode
;; Version: 1.1.1
;; Keywords: J, Languages
;; This file is not part of GNU Emacs.
;;; Commentary:
;; Provides font-lock and basic REPL integration for the
;; [J programming language](http://www.jsoftware.com)
;;; Installation
;; The only method of installation is to check out the project, add it to the
;; load path, and load normally. This may change one day.
;;
;; Put this in your emacs config
;; (add-to-list 'load-path "/path/to/j-mode/")
;; (load "j-mode")
;;
;; Add for detection of j source files if the auto-load fails
;; (add-to-list 'auto-mode-alist '("\\.ij[rstp]$" . j-mode)))
;;; License:
;; 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
;; GNU Emacs; see the file COPYING. If not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;; USA.
;;; Code:
;; Required eval depth for older systems
(setq max-lisp-eval-depth (max 500 max-lisp-eval-depth))
(require 'j-font-lock)
(require 'j-console)
(require 'j-help)
(defconst j-mode-version "1.1.1"
"`j-mode' version")
(defgroup j-mode nil
"A mode for J"
:group 'languages
:prefix "j-")
(defcustom j-mode-hook nil
"Hook called by `j-mode'"
:type 'hook
:group 'j)
(defvar j-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c !") 'j-console)
(define-key map (kbd "C-c C-c") 'j-console-execute-buffer)
(define-key map (kbd "C-c C-r") 'j-console-execute-region)
(define-key map (kbd "C-c C-l") 'j-console-execute-line)
(define-key map (kbd "C-c h") 'j-help-lookup-symbol)
(define-key map (kbd "C-c C-h") 'j-help-lookup-symbol-at-point)
map)
"Keymap for J major mode")
(defvar j-mode-menu nil "Drop-down menu for j-mode interaction")
(easy-menu-define j-mode-menu j-mode-map "J Mode menu"
'("J"
["Start J Console" j-console t]
["Execute Buffer" j-console-execute-buffer t]
["Execute Region" j-console-execute-region t]
["Execute Line" j-console-execute-line t]
"---"
["J Symbol Look-up" j-help-lookup-symbol t]
["J Symbol Dynamic Look-up" j-help-lookup-symbol-at-point t]
["Help on J-mode" describe-mode t]))
;;;###autoload
(defun j-mode ()
"Major mode for editing J"
(interactive)
(kill-all-local-variables)
(use-local-map j-mode-map)
(setq mode-name "J"
major-mode 'j-mode)
(set-syntax-table j-font-lock-syntax-table)
(set (make-local-variable 'comment-start)
"NB. ")
(set (make-local-variable 'comment-start-skip)
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)NB. *")
(set (make-local-variable 'font-lock-comment-start-skip)
"NB. *")
(set (make-local-variable 'font-lock-defaults)
'(j-font-lock-keywords
nil nil nil nil
;;(font-lock-mark-block-function . mark-defun)
(font-lock-syntactic-face-function
. j-font-lock-syntactic-face-function)))
(run-mode-hooks 'j-mode-hook))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.ij[rstp]$" . j-mode))
(provide 'j-mode)
;;; j-mode.el ends here