;;; gle-mode.el --- major mode for editing .gle files ;; Author: Graham Lee ;; Keywords: gle extensions ;; Version: 0.2.1 ;; Installation: ;; Put this file somewhere in your load-path (e.g. /usr/share/emacs/site-lisp) ;; Add the following to your ~/.emacs file: ;; (autoload 'gle-mode "gle-mode") ;; (add-to-list 'auto-mode-alist '("\\.gle\\'" . gle-mode)) ;; gle-mode will now be called whenever a .gle file is opened, or by executing ;; M-x gle-mode ;; To done (a.k.a. Version History): ;; 0.2.1: Then "adapted" it some more so that it worked! ;; 0.2.0: Shamelessly "adapted" some of Kai Nordlund's code to allow Emacs ;; to call GLE inline :-) ;; 0.1.5: Regexps cleaned up after suggestions by Stefan Monnier, also ;; Installation instructions trimmed a little. ;; 0.1.0: First ever public version! God it's ugly :-( ;; To do: ;; Some more regexps to tidy ;; Create some automatic indentification ;; Begin gle-mode (defvar gle-mode-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?! "<" st) (modify-syntax-entry ?\n ">" st) st) "Syntax table for `gle-mode'.") (defvar gle-font-lock-keywords `((,(concat "\\<" (regexp-opt '("begin" "start" "both" "end" "define" "for" "to" "next" "if" "then" "else" "include" "postscript" "bigfile" "data" "fullsize" "let" "set") t) "\\>") (0 font-lock-keyword-face)) (,(concat "\\<" (regexp-opt '("sub") t) "\\>") (0 font-lock-function-name-face)) (,(concat "\\<" (regexp-opt '("aline" "rline" "line" "amove" "rmove" "arc" "arcto" "bezier" "circle" "closepath" "curve" "grestore" "gsave" "join" "rbezier" "reverse" "save" "text" "write" "bar" "size" "title" "xaxis" "yaxis" "x2axis" "y2axis" "hscale" "vscale" "xlabels" "ylabels" "x2labels" "y2labels" "xnames" "ynames" "x2names" "y2names" "xplaces" "yplaces" "x2places" "y2places" "xside" "yside" "x2side" "y2side" "xsubticks" "ysubticks" "x2subticks" "y2subticks" "xtitle" "ytitle" "x2title" "y2title") t) "\\>") (0 font-lock-constant-face)) (,(concat "\\<" (regexp-opt '("width" "err" "herr" "errwidth" "herrwidth" "errup" "herrup" "errdown" "herrdown" "hei" "color" "dashlen" "font" "fontlwidth" "just" "add" "nobox" "name" "arrow" "stroke" "fill" "justify" "cap" "lstyle" "lwidth" "from" "dist" "key" "xmin" "ymin" "xmax" "ymax" "nomiss" "smooth" "smoothm" "dsubticks" "dpoints" "nticks" "dticks" "font" "shift" "offset" "position" "marker" "msize" "mscale") t) "\\>") (0 font-lock-variable-name-face)) (,(concat "\\<" (regexp-opt '("box" "clip" "origin" "path" "marker" "rotate" "scale" "table" "text" "translate") t) "\\>") (0 font-lock-string-face)) (,(concat "\\<" (regexp-opt '("butt" "round" "square" "mitre" "bevel" "left" "center" "right" "[tcblr]{2}" "on" "off" "grid" "log" "nofirst" "nolast") t) "\\>") (0 font-lock-builtin-face)) (,(concat "\\<" (regexp-opt '("time\\$" "date\\$") t) "\\>") (0 font-lock-string-face)) ("\\s *@\\w+" (0 font-lock-function-name-face)) ("\\b\\(left\\$\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(right\\$\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(seg\\$\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(num1?\\$\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(val\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(pos\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(len\\)\\s *(" (1 font-lock-string-face)) ("\\b\\(abs\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?cosh\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(cos\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?coth?\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?csch?\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?sech?\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?sinh\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(sin\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(atn\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(a?tanh\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(tan\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(exp\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(fix\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(int\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(log\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(log10\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(sgn\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(sqrt?\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(todeg\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(torad\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(not\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(rnd\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\([xy]end\\)\\s *(\\s *)" (1 font-lock-function-name-face)) ("\\b\\([xy]pos\\)\\s *(\\s *)" (1 font-lock-function-name-face)) ("\\b\\([xy]g\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(twidth\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(theight\\)\\s *(" (1 font-lock-function-name-face)) ("\\b\\(tdepth\\)\\s *(" (1 font-lock-function-name-face)) ) "Keyword highlighting specification for `gle-mode'.") (defun gle-create-postscript () "Create and view Postscript from current file" (interactive) (save-buffer) (shell-command (concat "gle -dps " (file-name-nondirectory (buffer-file-name)))) (shell-command (concat "gle_ps /output=emacsgle.ps " (file-name-nondirectory (buffer-file-name)))) (shell-command "ghostview emacsgle.ps; rm emacsgle.ps") ) (defun gle-create-encapsulated () "Create and view EPS from current file" (interactive) (save-buffer) (shell-command (concat "gle -deps " (file-name-nondirectory (buffer-file-name)))) (shell-command (concat "gle_ps /output=emacsgle.eps /eps " (file-name-nondirectory (buffer-file-name)))) (shell-command "gv emacsgle.eps; rm emacsgle.eps") ) (define-derived-mode gle-mode fundamental-mode "GLE" "A major mode for editing .gle files." (set (make-local-variable 'comment-start) "! ") (set (make-local-variable 'comment-start-skip) "!+\\s-*") (set (make-local-variable 'font-lock-defaults) '(gle-font-lock-keywords)) ) (provide 'gle-mode) ;; End gle-mode