[Thread Prev][Thread Next][Index]

Emacs ferret.el v 0.02.0



Thanks to some early comments on v 0.01.0, I have made a quick update to
ferret.el to make the following changes:

1) Font-lock is now case-insensitive
2) All commands, subcommands, and aliases are supported including most
   abbreviations (if I missed obvious ones, let me know)
3) Qualifiers are supported
4) Operators, functions, and transformations are supported
5) Strings (anything between "") are supported

Again, suggestions are gratefully accepted (encouraged). I would also like
suggestions for functionality beyond just font-lock (like fortran auto-indent).
For example, does anybody think any of the following would be useful?

a) auto-capitalization of commands, etc...
b) auto-indent of it-then-elif-endif constructs
c) abbreviations (e.g., ;s for shade)

The next-update will probably be a little ways off, the improvements I have in
mind now are more difficult to implement since the last time I wrote any LISP
code was more than 15 years ago.

See last message and comments inside code belowe for implementation notes.

And last, a comment: if you aren't sure what this is for you are probably using
vi, and thus are beyond help :^)

Mark Verschell

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
ferret.el
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;;; ferret.el --- Ferret mode for GNU Emacs

;; Copyright (c) 1999 by Mark A. Verschell <verschell@neptune.gsfc.nasa.gov>

;; Author: Mark A. Verschell <verschell@neptune.gsfc.nasa.gov>
;; Maintainer: Mark A. Verschell <verschell@neptune.gsfc.nasa.gov>
;; Version 0.02.0 (December 23, 1999)
;; Keywords: languages

;; Ferret.el is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License, version 2, published by the
;; Free Software Foundation.

;; 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
;; or refer to the WWW document "http://www.gnu.org/copyleft/gpl.html";.

;; Ferret.el 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.

;; Information about "Ferret", a graphical analysis tool for gridded data, can
;; be found at "http://ferret.wrc.noaa.gov/Ferret/";

;; Documentation
;; -------------
;; IMPORTANT NOTE: This only works with X-windows emacs, and only for
;; semi-recent versions of emacs (18.xx and above)
;;
;; This is Ferret mode for GNU emacs, a major mode designed to facilitate the
;; writing of journal files for "Ferret", a graphical analysis tool for
;; gridded data.
;;
;; Ferret mode for emacs is limited at this time to font-lock coverage
;; This means that the following is supported:
;;   Commands, subcommands, and aliases with most abbreviations
;;   Command and subcommand qualifiers with most abbreviations
;;   Comments starting with ! anywhere on line are supported
;;   Subroutines (go calls) are supported
;;   Shell command called by spawn is supported
;;   Strings are supported between ""
;;   Functions, operators, and transformations are supported
;;   Font-lock mode is case-insensitive
;;
;; I will take (friendly-worded) suggestions for improvements. Obviously, if I
;; get no comments, then I will only update this as I find it useful.

;; Usage
;; -----
;; - You need a local directory to store the ferret.el file, I call mine Emacs,
;;   so in the following block replace the /d9/verschell/Emacs with your local
;;   directory
;; - Place the ferret.el file in this directory
;; - Compile the ferret.el file
;;     Enter emacs while in the ferret.el directory
;;     ESC x byte-compile-file RETURN ferret.el RETURN
;; - This gives you ferret.elc
;; - Make the following modifications to your .emacs file
;;
;; <<<CUT HERE AND REMOVE BEGINNING ;; ON EACH LINE>>>
;; ;;; Add local function directory to emacs search path
;; (setq load-path (cons "/d9/verschell/Emacs" load-path))
;;
;; ;;; Add automatic ferret-mode for .jnl suffix
;; (setq auto-mode-alist (cons '("\.jnl$" . ferret-mode) auto-mode-alist))
;;
;; ;;; Load Ferret major-mode (modified text mode)
;; (load "ferret")
;;
;; ;;; Font lock mode
;; (cond ((fboundp 'global-font-lock-mode)
;;             ;; Turn on font-lock in all modes that support it
;;             (global-font-lock-mode t)
;;             ;; Maximum colors
;;             (setq font-lock-maximum-decoration t)))
;; <<<CUT HERE>>>
;;
;; - exit emacs
;; - the next time you edit a ferret file, you should get lots of pretty colors

;; Bugs to verschell@neptune.gsfc.nasa.gov

;;; Code:

(defconst ferret-mode-version "version 0.02.0")

(defgroup ferret nil
  "Ferret mode for Emacs"
  :group 'languages)

;; font-lock-comment-face        - COMMENTS
;; font-lock-function-name-face  - FUNCTION NAMES, SHELL COMMANDS
;; font-lock-keyword-face        - COMMANDS, SUBCOMMANDS, OPERATORS, FUNCTIONS,
;;                                 TRANSFORMATIONS
;; font-lock-reference-face
;; font-lock-string-face         - STRINGS
;; font-lock-type-face           - QUALIFIERS
;; font-lock-variable-name-face

(let ((comment-chars "!")
      (ferret-keywords
;      ("alias" "animate" "axis" "cancel" "commands" "contour" "data_set"
;       "dataset" "define" "elif" "else" "endif" "exit" "expression" "file"
;       "fill" "frame" "function" "grid" "help" "if" "label" "let" "list"
;       "load" "memory" "message" "mode" "movie" "palette" "plot" "pplus"
;       "queries" "query" "quit" "region" "repeat" "save" "say" "set" "shade"
;       "show" "statistics" "symbol" "then" "transform" "unalias" "use" "user"
;       "variable" "vector" "viewport" "window" "wire"))
       (concat "a\\(lias?\\|nima?t?e?\\|xis\\)\\|"
	       "c\\(an?ce?l?\\|o\\(mma?n?d?s?\\|nto?u?r?\\)\\)\\|"
	       "d\\(ata[_]*?s?e?t?\\|efi?n?e?\\)\\|"
	       "e\\(l\\(if\\|se\\)\\|ndif?\\|x\\(it\\|pre?s?s?i?o?n?\\)\\)\\|"
	       "f\\(i\\(le\\|ll\\)\\|rame?\\|unct?i?o?n?\\)\\|"
	       "grid\\|help\\|if\\|"
	       "l\\(abe?l?\\|et\\|ist\\|oad\\)\\|"
	       "m\\(e\\(mo?r?y?\\|ssa?g?e?\\)\\|o\\(de\\|vi?e?\\)\\)\\|"
	       "p\\(ale?t?t?e?\\|lot\\|plu?s?\\)\\|"
	       "qu\\(e\\(ri?e?s?\\|ry?\\)\\|it\\)\\|"
	       "re\\(gio?n?\\|pe?a?t?\\)\\|"
	       "s\\(a\\(ve\\|y\\)\\|et\\|h\\(ade?\\|ow\\)\\|tati?s?t?i?c?s?"
	       "\\|ymbo?l?\\)\\|"
	       "t\\(hen\\|rans?f?o?r?m?\\)\\|"
	       "u\\(nali?a?s?\\|ser?\\)\\|"
	       "v\\(ari?a?b?l?e?|ect?o?r?\\|iewp?o?r?t?\\)\\|"
	       "wi\\(ndo?w?\\|re\\)"))
      (ferret-qualifiers
;       "all" "append" "aspect" "bad" "brief" "clear" "clip" "clobber"
;       "columns" "command" "compress" "continue" "d" "data_set" "dataset"
;       "default" "depth" "di" "diag" "dj" "dk" "dl" "dt" "dx" "dy" "dynamic"
;       "dz" "external" "ez" "file" "fill" "format" "frame" "free" "from_data"
;       "fromdata" "full" "grid" "heading" "help" "i" "ignore" "ilimits" "j"
;       "jlimits" "k" "key" "klimits" "l" "laser" "last" "length" "levels"
;       "like" "line" "llimits" "location" "modulo" "name" "new" "noaxes"
;       "noerror" "nohead" "nokey" "nolabel" "npoints" "opt1" "opt2" "order"
;       "origin" "overlay" "palette" "pen" "permanent" "precision" "quiet"
;       "reset" "restore" "rigid" "save" "set_up" "single" "size" "skip"
;       "start" "symbol" "t" "t0" "temporary" "text" "title" "tlimits"
;       "tranpose" "units" "user" "variable" "viewpoint" "vs" "x" "xlimits"
;       "xskip" "y" "ylimits" "yskip" "z" "zlimits" "zscale"
       (concat "a\\(ll\\|ppe?n?d?\\|spe?c?t?\\)\\|"
	       "b\\(ad\\|rief?\\)\\|"
	       "c\\(l\\(ear?\\|ip\\|obb?e?r?\\)\\|o\\(lu?m?n?s?\\|m\\(ma?n?d?"
	       "\\|mpr?e?s?s?\\)\\|nti?n?u?e?\\)\\)\\|"
	       "d\\(\\|ata[_]*s?e?t?\\|e\\(fa?u?l?t?\\|pt?h?\\)\\|i\\(\\|ag\\)"
	       "\\|j\\|k\\|l\\|t\\|x\\|y\\(\\|na?m?i?c?\\)\\|z\\)\\|"
	       "e\\(xte?r?n?a?l?\\|z\\)\\|"
	       "f\\(il[el]\\|orm?a?t?\\|r\\(ame?\\|ee\\|om[_]*d?a?t?a?\\)"
	       "\\|ull\\)\\|"
	       "grid\\|"
	       "he\\(adi?n?g?\\|lp\\)\\|"
	       "i\\(\\|gno?r?e?\\|li?m?i?t?s?\\)\\|"
	       "j\\(\\|li?m?i?t?s?\\)\\|"
	       "k\\(\\|ey\\|li?m?i?t?s?\\)\\|"
	       "l\\(\\|as\\(er?\\|t\\)\\|e\\(ngt?h?\\|ve?l?s?\\)\\|i\\(ke\\|ne"
	       "\\)\\|li?m?i?t?s?\\|oca?t?i?o?n?\\)\\|"
	       "modu?l?o?\\|"
	       "n\\(ame\\|ew\\|o\\(axe?s?\\|err?o?r?\\|hea?d?\\|key?"
	       "\\|lab?e?l?\\)\\|poin?t?s?\\)\\|"
	       "o\\(p\\(t1\\|t2\\)\\|r\\(der?\\|igi?n?\\)\\|verl?a?y?\\)\\|"
	       "p\\(ale?t?t?e?\\|e\\(n\\|rma?n?e?n?t?\\)\\|reci?s?i?o?n?\\)\\|"
	       "quiet?\\|"
	       "r\\(e\\(s\\(et?\\|to?r?e?\\)\\)\\|igi?d?\\)\\|"
	       "s\\(ave?\\|et_?u?p?\\|i\\(ngl?e?\\|ze\\)\\|kip\\|tart?"
	       "\\|ymb?o?l?\\)\\|"
	       "t\\(\\|0\\|e\\(mpo?r?a?r?y?\\|xt\\)\\|itl?e?\\|li?m?i?t?s?"
	       "\\|ranp?o?s?e?\\)\\|"
	       "u\\(nits?\\|ser?\\)\\|"
	       "v\\(ari?a?b?l?e?\\|iewp?o?i?n?t?\\|s\\)\\|"
	       "x\\(\\|li?m?i?t?s?\\|ski?p?\\)\\|"
	       "y\\(\\|li?m?i?t?s?\\|ski?p?\\)\\|"
	       "z\\(\\|li?m?i?t?s?\\|sca?l?e?\\)"))
      (ferret-operators
;       "and" "eq" "ge" "gt" "le" "lt" "ne" "or"
       (concat "and\\|eq\\|g[et]\\|l[et]\\|ne\\|or"))
      (ferret-functions
;       "abs" "acos" "asin" "atan" "atan2" "cos" "days1900" "exp" "ignore0"
;       "int" "ln" "log" "max" "min" "missing" "mod" "randn" "randu" "reshape"
;       "rho_un" "sin" "tan" "theta_fo" "times2" "unravel" "zaxreplace"
       (concat "a\\(bs\\|cos\\|sin\\|tan2?\\)\\|cos\\|days1900\\|exp\\|"
	       "i\\(gnore0\\|nt\\)\\|l\\(n\\|og\\)\\|m\\(ax\\|i\\(n\\|ssing\\)"
	       "\\|od\\)\\|r\\(and[nu]\\|eshape\\|ho_un\\)\\|sin\\|t\\(an\\|"
	       "heta_fo\\|imes2\\)\\|unravel\\|zaxreplace"))
      (ferret-transformations
;       "asn" "ave" "ave" "cda" "cdb" "cia" "cib" "ddb" "ddc" "ddf" "din"
;       "fav" "fln" "fnr" "iin" "itp" "lin" "loc" "max" "max" "min" "min"
;       "mod" "modmax" "modmin" "modngd" "modsum" "modvar" "nbd" "ngd" "ngd"
;       "rsum" "sbn" "sbx" "shf" "shn" "spz" "sum" "sum" "swl" "var" "var"
;       "weq" "xact"
       (concat "a\\(sn\\|ve\\)\\|c\\(d[ab]\\|i[ab]\\)\\|d\\(d[bcf]\\|in\\)\\|"
	       "f\\(av\\|l[nr]\\)i\\(in\\|tp\\)\\|l\\(in\\|oc\\)\\|m\\(ax\\|in"
	       "\\|od\\(\\|m\\(ax\\|in\\)\\|ngd\\|sum\\|var\\)\\)\\|n[bg]d"
	       "\\|rsum\\|s\\(b[nx]\\|h[fn]\\|pz\\|um\\|wl\\)\\|var\\|weq"
	       "\\|xact"))
      )

  (setq ferret-font-lock-keywords
   (list
    '("\"[^'\n]*'?" . font-lock-comment-face)
    (list (concat "\\<\\(go\\|spaw\\|spawn\\)\\>[ \t]*\\(\\sw+\\)?")
       '(1 font-lock-keyword-face)
       '(2 font-lock-function-name-face nil t))
   (cons (concat "\\/\\(" ferret-qualifiers "\\)\\>") 'font-lock-type-face)
   (concat "\\<\\(" ferret-keywords "\\)\\>")
   (concat "\\<\\(" ferret-operators "\\)\\>")
   (concat "\\<\\(" ferret-functions "\\)\\>")
   (concat "\\@\\(" ferret-transformations "\\)\\>")
   ))
  "Default expressions to highlight in Ferret mode.")

-------------------------------------------------------------------------------
;;;###autoload
(require 'derived)

(define-derived-mode ferret-mode text-mode "Ferret"
  "Major mode for editing ferret .jnl files.
Special commands:
\\{ferret-mode-map}"
  (set (make-local-variable 'comment-start) "! ")
  (set-syntax-table (copy-syntax-table))
  (modify-syntax-entry ?! "<")
  (modify-syntax-entry ?\n ">")
  (set (make-local-variable 'font-lock-defaults)
       '(ferret-font-lock-keywords nil t)))

(provide 'ferret)

;;; ferret.el ends here


-- 
 Mark Verschell                     NASA/Goddard Space Flight Center
 verschell@neptune.gsfc.nasa.gov    Code 970/Lab. for Hydrospheric Proc.
 301-614-5669  Fax: 301-614-5666    Greenbelt, MD 20771


		     Better Living Through Denial
               ** USQC Certified: 100% Microsoft Free **


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement