summaryrefslogtreecommitdiff
path: root/lisp/progmodes/icon.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/icon.el')
-rw-r--r--lisp/progmodes/icon.el119
1 files changed, 53 insertions, 66 deletions
diff --git a/lisp/progmodes/icon.el b/lisp/progmodes/icon.el
index 933cb333dfb..e9a21d4a0cf 100644
--- a/lisp/progmodes/icon.el
+++ b/lisp/progmodes/icon.el
@@ -1,4 +1,4 @@
-;;; icon.el --- mode for editing Icon code
+;;; icon.el --- mode for editing Icon code -*- lexical-binding: t -*-
;; Copyright (C) 1989, 2001-2021 Free Software Foundation, Inc.
@@ -31,53 +31,48 @@
"Abbrev table in use in Icon-mode buffers.")
(define-abbrev-table 'icon-mode-abbrev-table ())
-(defvar icon-mode-map ()
- "Keymap used in Icon mode.")
-(if icon-mode-map
- ()
+(defvar icon-mode-map
(let ((map (make-sparse-keymap "Icon")))
- (setq icon-mode-map (make-sparse-keymap))
- (define-key icon-mode-map "{" 'electric-icon-brace)
- (define-key icon-mode-map "}" 'electric-icon-brace)
- (define-key icon-mode-map "\e\C-h" 'mark-icon-function)
- (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun)
- (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 [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))
- (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun))
- (define-key map [comment-region] '("Comment Out Region" . comment-region))
- (define-key map [indent-region] '("Indent Region" . indent-region))
- (define-key map [indent-line] '("Indent Line" . icon-indent-command))
- (put 'eval-region 'menu-enable 'mark-active)
- (put 'comment-region 'menu-enable 'mark-active)
- (put 'indent-region 'menu-enable 'mark-active)))
-
-(defvar icon-mode-syntax-table nil
- "Syntax table in use in Icon-mode buffers.")
+ (define-key map "{" 'electric-icon-brace)
+ (define-key map "}" 'electric-icon-brace)
+ (define-key map "\e\C-h" 'mark-icon-function)
+ (define-key map "\e\C-a" 'beginning-of-icon-defun)
+ (define-key map "\e\C-e" 'end-of-icon-defun)
+ (define-key map "\e\C-q" 'indent-icon-exp)
+ (define-key map "\177" 'backward-delete-char-untabify)
+ map)
+ "Keymap used in Icon mode.")
-(if icon-mode-syntax-table
- ()
- (setq icon-mode-syntax-table (make-syntax-table))
- (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table)
- (modify-syntax-entry ?# "<" icon-mode-syntax-table)
- (modify-syntax-entry ?\n ">" icon-mode-syntax-table)
- (modify-syntax-entry ?$ "." icon-mode-syntax-table)
- (modify-syntax-entry ?/ "." icon-mode-syntax-table)
- (modify-syntax-entry ?* "." icon-mode-syntax-table)
- (modify-syntax-entry ?+ "." icon-mode-syntax-table)
- (modify-syntax-entry ?- "." icon-mode-syntax-table)
- (modify-syntax-entry ?= "." icon-mode-syntax-table)
- (modify-syntax-entry ?% "." icon-mode-syntax-table)
- (modify-syntax-entry ?< "." icon-mode-syntax-table)
- (modify-syntax-entry ?> "." icon-mode-syntax-table)
- (modify-syntax-entry ?& "." icon-mode-syntax-table)
- (modify-syntax-entry ?| "." icon-mode-syntax-table)
- (modify-syntax-entry ?\' "\"" icon-mode-syntax-table))
+(easy-menu-define icon-mode-menu icon-mode-map
+ "Menu for Icon mode."
+ '("Icon"
+ ["Beginning of function" beginning-of-icon-defun]
+ ["Comment Out Region" comment-region
+ :enable mark-active]
+ ["End of function" end-of-icon-defun]
+ ["Indent Line" icon-indent-command]
+ ["Indent Region" indent-region
+ :enable mark-active]))
+
+(defvar icon-mode-syntax-table
+ (let ((table (make-syntax-table)))
+ (modify-syntax-entry ?\\ "\\" table)
+ (modify-syntax-entry ?# "<" table)
+ (modify-syntax-entry ?\n ">" table)
+ (modify-syntax-entry ?$ "." table)
+ (modify-syntax-entry ?/ "." table)
+ (modify-syntax-entry ?* "." table)
+ (modify-syntax-entry ?+ "." table)
+ (modify-syntax-entry ?- "." table)
+ (modify-syntax-entry ?= "." table)
+ (modify-syntax-entry ?% "." table)
+ (modify-syntax-entry ?< "." table)
+ (modify-syntax-entry ?> "." table)
+ (modify-syntax-entry ?& "." table)
+ (modify-syntax-entry ?| "." table)
+ (modify-syntax-entry ?\' "\"" table)
+ table)
+ "Syntax table in use in Icon-mode buffers.")
(defgroup icon nil
"Mode for editing Icon code."
@@ -86,42 +81,35 @@
(defcustom icon-indent-level 4
"Indentation of Icon statements with respect to containing block."
- :type 'integer
- :group 'icon)
+ :type 'integer)
(defcustom icon-brace-imaginary-offset 0
"Imagined indentation of an Icon open brace that actually follows a statement."
- :type 'integer
- :group 'icon)
+ :type 'integer)
(defcustom icon-brace-offset 0
"Extra indentation for braces, compared with other text in same context."
- :type 'integer
- :group 'icon)
+ :type 'integer)
(defcustom icon-continued-statement-offset 4
"Extra indent for Icon lines not starting new statements."
- :type 'integer
- :group 'icon)
+ :type 'integer)
(defcustom icon-continued-brace-offset 0
"Extra indent for Icon substatements that start with open-braces.
This is in addition to `icon-continued-statement-offset'."
- :type 'integer
- :group 'icon)
+ :type 'integer)
(defcustom icon-auto-newline nil
"Non-nil means automatically newline before and after braces Icon code.
This applies when braces are inserted."
- :type 'boolean
- :group 'icon)
+ :type 'boolean)
(defcustom icon-tab-always-indent t
"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
- :group 'icon)
+ :type 'boolean)
(defvar icon-imenu-generic-expression
'((nil "^[ \t]*procedure[ \t]+\\(\\sw+\\)[ \t]*(" 1))
@@ -209,12 +197,11 @@ with no args, if that value is non-nil."
(progn
(insert last-command-event)
(icon-indent-line)
- (if icon-auto-newline
- (progn
- (newline)
- ;; (newline) may have done auto-fill
- (setq insertpos (- (point) 2))
- (icon-indent-line)))
+ (when icon-auto-newline
+ (newline)
+ ;; (newline) may have done auto-fill
+ (setq insertpos (- (point) 2))
+ (icon-indent-line))
(save-excursion
(if insertpos (goto-char (1+ insertpos)))
(delete-char -1))))