emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/j-mode 3e9dacc 11/56: Breaking j-mode into 4 files for eas


From: ELPA Syncer
Subject: [nongnu] elpa/j-mode 3e9dacc 11/56: Breaking j-mode into 4 files for easier maintainence
Date: Sun, 29 Aug 2021 11:20:45 -0400 (EDT)

branch: elpa/j-mode
commit 3e9dacce5d8708295c0757c270def5eeb04a207c
Author: Zachary Elliott <zach@nyu.edu>
Commit: Zachary Elliott <zach@nyu.edu>

    Breaking j-mode into 4 files for easier maintainence
---
 j-console.el   | 139 +++++++++++++++++++++++++++++
 j-font-lock.el | 223 ++++++++++++++++++++++++++++++++++++++++++++++
 j-help.el      |   9 +-
 j-mode.el      | 276 +++++----------------------------------------------------
 4 files changed, 388 insertions(+), 259 deletions(-)

diff --git a/j-console.el b/j-console.el
new file mode 100644
index 0000000..d17a7f2
--- /dev/null
+++ b/j-console.el
@@ -0,0 +1,139 @@
+
+;;; j-mode.el --- Major mode for editing J programs
+
+;; Copyright (C) 2012 Zachary Elliott
+;;
+;; Authors: Zachary Elliott <ZacharyElliott1@gmail.com>
+;; URL: http://github.com/zellio/j-mode
+;; Version: 0.0.1
+;; Keywords: J, Langauges
+
+;; This file is not part of GNU Emacs.
+
+;;; Commentary:
+
+;;
+
+;;; 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:
+
+
+(require 'comint)
+
+
+(defconst j-console-version "0.0.1"
+  "`j-console' version")
+
+(defgroup j-console nil
+  "REPL integration extention for `j-mode'"
+  :group 'applications
+  :group 'j
+  :prefix "j-console-")
+
+(defcustom j-console-cmd "jconsole"
+  "Name of the executable used for the J REPL session"
+  :type 'string
+  :group 'j-console)
+
+(defcustom j-console-cmd-args '()
+  "Arguments to be passed to the j-console-cmd on start"
+  :type 'string
+  :group 'j-console)
+
+(defcustom j-console-cmd-init-file nil
+  "Full path to the file who's contents are sent to the
+  j-console-cmd on start"
+  :type 'string
+  :group 'j-console)
+
+(defcustom j-console-cmd-buffer-name "J"
+  "Name of the buffer which contains the j-console-cmd session"
+  :type 'string
+  :group 'j-console)
+
+(defvar j-console-comint-input-filter-function nil
+  "")
+
+(defvar j-console-comint-output-filter-function nil
+  "")
+
+(defvar j-console-comint-preoutput-filter-function nil
+  "")
+
+;; 'comint-preoutput-filter-functions
+;; (lambda ( output )
+;;   (if (string-match "^[ \r\n\t]+" output)
+;;       (concat "  " (replace-match "" nil t output))
+;;     output))))
+
+(defun j-console-create-session ()
+  "Starts a comint session"
+  (setq comint-process-echoes t)
+  (apply 'make-comint j-console-cmd-buffer-name
+         j-console-cmd j-console-cmd-init-file j-console-cmd-args)
+  (mapc
+   (lambda ( comint-hook-sym )
+     (let ((local-comint-hook-fn-sym
+            (intern
+             (replace-regexp-in-string
+              "s$" "" (concat "j-console-" (symbol-name comint-hook-sym))))))
+       (when (symbol-value local-comint-hook-fn-sym)
+         (add-hook comint-hook-sym (symbol-value local-comint-hook-fn-sym)))))
+   '(comint-input-filter-functions
+     comint-output-filter-functions
+     comint-preoutput-filter-functions)))
+
+(defun j-console-ensure-session ()
+  "Checks for a running j-console-cmd comint session and either
+  returns it or starts a new session and returns that"
+  (or (get-process j-console-cmd-buffer-name)
+      (progn
+        (j-console-create-session)
+        (get-process j-console-cmd-buffer-name))))
+
+;;;###autoload
+(defun j-console ()
+  "Ensure a running j-console-cmd session and switches focus to
+the containing buffer"
+  (interactive)
+  (switch-to-buffer-other-window (process-buffer (j-console-ensure-session))))
+
+(defun j-console-execute-region ( start end )
+  "Sends current region to the j-console-cmd session and exectues it"
+  (interactive "r")
+  (when (= start end)
+    (error "Region is empty"))
+  (let ((region (buffer-substring-no-properties start end))
+        (session (j-console-ensure-session)))
+    (pop-to-buffer (process-buffer session))
+    (goto-char (point-max))
+    (insert-string (format "\n%s\n" region))
+    (comint-send-input)))
+
+(defun j-console-execute-line ()
+  "Sends current line to the j-console-cmd session and exectues it"
+  (interactive)
+  (j-console-execute-region (point-at-bol) (point-at-eol)))
+
+(defun j-console-execute-buffer ()
+  "Sends current buffer to the j-console-cmd session and exectues it"
+  (interactive)
+  (j-console-execute-region (point-min) (point-max)))
+
+(provide 'j-console)
diff --git a/j-font-lock.el b/j-font-lock.el
new file mode 100644
index 0000000..1173195
--- /dev/null
+++ b/j-font-lock.el
@@ -0,0 +1,223 @@
+
+;;; j-font-lock.el --- font-lock extension for j-mode
+
+;; Copyright (C) 2012 Zachary Elliott
+;;
+;; Authors: Zachary Elliott <ZacharyElliott1@gmail.com>
+;; URL: http://github.com/zellio/j-mode
+;; Version: 0.0.1
+;; Keywords: J, Langauges
+
+;; This file is not part of GNU Emacs.
+
+;;; Commentary:
+
+;;
+
+;;; 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:
+
+
+(defconst j-font-lock-version "0.0.1"
+  "`j-font-lock' version")
+
+(defgroup j-font-lock nil
+  "font-lock extension for j-mode"
+  :group 'j
+  :prefix "j-font-lock-")
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defgroup j-faces nil
+  "Faces for j-mode font-lock"
+  :group 'j-)
+
+(defmacro build-faces ( &rest faces )
+  "Allows for easy defining of multiple faces in one command.
+
+ (BUILD-FACES (FACE-NAME FACE-RULES DOCS-STR &optional GROUP) ...)"
+  `(eval-when-compile
+     ,@(mapcan (lambda ( x )
+                 (let* ((name (car x))
+                        (body (cdr x)))
+                   `((defvar ,name ',name)
+                     (defface ,name ,@body))))
+               faces)))
+
+(build-faces
+ (j-verb-face
+  `((t (:foreground "Red")))
+  "Font Lock mode face used to higlight vrebs"
+  :group 'j-faces)
+
+ (j-adverb-face
+  `((t (:foreground "Green")))
+  "Font Lock mode face used to higlight adverbs"
+  :group 'j-faces)
+
+ (j-conjunction-face
+  `((t (:foreground "Blue")))
+  "Font Lock mode face used to higlight conjunctions"
+  :group 'j-faces)
+
+ (j-other-face
+  `((t (:foreground "Black")))
+  "Font Lock mode face used to higlight others"
+  :group 'j-faces))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defvar j-font-lock-syntax-table
+  (let ((table (make-syntax-table)))
+    (modify-syntax-entry ?\{ "."   table)
+    (modify-syntax-entry ?\} "."   table)
+    (modify-syntax-entry ?\[ "."   table)
+    (modify-syntax-entry ?\] "."   table)
+    (modify-syntax-entry ?\" "."   table)
+    (modify-syntax-entry ?\\ "."   table)
+    (modify-syntax-entry ?\. "w"   table)
+    (modify-syntax-entry ?\: "w"   table)
+    (modify-syntax-entry ?\( "()"  table)
+    (modify-syntax-entry ?\) ")("  table)
+    (modify-syntax-entry ?\' "\""  table)
+    (modify-syntax-entry ?\N "w 1" table)
+    (modify-syntax-entry ?\B "w 2" table)
+    (modify-syntax-entry ?\n ">"   table)
+    (modify-syntax-entry ?\r ">"   table)
+    table)
+  "Syntax table for j-mode")
+
+(defvar j-font-lock-constants '())
+
+(defvar j-font-lock-control-structures
+  '("assert."  "break."  "continue."  "while."  "whilst."  "for."  "do."  
"end."
+    "if."  "else."  "elseif."  "return."  "select."  "case."  "fcase."  
"throw."
+    "try."  "catch."  "catchd."  "catcht."  "end."
+    ;; "for_[a-zA-Z]+\\."  "goto_[a-zA-Z]+\\."  "label_[a-zA-Z]+\\."
+    ))
+
+(defvar j-font-lock-foreign-conjunctions
+  '("0!:" "1!:" "2!:" "3!:" "4!:" "5!:" "6!:" "7!:" "8!:" "9!:" "11!:" "13!:"
+    "15!:" "18!:" "128!:" ))
+
+(defvar j-font-lock-len-3-verbs
+  '("_9:" "p.." "{::"))
+(defvar j-font-lock-len-2-verbs
+  '("x:" "u:" "s:" "r." "q:" "p:" "p." "o." "L." "j." "I." "i:" "i." "E." "e."
+    "C." "A." "?." "\":" "\"." "}:" "}." "{:" "{." "[:" "/:" "#:" "#." ";:" 
",:"
+    ",." "|:" "|." "~:" "~." "$:" "$." "^." "%:" "%." "-:" "-." "*:" "*."  "+:"
+    "+." "_:" ">:" ">." "<:" "<."))
+(defvar j-font-lock-len-1-verbs
+  '("?" "{" "]" "[" ":" "!" "#" ";" "," "|" "$" "^" "%" "-" "*" "+" ">" "<" 
"="))
+(defvar j-font-lock-verbs
+  (append j-font-lock-len-3-verbs j-font-lock-len-2-verbs 
j-font-lock-len-1-verbs))
+
+(defvar j-font-lock-len-2-adverbs
+  '("t:" "t." "M." "f." "b." "/."))
+(defvar j-font-lock-len-1-adverbs
+  '("}" "." "\\" "/" "~"))
+(defvar j-font-lock-adverbs
+  (append j-font-lock-len-2-adverbs j-font-lock-len-1-adverbs))
+
+(defvar j-font-lock-len-3-others
+  '("NB."))
+(defvar j-font-lock-len-2-others
+  '("=." "=:" "_." "a." "a:"))
+(defvar j-font-lock-len-1-others
+  '("_" ))
+(defvar j-font-lock-others
+  (append j-font-lock-len-3-others j-font-lock-len-2-others 
j-font-lock-len-1-others))
+
+(defvar j-font-lock-len-3-conjunctions
+  '("&.:"))
+(defvar j-font-lock-len-2-conjunctions
+  '("T." "S:" "L:" "H." "D:" "D." "d." "&:" "&." "@:" "@." "`:" "!:" "!." ";."
+    "::" ":." ".:" ".." "^:"))
+(defvar j-font-lock-len-1-conjunctions
+  '("&" "@" "`" "\"" ":" "."))
+(defvar j-font-lock-conjunctions
+  (append j-font-lock-len-3-conjunctions
+          j-font-lock-len-2-conjunctions
+          j-font-lock-len-1-conjunctions))
+
+
+(defvar j-font-lock-keywords
+  `(
+    ("\\([_a-zA-Z0-9]+\\)\s*\\(=[.:]\\)"
+     (1 font-lock-variable-name-face) (2 j-other-face))
+
+    (,(regexp-opt j-font-lock-foreign-conjunctions) . font-lock-warning-face)
+    (,(concat (regexp-opt j-font-lock-control-structures)
+              "\\|\\(?:\\(?:for\\|goto\\|label\\)_[a-zA-Z]+\\.\\)")
+     . font-lock-keyword-face)
+    (,(regexp-opt j-font-lock-constants) . font-lock-constant-face)
+    (,(regexp-opt j-font-lock-len-3-verbs) . j-verb-face)
+    (,(regexp-opt j-font-lock-len-3-conjunctions) . j-conjunction-face)
+    ;;(,(regexp-opt j-font-lock-len-3-others) . )
+    (,(regexp-opt j-font-lock-len-2-verbs) . j-verb-face)
+    (,(regexp-opt j-font-lock-len-2-adverbs) . j-adverb-face)
+    (,(regexp-opt j-font-lock-len-2-conjunctions) . j-conjunction-face)
+    ;;(,(regexp-opt j-font-lock-len-2-others) . )
+    (,(regexp-opt j-font-lock-len-1-verbs) . j-verb-face)
+    (,(regexp-opt j-font-lock-len-1-adverbs) . j-adverb-face)
+    (,(regexp-opt j-font-lock-len-1-conjunctions) . j-conjunction-face)
+    ;;(,(regexp-opt j-font-lock-len-1-other) . )
+    ) "J Mode font lock keys words")
+
+(defun j-font-lock-syntactic-face-function (state)
+  "Function for detection of string vs. Comment Note: J comments
+are three chars longs, there is no easy / evident way to handle
+this in emacs and it poses problems"
+  (if (nth 3 state) font-lock-string-face
+    (let* ((start-pos (nth 8 state)))
+      (and (<= (+ start-pos 3) (point-max))
+           (eq (char-after start-pos) ?N)
+           (string= (buffer-substring-no-properties
+                     start-pos (+ start-pos 3)) "NB.")
+           font-lock-comment-face))))
+
+(provide 'j-font-lock)
+
+;;;;;###autoload
+;;(defun j-mode ()
+;;  "Major mode for editing J code"
+;;  (interactive)
+;;  (kill-all-local-variables)
+;;  (use-local-map j-mode-map)
+;;  (setq mode-name "J"
+;;        major-mode 'j-mode)
+;;  (set-syntax-table j-mode-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-mode-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
+;;(progn
+;;  (add-to-list 'auto-mode-alist '("\\.ij[rstp]$" . j-mode)))
+;;
+;;(provide 'j-mode '(j-console))
+;;
diff --git a/j-help.el b/j-help.el
index 98575eb..b4e9bf0 100644
--- a/j-help.el
+++ b/j-help.el
@@ -1,5 +1,5 @@
 
-;;; j-help.el --- Help extension for j-mode.el
+;;; j-help.el --- Documentation extention for j-mode
 
 ;; Copyright (C) 2012 Zachary Elliott
 ;;
@@ -12,9 +12,6 @@
 
 ;;; Commentary:
 
-;; Provides look up functions for the J software language documentation as
-;; provided by the VOC and other documentation on jsoftware.com
-
 ;; This is not complete
 
 ;;; License:
@@ -72,7 +69,7 @@ It groups the objects in LIST according to the predicate FN"
     (group-by* sl fn '() '() '())))
 
 (defgroup j-help nil
-  "Help documentation for j-mode"
+  "Documentation extention for j-mode"
   :group 'applications
   :prefix "j-help-")
 
@@ -190,3 +187,5 @@ It groups the objects in LIST according to the predicate FN"
   (if-let ((symbol (j-help-determine-symbol-at-point point)))
       (j-help-lookup-symbol symbol)
     (error "No symbol could be determined for point %d" point)))
+
+(provide 'j-help)
diff --git a/j-mode.el b/j-mode.el
index b853e7b..cbc41f0 100644
--- a/j-mode.el
+++ b/j-mode.el
@@ -5,7 +5,7 @@
 ;;
 ;; Authors: Zachary Elliott <ZacharyElliott1@gmail.com>
 ;; URL: http://github.com/zellio/j-mode
-;; Version: 0.0.8
+;; Version: 0.1.0
 ;; Keywords: J, Langauges
 
 ;; This file is not part of GNU Emacs.
@@ -34,11 +34,11 @@
 
 ;;; Code:
 
+(require 'j-console)
+(require 'j-help)
+(require 'j-font-lock)
 
-(require 'comint)
-
-
-(defconst j-mode-version "0.0.8"
+(defconst j-mode-version "0.1.0"
   "`j-mode' version")
 
 (defgroup j-mode nil
@@ -49,179 +49,30 @@
 (defcustom j-mode-hook nil
   "Hook called by `j-mode'."
   :type 'hook
-  :group 'j-)
-
-
-(defgroup j-faces nil
-  "Faces for j-mode font-lock"
-  :group 'j-)
-
-(defmacro build-faces ( &rest faces )
-  "Allows for easy defining of multiple faces in one command.
-
- (BUILD-FACES (FACE-NAME FACE-RULES DOCS-STR &optional GROUP) ...)"
-  `(eval-when-compile
-     ,@(mapcan (lambda ( x )
-                 (let* ((name (car x))
-                        (body (cdr x)))
-                   `((defvar ,name ',name)
-                     (defface ,name ,@body))))
-               faces)))
-
-(build-faces
- (j-verb-face
-  `((t (:foreground "Red")))
-  "Font Lock mode face used to higlight vrebs"
-  :group 'j-faces)
-
- (j-adverb-face
-  `((t (:foreground "Green")))
-  "Font Lock mode face used to higlight adverbs"
-  :group 'j-faces)
-
- (j-conjunction-face
-  `((t (:foreground "Blue")))
-  "Font Lock mode face used to higlight conjunctions"
-  :group 'j-faces)
-
- (j-other-face
-  `((t (:foreground "Black")))
-  "Font Lock mode face used to higlight others"
-  :group 'j-faces))
-
+  :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-execute-buffer)
-    (define-key map (kbd "C-c C-r") 'j-execute-region)
-    (define-key map (kbd "C-c C-l") 'j-execute-line)
+    (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-execute-buffer]
-    ["Execute Region" j-execute-region]
-    ["Execute Line" j-execute-line]
+    ["Execute Buffer" j-execute-buffer t]
+    ["Execute Region" j-execute-region t]
+    ["Execute Line" j-execute-line t]
     "---"
-    ["Help on J-mode" describe-mode t]
-    "---"
-    ("Sub-Menu")))
-
-
-(defvar j-mode-syntax-table
-  (let ((table (make-syntax-table)))
-    (modify-syntax-entry ?\{ "."  table)
-    (modify-syntax-entry ?\} "."  table)
-    (modify-syntax-entry ?\[ "."  table)
-    (modify-syntax-entry ?\] "."  table)
-    (modify-syntax-entry ?\" "."  table)
-    (modify-syntax-entry ?\\ "."  table)
-    (modify-syntax-entry ?\. "w"  table)
-    (modify-syntax-entry ?\: "w"  table)
-    (modify-syntax-entry ?\( "()"  table)
-    (modify-syntax-entry ?\) ")("  table)
-    (modify-syntax-entry ?\' "\"" table)
-    (modify-syntax-entry ?\N "w 1" table)
-    (modify-syntax-entry ?\B "w 2" table)
-    (modify-syntax-entry ?\n ">" table)
-    (modify-syntax-entry ?\r ">" table)
-    table)
-  "Syntax table for j-mode")
-
-
-(defvar j-mode-constants '())
-
-(defvar j-mode-control-structures
-  '("assert."  "break."  "continue."  "while."  "whilst."  "for."  "do."  
"end."
-    "if."  "else."  "elseif."  "return."  "select."  "case."  "fcase."  
"throw."
-    "try."  "catch."  "catchd."  "catcht."  "end."
-    ;; "for_[a-zA-Z]+\\."  "goto_[a-zA-Z]+\\."  "label_[a-zA-Z]+\\."
-    ))
-
-(defvar j-mode-foreign-conjunctions
-  '("0!:" "1!:" "2!:" "3!:" "4!:" "5!:" "6!:" "7!:" "8!:" "9!:" "11!:" "13!:"
-    "15!:" "18!:" "128!:" ))
-
-(defvar j-mode-len-3-verbs
-  '("_9:" "p.." "{::"))
-(defvar j-mode-len-2-verbs
-  '("x:" "u:" "s:" "r." "q:" "p:" "p." "o." "L." "j." "I." "i:" "i." "E." "e."
-    "C." "A." "?." "\":" "\"." "}:" "}." "{:" "{." "[:" "/:" "#:" "#." ";:" 
",:"
-    ",." "|:" "|." "~:" "~." "$:" "$." "^." "%:" "%." "-:" "-." "*:" "*."  "+:"
-    "+." "_:" ">:" ">." "<:" "<."))
-(defvar j-mode-len-1-verbs
-  '("?" "{" "]" "[" ":" "!" "#" ";" "," "|" "$" "^" "%" "-" "*" "+" ">" "<" 
"="))
-(defvar j-mode-verbs
-  (append j-mode-len-3-verbs j-mode-len-2-verbs j-mode-len-1-verbs))
-
-(defvar j-mode-len-2-adverbs
-  '("t:" "t." "M." "f." "b." "/."))
-(defvar j-mode-len-1-adverbs
-  '("}" "." "\\" "/" "~"))
-(defvar j-mode-adverbs
-  (append j-mode-len-2-adverbs j-mode-len-1-adverbs))
-
-(defvar j-mode-len-3-others
-  '("NB."))
-(defvar j-mode-len-2-others
-  '("=." "=:" "_." "a." "a:"))
-(defvar j-mode-len-1-others
-  '("_" ))
-(defvar j-mode-others
-  (append j-mode-len-3-others j-mode-len-2-others j-mode-len-1-others))
-
-(defvar j-mode-len-3-conjunctions
-  '("&.:"))
-(defvar j-mode-len-2-conjunctions
-  '("T." "S:" "L:" "H." "D:" "D." "d." "&:" "&." "@:" "@." "`:" "!:" "!." ";."
-    "::" ":." ".:" ".." "^:"))
-(defvar j-mode-len-1-conjunctions
-  '("&" "@" "`" "\"" ":" "."))
-(defvar j-mode-conjunctions
-  (append j-mode-len-3-conjunctions j-mode-len-2-conjunctions 
j-mode-len-1-conjunctions))
-
-
-(defvar j-mode-font-lock-keywords
-  `(
-    ("\\([_a-zA-Z0-9]+\\)\s*\\(=[.:]\\)"
-     (1 font-lock-variable-name-face) (2 j-other-face))
-
-    (,(regexp-opt j-mode-foreign-conjunctions) . font-lock-warning-face)
-    (,(concat (regexp-opt j-mode-control-structures)
-              "\\|\\(?:\\(?:for\\|goto\\|label\\)_[a-zA-Z]+\\.\\)")
-     . font-lock-keyword-face)
-    (,(regexp-opt j-mode-constants) . font-lock-constant-face)
-    (,(regexp-opt j-mode-len-3-verbs) . j-verb-face)
-    (,(regexp-opt j-mode-len-3-conjunctions) . j-conjunction-face)
-    ;;(,(regexp-opt j-mode-len-3-others) . )
-    (,(regexp-opt j-mode-len-2-verbs) . j-verb-face)
-    (,(regexp-opt j-mode-len-2-adverbs) . j-adverb-face)
-    (,(regexp-opt j-mode-len-2-conjunctions) . j-conjunction-face)
-    ;;(,(regexp-opt j-mode-len-2-others) . )
-    (,(regexp-opt j-mode-len-1-verbs) . j-verb-face)
-    (,(regexp-opt j-mode-len-1-adverbs) . j-adverb-face)
-    (,(regexp-opt j-mode-len-1-conjunctions) . j-conjunction-face)
-    ;;(,(regexp-opt j-mode-len-1-other) . )
-    ) "J Mode font lock keys words")
-
-
-(defun j-font-lock-syntactic-face-function (state)
-  "Function for detection of string vs. Comment Note: J comments
-are three chars longs, there is no easy / evident way to handle
-this in emacs and it poses problems"
-  (if (nth 3 state) font-lock-string-face
-    (let* ((start-pos (nth 8 state)))
-      (and (<= (+ start-pos 3) (point-max))
-           (eq (char-after start-pos) ?N)
-           (string= (buffer-substring-no-properties
-                     start-pos (+ start-pos 3)) "NB.")
-           font-lock-comment-face))))
-
+    ["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 ()
@@ -231,7 +82,7 @@ this in emacs and it poses problems"
   (use-local-map j-mode-map)
   (setq mode-name "J"
         major-mode 'j-mode)
-  (set-syntax-table j-mode-syntax-table)
+  (set-syntax-table j-font-lock-syntax-table)
   (set (make-local-variable 'comment-start)
        "NB.")
   (set (make-local-variable 'comment-start-skip)
@@ -239,98 +90,15 @@ this in emacs and it poses problems"
   (set (make-local-variable 'font-lock-comment-start-skip)
        "NB. *")
   (set (make-local-variable 'font-lock-defaults)
-       '(j-mode-font-lock-keywords
+       '(j-font-lock-keywords
          nil nil nil nil
-;;         (font-lock-mark-block-function . mark-defun)
+         ;;(font-lock-mark-block-function . mark-defun)
          (font-lock-syntactic-face-function
           . j-font-lock-syntactic-face-function)))
   (run-mode-hooks 'j-mode-hook))
 
-
-(defcustom j-cmd "jconsole"
-  "Name of the executable used to start a J session."
-  :type 'string
-  :group 'j-)
-
-(defcustom j-cmd-args '()
-  "Arguments to be passed to the j-cmd command on start."
-  :type 'string
-  :group 'j-)
-
-(defcustom j-cmd-init nil
-  "Full path to file who's contents are sent to the j-cmd on start."
-  :type 'string
-  :group 'j-)
-
-(defcustom j-cmd-buffer-name "J"
-  "Name of the buffer which contains the j-cmd session."
-  :type 'string
-  :group 'j-)
-
-(defun j-create-interpreter ()
-  "Starts a comint session using the various j-cmd variables"
-  (setq comint-process-echoes t)
-  (apply 'make-comint j-cmd-buffer-name j-cmd j-cmd-init j-cmd-args)
-  (add-hook
-   'comint-preoutput-filter-functions
-   (lambda ( output )
-     (if (string-match "^[ \r\n\t]+" output)
-         (concat "  " (replace-match "" nil t output))
-       output))))
-
-(defun j-ensure-interpreter ()
-  "Checks for a running j-cmd comint session.
-Will start a new one if a session isn't found."
-  (or (get-process j-cmd-buffer-name)
-      (progn
-        (j-create-interpreter)
-        (get-process j-cmd-buffer-name))))
-
-(defmacro defun-wp ( name label args docstring interactive &rest body )
-  "Simplifies working with `j-ensure-interpreter'"
-  `(defun ,name ,args
-     ,docstring
-     ,interactive
-     (let* ((,@label (j-ensure-interpreter)))
-       ,@body)))
-
-(defun-wp j-execute-line ( interpreter ) ()
-  "Sends current line to the j-cmd session and exectues it"
-  (interactive)
-  (let* ((line (buffer-substring-no-properties (point-at-bol)
-                                               (point-at-eol))))
-    (pop-to-buffer (process-buffer interpreter))
-    (goto-char (point-max))
-    (insert-string line)
-    (comint-send-input)))
-
-(defun-wp j-execute-region (interpreter) (start end)
-  "Sends current region to the j-cmd session and exectues it"
-  (interactive "r")
-  (and (= start end) (error "Region is empty"))
-  (let* ((region (buffer-substring-no-properties start end))
-         (block-size (if (and (= start (point-min)) (= end (point-max)))
-                         "buffer" "region"))
-         (region (concat "\nNB. Sending " block-size "...\n" region)))
-    (pop-to-buffer (process-buffer interpreter))
-    (insert-string (concat "\n" region "\n"))
-    (comint-send-input)))
-
-(defun j-execute-buffer ()
-  "Sends current buffer to the j-cmd session and exectues it"
-  (interactive)
-  (j-execute-region (point-min) (point-max)))
-
-;;;###autoload
-(defun j-console ()
-  "Ensures a running j-cmd session and switches focus to that buffer"
-  (interactive)
-  (switch-to-buffer-other-window (process-buffer (j-ensure-interpreter))))
-
-
 ;;;###autoload
 (progn
   (add-to-list 'auto-mode-alist '("\\.ij[rstp]$" . j-mode)))
 
-
-(provide 'j-mode '(j-console))
+(provide 'j-mode)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]