;;; javagi-mode.el --- JavaGI mode ;; Author: 2008 Stefan Wehr ;; Maintainer: Stefan Wehr ;; Created: November 2008 ;; Modified: December 2009 ;; Version: 0.1.0 ;; Keywords: javagi java languages oop ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program 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. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; Installation instructions ;; ;; - Make sure that the file is in (X)Emacs's load path. ;; - Add the following lines to your .emacs file: ;; (autoload 'javagi-mode "javagi-mode" "Major mode for editing JavaGI code." t) ;; (setq auto-mode-alist (cons '("\\.javagi$" . javagi-mode) auto-mode-alist)) ;; ;; Note: javagi-mode requires CC Mode 5.30 or later. ;;; Code: (require 'cc-mode) (require 'cc-mode) (require 'cc-fonts) (require 'cc-langs) (require 'cc-bytecomp) (require 'compile) ;; The language constants are needed when compiling. (eval-when-compile (let ((load-path (if (and (boundp 'byte-compile-dest-file) (stringp byte-compile-dest-file)) (cons (file-name-directory byte-compile-dest-file) load-path) load-path))) (load "cc-mode" nil t) (load "cc-fonts" nil t) (load "cc-langs" nil t) (load "cc-bytecomp" nil t))) (eval-and-compile ;; Make our mode known to the language constant system. Use Java ;; mode as the fallback for the constants we don't change here. ;; This needs to be done also at compile time since the language ;; constants are evaluated then. (c-add-language 'javagi-mode 'java-mode)) ;; Structures that are similiar to classes. (c-lang-defconst c-class-decl-kwds javagi '("class" "interface" "implementation" "receiver")) ;; The various modifiers. (c-lang-defconst c-modifier-kwds javagi '("abstract" "const" "final" "native" "private" "protected" "public" "static" "strictfp" "synchronized" "transient" "volatile" "where")) (defconst javagi-font-lock-keywords-1 (c-lang-const c-matchers-1 javagi) "Minimal highlighting for Javagi mode.") (defconst javagi-font-lock-keywords-2 (c-lang-const c-matchers-2 javagi) "Fast normal highlighting for Javagi mode.") (defconst javagi-font-lock-keywords-3 (c-lang-const c-matchers-3 javagi) "Accurate normal highlighting for Javagi mode.") (defvar javagi-font-lock-keywords javagi-font-lock-keywords-3 "Default expressions to highlight in Javagi mode.") (defvar javagi-mode-syntax-table nil "Syntax table used in javagi-mode buffers.") (or javagi-mode-syntax-table (setq javagi-mode-syntax-table (funcall (c-lang-const c-make-mode-syntax-table javagi)))) (defvar javagi-mode-abbrev-table nil "Abbreviation table used in javagi-mode buffers.") (c-define-abbrev-table 'javagi-mode-abbrev-table ;; Keywords that if they occur first on a line might alter the ;; syntactic context, and which therefore should trig reindentation ;; when they are completed. '(("else" "else" c-electric-continued-statement 0) ("while" "while" c-electric-continued-statement 0) ("catch" "catch" c-electric-continued-statement 0) ("finally" "finally" c-electric-continued-statement 0))) (defvar javagi-mode-map (let ((map (c-make-inherited-keymap))) ;; Add bindings which are only useful for Javagi map) "Keymap used in javagi-mode buffers.") ;;; The entry point into the mode (defun javagi-mode () "Major mode for editing Javagi code. This is a simple example of a separate mode derived from CC Mode to support a language with syntax similar to C/C++/ObjC/Java/IDL/Pike. The hook `c-mode-common-hook' is run with no args at mode initialization, then `javagi-mode-hook'. Key bindings: \\{javagi-mode-map}" (interactive) (kill-all-local-variables) (c-initialize-cc-mode t) (set-syntax-table javagi-mode-syntax-table) (setq major-mode 'javagi-mode mode-name "Javagi" local-abbrev-table javagi-mode-abbrev-table abbrev-mode t) (use-local-map c-mode-map) ;; `c-init-language-vars' is a macro that is expanded at compile ;; time to a large `setq' with all the language variables and their ;; customized values for our language. (c-init-language-vars javagi-mode) ;; `c-common-init' initializes most of the components of a CC Mode ;; buffer, including setup of the mode menu, font-lock, etc. ;; There's also a lower level routine `c-basic-common-init' that ;; only makes the necessary initialization to get the syntactic ;; analysis and similar things working. (c-common-init 'javagi-mode) (run-hooks 'c-mode-common-hook) (run-hooks 'javagi-mode-hook) (c-update-modeline)) (provide 'javagi-mode)