[Thread Prev][Thread Next][Index]

Re: Emacs ferret-mode?

Back in May, David asked if there was a ferret mode for emacs. I thought that
this was a great idea and finally had a little time to work one out.

This is VERY basic at this point, limited entirely to implementing font-lock
mode for ferret and only for fully-typed out commands - no aliases or
abbreviations. There is also support for command modifiers, but not command
qualifiers (e.g., VIEWPORT but not /LABELS), comments, and the command argument
for the GO and SPAWN commands. This is probably more useful at this point if
you are trying to make a journal file that will be saved and executed often and
you want it reasonably documented.

How to implement this is detailed in the following lisp code. If you haven't
tried font-lock mode before, WHY NOT? Seriously, the usage explanation will
direct you to modify your .emacs file such that you will turn on font-lock mode
globally (e.g., for ForTran and C and LaTeX, etc... as well as for ferret) so
give it a try.

This only works for newer emacs used in X-windows mode.

Mark Verschell


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

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

;; Documentation
;; -------------
;; IMPORTANT NOTE: This only works with X-windows emacs, and only for
;; semi-recent versions of emacs (18.xx and above??)
;; Ferret mode for emacs is limited at this time to basic font-lock coverage
;; This means that only the following is supported:
;;   Fully spelled out commands (NO aliases). E.g., "cancel" not "can"
;;   Fully spelled out modifiers. E.g., "viewport" not "view"
;;   Comments starting with ! anywhere on line are supported
;;   Subroutines (go calls) are supported
;;   Shell command called by spawn are supported
;; That's it for now.
;; I will take (friendly-worded) suggestions for improvements. Obviously, if I
;; get no comments, then I will only update this only 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.01.0")

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

(require 'derived)

(define-derived-mode ferret-mode text-mode "Ferret"
  "Major mode for editing ferret .jnl files.
Special commands:
  (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 nil ((?_ . "w")))))

(defvar ferret-font-lock-keywords
     ;; Function name declarations.
     '("\\<\\(go\\|spawn\\)\\>[ \t]*\\(\\sw+\\)?"
       (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
     ;; Keywords.
;(make regexp '("cancel" "contour" "define" "elif" "else" "endif" "exit"
;              "frame" "if" "label" "list" "load" "message" "palette" "plot"
;              "pplus" "repeat" "save" "set" "shade" "show" "statistics"
;              "user" "vector" "wire"))
     (concat "\\<\\("
     ;; Types.
;   (make-regexp '("alias" "axis" "commands" "data_set" "expression" "grid"
;                 "list" "memory" "mode" "movie" "region" "transform"
;                 "variable" "variables" "viewport" "window" "windows"))
     (cons (concat "\\<\\("

  "Default expressions to highlight in Ferret mode.")

(provide 'ferret)


 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