[E-Lang] Emacs E mode
Will Glozer
wglozer@yahoo.com
Sun, 5 Aug 2001 12:49:30 -0700 (PDT)
--0-790317057-997040970=:77166
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello, I'm posting an initial attempt at an Emacs mode for
programming in E. It provides syntax highlighting and
running the buffer or a region in the E interpreter. I'm not
much of an elisp hacker so I hope someone finds an interest
and continues work on this =)
Regards,
Will
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--0-790317057-997040970=:77166
Content-Type: text/plain; name="e-mode.el"
Content-Description: e-mode.el
Content-Disposition: inline; filename="e-mode.el"
;; A minimal Emacs major-mode for E, www.erights.org.
(defvar e-command "d:/e/bin/win32/e.exe"
"*Shell command used to start E interpreter.")
(defvar e-args '("--ehome" "d:/e")
"*Arguments to pass to the E interpreter.")
(setq e-mode-map nil)
(defvar e-mode-map ()
"Keymap used in `e-mode' buffers.")
(if e-mode-map
nil
(setq e-mode-map (make-sparse-keymap))
;; indentation level modifiers
(define-key e-mode-map "\C-c\C-c" 'e-execute-buffer)
(define-key e-mode-map "\C-c\C-r" 'e-execute-region)
; (define-key e-mode-map "{" 'c-electric-brace)
; (define-key e-mode-map "}" 'c-electric-brace)
; (define-key e-mode-map "\C-m" 'newline-and-indent))
)
(defvar e-font-lock-keywords
(let ((keywords (mapconcat 'identity
'("begin" "catch" "class" "def"
"define" "delegate" "else" "end"
"escape" "finally" "for" "if"
"in" "match" "meta" "switch"
"to" "try" "while"
)
"\\|"))
)
(list
;; keywords
(cons (concat "\\b\\(" keywords "\\)\\b[ \n\t(]") 1)
;; classes
'("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1 font-lock-type-face)
;; functions
'("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1 font-lock-function-name-face)
))
"Additional expressions to highlight in e mode.")
(put 'e-mode 'font-lock-defaults '(e-font-lock-keywords))
(defvar e-mode-syntax-table nil
"Syntax table used in `e-mode' buffers.")
(if e-mode-syntax-table
nil
(setq e-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?\` "\"" e-mode-syntax-table)
;; what a hack job... gnu emacs 20 is incapable of supporting E's 3
;; comment styles
;; use me if you want # and /* */ comments
(modify-syntax-entry ?\# "<" e-mode-syntax-table)
(modify-syntax-entry ?\n ">" e-mode-syntax-table))
(modify-syntax-entry ?/ ". 14b" e-mode-syntax-table)
(modify-syntax-entry ?* ". 23b" e-mode-syntax-table)
;; use me if you want // and /* */ comments
;(modify-syntax-entry ?\n "> b" e-mode-syntax-table))
;(modify-syntax-entry ?/ ". 124b" e-mode-syntax-table)
;(modify-syntax-entry ?* ". 23" e-mode-syntax-table)
(defun e-mode ()
"Major mode for editing E files."
(interactive)
;; set up local variables
(kill-all-local-variables)
(make-local-variable 'font-lock-defaults)
(make-local-variable 'comment-start)
(make-local-variable 'comment-end)
(make-local-variable 'comment-start-skip)
(make-local-variable 'comment-column)
(make-local-variable 'comment-indent-function)
(make-local-variable 'indent-region-function)
(make-local-variable 'indent-line-function)
(set-syntax-table e-mode-syntax-table)
(setq major-mode 'e-mode
mode-name "E"
;;**local-abbrev-table e-mode-abbrev-table
font-lock-defaults '(e-font-lock-keywords)
comment-start "# "
comment-end ""
comment-start-skip "# *"
comment-column 40
;comment-indent-function 'e-comment-indent-function
indent-region-function 'c-indent-region
; indent-line-function 'c-indent-line
indent-line-function 'indent-to-left-margin
;; tell add-log.el how to find the current function/method/variable
;add-log-current-defun-function 'e-current-defun
)
(use-local-map e-mode-map)
(c-set-offset 'statement-cont '0)
)
(defvar e-output-buffer "*E*")
(defun e-execute-region (start end &optional foo)
"Execute the region in an E interpreter."
(interactive "r\nP")
(or (< start end)
(error "Region is empty"))
(let ((e-buffer (get-buffer-create e-output-buffer)))
(if (get-process "E")
nil
(comint-exec e-buffer "E" e-command nil e-args))
(save-excursion
(process-send-region e-buffer start end)
(pop-to-buffer e-buffer)
(comint-mode)
(setq comint-prompt-regexp ".* $"))))
(defun e-execute-buffer (&optional foo)
"Send the contents of the buffer to an E interpreter.
If there is a *E* process buffer it is used."
(interactive "P")
(e-execute-region (point-min) (point-max)))
(setq auto-mode-alist (append '(("\\.e$" . e-mode)) auto-mode-alist))
(provide 'e-mode)
--0-790317057-997040970=:77166--