]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/icon.el
Merge from emacs-24; up to 2012-12-31T11:35:13Z!rudalics@gmx.at
[gnu-emacs] / lisp / progmodes / icon.el
index f0287c90188dc1f31b62eeb55ea377cd18942d84..894a42811c7f3e440afb65869d227dbab44d47d8 100644 (file)
@@ -1,7 +1,6 @@
 ;;; icon.el --- mode for editing Icon code
 
-;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-;;   2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Chris Smith <csmith@convex.com>
 ;; Created: 15 Feb 89
   :group 'languages)
 
 (defcustom icon-indent-level 4
-  "*Indentation of Icon statements with respect to containing block."
+  "Indentation of Icon statements with respect to containing block."
   :type 'integer
   :group 'icon)
 
 (defcustom icon-brace-imaginary-offset 0
-  "*Imagined indentation of a Icon open brace that actually follows a statement."
+  "Imagined indentation of a Icon open brace that actually follows a statement."
   :type 'integer
   :group 'icon)
 
 (defcustom icon-brace-offset 0
-  "*Extra indentation for braces, compared with other text in same context."
+  "Extra indentation for braces, compared with other text in same context."
   :type 'integer
   :group 'icon)
 
 (defcustom icon-continued-statement-offset 4
-  "*Extra indent for Icon lines not starting new statements."
+  "Extra indent for Icon lines not starting new statements."
   :type 'integer
   :group 'icon)
 
 (defcustom icon-continued-brace-offset 0
-  "*Extra indent for Icon substatements that start with open-braces.
+  "Extra indent for Icon substatements that start with open-braces.
 This is in addition to `icon-continued-statement-offset'."
   :type 'integer
   :group 'icon)
 
 (defcustom icon-auto-newline nil
-  "*Non-nil means automatically newline before and after braces Icon code.
+  "Non-nil means automatically newline before and after braces Icon code.
 This applies when braces are inserted."
   :type 'boolean
   :group 'icon)
 
 (defcustom icon-tab-always-indent t
-  "*Non-nil means TAB in Icon mode should always reindent the current line.
+  "Non-nil means TAB in Icon mode should always reindent the current line.
 It will then reindent, regardless of where in the line point is
 when the TAB command is used."
   :type 'boolean
@@ -131,7 +130,7 @@ when the TAB command is used."
 
 \f
 ;;;###autoload
-(defun icon-mode ()
+(define-derived-mode icon-mode prog-mode "Icon"
   "Major mode for editing Icon code.
 Expression and list commands understand all Icon brackets.
 Tab indents for Icon code.
@@ -163,49 +162,33 @@ Variables controlling indentation style:
 
 Turning on Icon mode calls the value of the variable `icon-mode-hook'
 with no args, if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map icon-mode-map)
-  (setq major-mode 'icon-mode)
-  (setq mode-name "Icon")
-  (setq local-abbrev-table icon-mode-abbrev-table)
-  (set-syntax-table icon-mode-syntax-table)
-  (make-local-variable 'paragraph-start)
-  (setq paragraph-start (concat "$\\|" page-delimiter))
-  (make-local-variable 'paragraph-separate)
-  (setq paragraph-separate paragraph-start)
-  (make-local-variable 'indent-line-function)
-  (setq indent-line-function 'icon-indent-line)
-  (make-local-variable 'require-final-newline)
-  (setq require-final-newline mode-require-final-newline)
-  (make-local-variable 'comment-start)
-  (setq comment-start "# ")
-  (make-local-variable 'comment-end)
-  (setq comment-end "")
-  (make-local-variable 'comment-start-skip)
-  (setq comment-start-skip "# *")
-  (make-local-variable 'comment-indent-function)
-  (setq comment-indent-function 'icon-comment-indent)
+  :abbrev-table icon-mode-abbrev-table
+  (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
+  (set (make-local-variable 'paragraph-separate) paragraph-start)
+  (set (make-local-variable 'indent-line-function) #'icon-indent-line)
+  (set (make-local-variable 'comment-start) "# ")
+  (set (make-local-variable 'comment-end) "")
+  (set (make-local-variable 'comment-start-skip) "# *")
+  (set (make-local-variable 'comment-indent-function) 'icon-comment-indent)
   (set (make-local-variable 'indent-line-function) 'icon-indent-line)
   ;; font-lock support
-  (setq font-lock-defaults
-       '((icon-font-lock-keywords
-          icon-font-lock-keywords-1 icon-font-lock-keywords-2)
-         nil nil ((?_ . "w")) beginning-of-defun
-         ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP.
-         ;(font-lock-comment-start-regexp . "#")
-         (font-lock-mark-block-function . mark-defun)))
+  (set (make-local-variable 'font-lock-defaults)
+       '((icon-font-lock-keywords
+          icon-font-lock-keywords-1 icon-font-lock-keywords-2)
+         nil nil ((?_ . "w")) beginning-of-defun
+         ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP.
+         ;;(font-lock-comment-start-regexp . "#")
+         (font-lock-mark-block-function . mark-defun)))
   ;; imenu support
-  (make-local-variable 'imenu-generic-expression)
-  (setq imenu-generic-expression icon-imenu-generic-expression)
+  (set (make-local-variable 'imenu-generic-expression)
+       icon-imenu-generic-expression)
   ;; hideshow support
   ;; we start from the assertion that `hs-special-modes-alist' is autoloaded.
   (unless (assq 'icon-mode hs-special-modes-alist)
     (setq hs-special-modes-alist
          (cons '(icon-mode  "\\<procedure\\>" "\\<end\\>" nil
                             icon-forward-sexp-function)
-               hs-special-modes-alist)))
-  (run-mode-hooks 'icon-mode-hook))
+               hs-special-modes-alist))))
 \f
 ;; This is used by indent-for-comment to decide how much to
 ;; indent a comment in Icon code based on its context.
@@ -501,9 +484,9 @@ Returns nil if line starts inside a string, t if in a comment."
   (let ((indent-stack (list nil))
        (contain-stack (list (point)))
        (case-fold-search nil)
-       restart outer-loop-done inner-loop-done state ostate
-       this-indent last-sexp last-depth
-       at-else at-brace at-do
+       outer-loop-done inner-loop-done state ostate
+       this-indent last-depth
+       at-else at-brace
        (opoint (point))
        (next-depth 0))
     (save-excursion
@@ -523,9 +506,6 @@ Returns nil if line starts inside a string, t if in a comment."
          (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
                                          nil nil state))
          (setq next-depth (car state))
-         (if (and (car (cdr (cdr state)))
-                  (>= (car (cdr (cdr state))) 0))
-             (setq last-sexp (car (cdr (cdr state)))))
          (if (or (nth 4 ostate))
              (icon-indent-line))
          (if (or (nth 3 state))
@@ -535,8 +515,6 @@ Returns nil if line starts inside a string, t if in a comment."
            (setq outer-loop-done t))
        (if outer-loop-done
            nil
-         (if (/= last-depth next-depth)
-             (setq last-sexp nil))
          (while (> last-depth next-depth)
            (setq indent-stack (cdr indent-stack)
                  contain-stack (cdr contain-stack)