]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/icon.el
Close bug#3992.
[gnu-emacs] / lisp / progmodes / icon.el
index fa0b9266bc0a1a7008aedb5671451caaef32a75d..9182b319b5768272c2d3a4156642ae32dc3042de 100644 (file)
@@ -1,6 +1,7 @@
 ;;; icon.el --- mode for editing Icon code
 
-;; Copyright (C) 1989 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Free Software Foundation, Inc.
 
 ;; Author: Chris Smith <csmith@convex.com>
 ;; Created: 15 Feb 89
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs 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.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -46,9 +45,8 @@
     (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun)
     (define-key icon-mode-map "\e\C-q" 'indent-icon-exp)
     (define-key icon-mode-map "\177" 'backward-delete-char-untabify)
-    (define-key icon-mode-map "\t" 'icon-indent-command)
-  
-    (define-key icon-mode-map [menu-bar] (make-sparse-keymap))
+
+    (define-key icon-mode-map [menu-bar] (make-sparse-keymap "Icon"))
     (define-key icon-mode-map [menu-bar icon]
       (cons "Icon" map))
     (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun))
@@ -84,6 +82,7 @@
 
 (defgroup icon nil
   "Mode for editing Icon code."
+  :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
   :group 'languages)
 
 (defcustom icon-indent-level 4
@@ -122,11 +121,11 @@ This applies when braces are inserted."
   "*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 'integer
+  :type 'boolean
   :group 'icon)
 
 (defvar icon-imenu-generic-expression
-      '((nil "^[ \t]*procedure[ \t]*\\(\\sw+\\)[ \t]*("  1))
+      '((nil "^[ \t]*procedure[ \t]+\\(\\sw+\\)[ \t]*("  1))
   "Imenu expression for Icon mode.  See `imenu-generic-expression'.")
 
 
@@ -178,46 +177,40 @@ with no args, if that value is non-nil."
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'icon-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (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-column)
-  (setq comment-column 32)
   (make-local-variable 'comment-start-skip)
   (setq comment-start-skip "# *")
   (make-local-variable 'comment-indent-function)
   (setq comment-indent-function 'icon-comment-indent)
+  (set (make-local-variable 'indent-line-function) 'icon-indent-line)
   ;; font-lock support
-  (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults  
+  (setq font-lock-defaults
        '((icon-font-lock-keywords
-          icon-font-lock-keywords-1 
-          icon-font-lock-keywords-2
-          )
+          icon-font-lock-keywords-1 icon-font-lock-keywords-2)
          nil nil ((?_ . "w")) beginning-of-defun
-         (font-lock-comment-start-regexp . "#")
+         ;; 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)
   ;; hideshow support
   ;; we start from the assertion that `hs-special-modes-alist' is autoloaded.
-  (pushnew '(icon-mode  "\\<procedure\\>" "\\<end\\>" nil 
-                       icon-forward-sexp-function)
-          hs-special-modes-alist :test 'equal)
-  (run-hooks 'icon-mode-hook))
+  (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))
 \f
 ;; This is used by indent-for-comment to decide how much to
 ;; indent a comment in Icon code based on its context.
 (defun icon-comment-indent ()
-  (if (looking-at "^#")
-      0        
-    (save-excursion
-      (skip-chars-backward " \t")
-      (max (if (bolp) 0 (1+ (current-column)))
-          comment-column))))
+  (if (looking-at "^#") 0 comment-column))
 
 (defun electric-icon-brace (arg)
   "Insert character and correct line's indentation."
@@ -232,7 +225,7 @@ with no args, if that value is non-nil."
                     (progn (icon-indent-line) (newline) t)
                   nil)))
        (progn
-         (insert last-command-char)
+         (insert last-command-event)
          (icon-indent-line)
          (if icon-auto-newline
              (progn
@@ -250,7 +243,6 @@ with no args, if that value is non-nil."
       (self-insert-command (prefix-numeric-value arg)))))
 \f
 (defun icon-indent-command (&optional whole-exp)
-  (interactive "P")
   "Indent current line as Icon code, or in some cases insert a tab character.
 If `icon-tab-always-indent' is non-nil (the default), always indent current
 line.  Otherwise, indent the current line only if point is at the left margin
@@ -260,6 +252,7 @@ A numeric argument, regardless of its value, means indent rigidly all the
 lines of the expression starting after point so that this line becomes
 properly indented.  The relative indentation among the lines of the
 expression are preserved."
+  (interactive "P")
   (if whole-exp
       ;; If arg, always indent this line as Icon
       ;; and shift remaining lines of expression the same amount.
@@ -294,9 +287,7 @@ Return the amount the indentation changed by."
     (setq beg (point))
     (cond ((eq indent nil)
           (setq indent (current-indentation)))
-         ((eq indent t)
-          (setq indent (calculate-icon-indent-within-comment)))
-         ((looking-at "[ \t]*#")
+         ((looking-at "^#")
           (setq indent 0))
          (t
           (skip-chars-forward " \t")
@@ -433,7 +424,7 @@ Returns nil if line starts inside a string, t if in a comment."
                (progn (forward-word -1) (point))
                (progn (forward-word 1) (point)))
               icon-resword-alist)
-      (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\n))))))
+      (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n))))))
 
 (defun icon-backward-to-noncomment (lim)
   (let (opoint stop)
@@ -617,52 +608,47 @@ Returns nil if line starts inside a string, t if in a comment."
   (eval-when-compile
     (list
      ;; Fontify procedure name definitions.
-     '("^[ \t]*\\(procedure\\)[ \t]*\\(\\sw+\\)[ \t]*("
+       '("^[ \t]*\\(procedure\\)\\>[ \t]*\\(\\sw+\\)?"
        (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t))))
-  "Subdued level highlighting for `icon-mode'.")
+  "Subdued level highlighting for Icon mode.")
 
 (defconst icon-font-lock-keywords-2
-  (append 
+  (append
    icon-font-lock-keywords-1
    (eval-when-compile
      (list
       ;; Fontify all type specifiers.
-      (cons 
-       (concat 
-       "\\<" (regexp-opt  '("null" "string" "co-expression" "table" "integer" 
-                            "cset"  "set" "real" "file" "list") t) 
-       "\\>") 
+      (cons
+       (regexp-opt  '("null" "string" "co-expression" "table" "integer"
+                     "cset"  "set" "real" "file" "list") 'words)
        'font-lock-type-face)
       ;; Fontify all keywords.
       ;;
-      (cons 
-       (concat 
-       "\\<" 
-       (regexp-opt 
-        '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" 
-          "until" "case" "of" "while" "create" "every" "suspend" "default" 
-          "fail" "record" "then") t)
-       "\\>")
+      (cons
+       (regexp-opt
+       '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return"
+         "until" "case" "of" "while" "create" "every" "suspend" "default"
+         "fail" "record" "then") 'words)
        'font-lock-keyword-face)
-      ;; "end" "initial" 
-      (cons (concat "\\<" (regexp-opt '("end" "initial") t) "\\>")
+      ;; "end" "initial"
+      (cons (regexp-opt '("end" "initial") 'words)
            'font-lock-builtin-face)
       ;; Fontify all system variables.
-      (cons 
-       (regexp-opt 
-       '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column" 
+      (cons
+       (regexp-opt
+       '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column"
          "&control" "&cset" "&current" "&date" "&dateline" "&digits" "&dump"
-         "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout" 
-         "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features" 
-         "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters" 
-         "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta" 
-         "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos" 
-         "&progname" "&random" "&rdrag" "&regions" "&resize" "&row" 
-         "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" 
+         "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout"
+         "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features"
+         "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters"
+         "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta"
+         "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos"
+         "&progname" "&random" "&rdrag" "&regions" "&resize" "&row"
+         "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject"
          "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y") t)
-       'font-lock-reference-face)
+       'font-lock-constant-face)
       (cons      ;; global local static declarations and link files
-       (concat 
+       (concat
        "^[ \t]*"
        (regexp-opt '("global" "link" "local" "static") t)
        "\\(\\sw+\\>\\)*")
@@ -673,21 +659,21 @@ Returns nil if line starts inside a string, t if in a comment."
                 font-lock-function-name-face
               font-lock-variable-name-face)))))
 
-      (cons      ;; $define $elif $ifdef $ifdef $ifndef
-       (concat 
-       "^" 
-       (regexp-opt'("$define" "$elif" "$ifdef" "$ifdef" "$ifndef" "$undef") t)
-       "[ \t]+\\([^ \t\n]+\\)")
-           '((1 font-lock-builtin-face) 
+      (cons      ;; $define $elif $ifdef $ifndef $undef
+       (concat "^"
+              (regexp-opt'("$define" "$elif" "$ifdef" "$ifndef" "$undef") t)
+              "\\>[ \t]*\\([^ \t\n]+\\)?")
+           '((1 font-lock-builtin-face)
              (4 font-lock-variable-name-face nil t)))
-      (cons      ;; $dump $endif $else $include 
-       (concat 
+      (cons      ;; $dump $endif $else $include
+       (concat
        "^" (regexp-opt'("$dump" "$endif" "$else" "$include") t) "\\>" )
        'font-lock-builtin-face)
       (cons      ;; $warning $error
-       (concat         "^" (regexp-opt '("$warning" "$error") t) "[ \t]+\\([^\n]+\\)")
-           '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t))))))
-    "Gaudy level highlighting for `icon-mode'.")
+       (concat "^" (regexp-opt '("$warning" "$error") t)
+              "\\>[ \t]*\\(.+\\)?")
+       '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t))))))
+  "Gaudy level highlighting for Icon mode.")
 
 (defvar icon-font-lock-keywords icon-font-lock-keywords-1
   "Default expressions to highlight in `icon-mode'.")
@@ -699,5 +685,7 @@ Returns nil if line starts inside a string, t if in a comment."
     (end-of-icon-defun)
     (forward-char -1)))
 
-(provide 'icon-mode)
+(provide 'icon)
+
+;; arch-tag: 8abf8c99-e7df-44af-a58f-ef5ed2ee52cb
 ;;; icon.el ends here