;;; dprog.el --- Major mode for editing dprog source. ;;; Copyright (C) 2002 Thomas Mailund ;;; This file is not part of GNU Emacs, but it is distributed under the ;;; same conditions. ;;; ==================================================================== ;;; 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, 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 software; see the file COPYING. If not, write to the ;;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; ==================================================================== ;;; Installation: ;;; ;;; To install dprog-mode, put the source files in your ;;; Emacs-Lisp load path (or extend the load path to include the ;;; directory containing the files). Then add (require 'dprog) ;;; to your .emacs. ;;; To automatically enter dprog-mode when opening .dprog files, add ;;; ;;; (setq auto-mode-alist ;;; (cons '("\\.dprog$" . dprog-mode) auto-mode-alist)) ;;; ;;; to .emacs ;;; ==================================================================== (require 'dprog-constants) (require 'dprog-font-lock) (require 'dprog-indent) (provide 'dprog) ;;; === variables for the mode ======================================= ;;; --- customization stuff ------------------------------------------ ;;; some customization stuff is scattered througout the files to be ;;; close to the functionality that is customised, this file just ;;; holds the general stuff. (defgroup dprog nil "An environment for editing Dprog code." :tag "Dprog" :group 'languages ;Programming->Languages->Dprog :version "21.2") ;;; --- std. mode stuff ---------------------------------------------- (defvar dprog-mode-syntax-table (let ((table (copy-syntax-table lisp-mode-syntax-table))) (modify-syntax-entry ?{ "(}" table) (modify-syntax-entry ?} "){" table) table) "Syntax table for `dprog-mode'.") (defvar dprog-mode-abbrev-table nil "Abbrev table used while in `dprog-mode'.") (define-abbrev-table 'dprog-mode-abbrev-table ()) (defvar dprog-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-v" 'dprog-version) (define-key map "\C-c\C-b" 'dprog-submit-bug-report) map) "Keymap for `dprog-mode'.") (defvar dprog-mode-hook nil "*Hook called by `dprog-mode'.") ;;; === mode functions =============================================== ;;; --- handling blocks ---------------------------------------------- (defun dprog-move-to-start-of-block nil "Move point to the start of the current block, recursively skipping over sub-blocks." (progn (while (and (backward-to-indentation 1) (not (or (looking-at dprog-open-block) (looking-at dprog-close-block))) (> (point) 1))) ;; if we are now at the beginning of the block we are done, but if ;; we are at the closing of a block we need to skip past a ;; sub-block and searc again. (if (looking-at dprog-close-block) (progn ;; skip past sub-block (dprog-move-to-start-of-block) ;; and search (again) for the start of this block (dprog-move-to-start-of-block))))) ;;; --- bug reporting ------------------------------------------------ (defconst dprog-mode-help-address "dprog-bug@mailund.dk" "Addresses for `dprog-mode' bug reports.") (defun dprog-submit-bug-report () "Submit via mail a bug report on `dprog-mode'." (interactive) (let ((reporter-prompt-for-summary-p t)) (reporter-submit-bug-report dprog-mode-help-address (concat "dprog-mode " dprog-mode-version) (list ;; the interesting vars 'dprog-mode-hook 'dprog-mode-map ) nil nil "Hello, old friend!"))) ;;; === setup the mode =============================================== (defun dprog-mode nil "Major mode for editing Dprog code. To submit a problem report, enter `\\[dprog-submit-bug-report]' from a dprog-mode buffer. This automatically sets up a mail buffer with version information already added. You just need to add a description of the problem, including a reproducible test case, and send the message. To see what version of Dprog mode you are running, enter `\\[dprog-version]'. \\{dprog-mode-map} Turning on Dprog mode runs the hook `dprog-mode-hook'." (interactive) ;; setup local variables and tables (kill-all-local-variables) (use-local-map dprog-mode-map) (setq local-abbrev-table dprog-mode-abbrev-table) (set-syntax-table dprog-mode-syntax-table) ;; some mode setup (make-local-variable 'comment-start) (make-local-variable 'comment-end) (make-local-variable 'comment-continue) (make-local-variable 'comment-style) (make-local-variable 'comment-column) (make-local-variable 'indent-line-function) (make-local-variable 'tab-width) (setq mode-name "Dprog" major-mode 'dprog-mode comment-start ";; " comment-end "" comment-continue nil comment-column 45 comment-style 'extra-line indent-line-function 'dprog-indent-line tab-width 8 font-lock-defaults '((dprog-font-lock-keywords dprog-font-lock-keywords-0 dprog-font-lock-keywords-1 dprog-font-lock-keywords-2) nil t) ) ; setq ;; and run hooks for customisation (run-hooks 'dprog-mode-hook))