;;; EDIF-mode - Major mode for viewing EDIF source in emacs. ;;; Brian Pratt - 2006 ;;; INSTALLATION ;;; ============ ;;; Put the edif-mode.el file in your load-path and optionally byte ;;; compile it. If you don't know the load path of your emacs, try: ;;; C-h v load-path ;;; If you don't have write access anywhere in this path, you can ;;; place this file in ~/lisp and add this line to your .emacs file: ;;; ;;; (setq load-path (cons "~/lisp" load-path)) (defvar edif-mode-hook nil) (defvar edif-mode-map () "Keymap for EDIF major mode") (if (null edif-mode-map) (setq edif-mode-map (make-sparse-keymap))) ;; Sample key binding ;; Would any special key bindings be useful? ;(define-key edif-mode-map "\C-j" 'newline-and-indent) ;; Automatically recognize EDIF files (add-to-list 'auto-mode-alist '("\\.edf\\'" . edif-mode)) (add-to-list 'auto-mode-alist '("\\.edn\\'" . edif-mode)) ;; Keywords for syntax highlighting ;; L1: "edif" "edifVersion" "edifLevel" "keywordMap" "keywordLevel" "status" "written" "timeStamp" "author" "program" "technology" "external" "library" "cell" "port" "view" "contents" "instance" "portRef" "net" "design" ;; L2: "rename" "interface" "cellType" "viewType" "direction" "property" "string" "viewRef" "cellRef" "libraryRef" "array" "joined" "member" "owner" "instanceRef" "comment" (defconst edif-font-lock-keywords-1 (list '("\\<\\(edif\\|edifVersion\\|edifLevel\\|keywordMap\\|keywordLevel\\|status\\|written\\|timeStamp\\|author\\|program\\|technology\\|external\\|library\\|cell\\|port\\|view\\|contents\\|instance\\|portRef\\|net\\|design\\)\\>" . font-lock-keyword-face) '("\\('\\w*'\\)" . font-lock-variable-name-face)) "Minimal highlighting expressions for EDIF mode") (defconst edif-font-lock-keywords-2 (append edif-font-lock-keywords-1 (list '("\\<\\(rename\\|interface\\|cellType\\|viewType\\|direction\\|property\\|string\\|viewRef\\|cellRef\\|libraryRef\\|array\\|joined\\|member\\|owner\\|instanceRef\\|comment\\)\\>" . font-lock-constant-face) '("\\('\\w*'\\)" . font-lock-variable-name-face))) "Even more highlighting in EDIF mode") (defvar edif-font-lock-keywords edif-font-lock-keywords-2 "Default highlighting expressions for EDIF mode") ;; Sytax Table (defvar e-m-s-t nil "Syntax table in use in EDIF-mode buffers.") (setq e-m-s-t nil) (setq e-m-s-t (make-syntax-table)) (modify-syntax-entry ?_ "w" e-m-s-t) (modify-syntax-entry ?\' "." e-m-s-t) ;; Entry function (defun edif-mode () (interactive) (kill-all-local-variables) (use-local-map edif-mode-map) (set-syntax-table e-m-s-t) ;; Set up font-lock (set (make-local-variable 'font-lock-defaults) '(edif-font-lock-keywords)) ;; Register our indentation function ;(set (make-local-variable 'indent-line-function) 'edif-indent-line) (setq major-mode 'edif-mode) (setq mode-name "EDIF") (run-hooks 'edif-mode-hook)) (provide 'edif-mode) ;; (defvar edif-keywords ;; '("edif" "edifversion" "ediflevel" "keywordmap" "keywordlevel" ;; "status" "written" "timestamp" "author" "program" "rename" "library" ;; "technology" "cell" "port" "view" "contents" "instance" "portref" ;; "net" "design" "interface" "celltype" "viewtype" "direction" ;; "property" "string" "viewref" "cellref" "libraryRef" "array" "joined" ;; "member" "owner" ;; ))