Mercurial > emacs
comparison lisp/progmodes/icon.el @ 17266:9ef8bf76c3c2
(icon-mode-map): Added menus.
(icon-imenu-generic-expression): New variable to be used for imenu.
(icon-mode): Added font-lock, imenu and hideshow support.
(icon-font-lock-keywords-1, icon-font-lock-keywords-2):
New constants for different level of font-lock fontification.
(icon-font-lock-keywords): New variable. Default expression to be
assigned to font-lock-keywords in `icon-mode'.
(icon-forward-sexp-function): New function used as `forward-sexp' by hideshow.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 30 Mar 1997 21:50:02 +0000 |
parents | 83f275dcd93a |
children | 3b746ca2bca9 |
comparison
equal
deleted
inserted
replaced
17265:ddbe17ae5280 | 17266:9ef8bf76c3c2 |
---|---|
35 | 35 |
36 (defvar icon-mode-map () | 36 (defvar icon-mode-map () |
37 "Keymap used in Icon mode.") | 37 "Keymap used in Icon mode.") |
38 (if icon-mode-map | 38 (if icon-mode-map |
39 () | 39 () |
40 (setq icon-mode-map (make-sparse-keymap)) | 40 (let ((map (make-sparse-keymap "Icon"))) |
41 (define-key icon-mode-map "{" 'electric-icon-brace) | 41 (setq icon-mode-map (make-sparse-keymap)) |
42 (define-key icon-mode-map "}" 'electric-icon-brace) | 42 (define-key icon-mode-map "{" 'electric-icon-brace) |
43 (define-key icon-mode-map "\e\C-h" 'mark-icon-function) | 43 (define-key icon-mode-map "}" 'electric-icon-brace) |
44 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun) | 44 (define-key icon-mode-map "\e\C-h" 'mark-icon-function) |
45 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun) | 45 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun) |
46 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp) | 46 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun) |
47 (define-key icon-mode-map "\177" 'backward-delete-char-untabify) | 47 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp) |
48 (define-key icon-mode-map "\t" 'icon-indent-command)) | 48 (define-key icon-mode-map "\177" 'backward-delete-char-untabify) |
49 (define-key icon-mode-map "\t" 'icon-indent-command) | |
50 | |
51 (define-key icon-mode-map [menu-bar] (make-sparse-keymap)) | |
52 (define-key icon-mode-map [menu-bar icon] | |
53 (cons "Icon" map)) | |
54 (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun)) | |
55 (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun)) | |
56 (define-key map [comment-region] '("Comment Out Region" . comment-region)) | |
57 (define-key map [indent-region] '("Indent Region" . indent-region)) | |
58 (define-key map [indent-line] '("Indent Line" . icon-indent-command)) | |
59 (put 'eval-region 'menu-enable 'mark-active) | |
60 (put 'comment-region 'menu-enable 'mark-active) | |
61 (put 'indent-region 'menu-enable 'mark-active))) | |
49 | 62 |
50 (defvar icon-mode-syntax-table nil | 63 (defvar icon-mode-syntax-table nil |
51 "Syntax table in use in Icon-mode buffers.") | 64 "Syntax table in use in Icon-mode buffers.") |
52 | 65 |
53 (if icon-mode-syntax-table | 66 (if icon-mode-syntax-table |
86 inserted in Icon code.") | 99 inserted in Icon code.") |
87 | 100 |
88 (defvar icon-tab-always-indent t | 101 (defvar icon-tab-always-indent t |
89 "*Non-nil means TAB in Icon mode should always reindent the current line, | 102 "*Non-nil means TAB in Icon mode should always reindent the current line, |
90 regardless of where in the line point is when the TAB command is used.") | 103 regardless of where in the line point is when the TAB command is used.") |
104 | |
105 (defvar icon-imenu-generic-expression | |
106 '((nil "^[ \t]*procedure[ \t]*\\(\\sw+\\)[ \t]*(" 1)) | |
107 "Imenu expression for Icon-mode. See `imenu-generic-expression'.") | |
108 | |
109 | |
91 | 110 |
92 ;;;###autoload | 111 ;;;###autoload |
93 (defun icon-mode () | 112 (defun icon-mode () |
94 "Major mode for editing Icon code. | 113 "Major mode for editing Icon code. |
95 Expression and list commands understand all Icon brackets. | 114 Expression and list commands understand all Icon brackets. |
145 (setq comment-column 32) | 164 (setq comment-column 32) |
146 (make-local-variable 'comment-start-skip) | 165 (make-local-variable 'comment-start-skip) |
147 (setq comment-start-skip "# *") | 166 (setq comment-start-skip "# *") |
148 (make-local-variable 'comment-indent-function) | 167 (make-local-variable 'comment-indent-function) |
149 (setq comment-indent-function 'icon-comment-indent) | 168 (setq comment-indent-function 'icon-comment-indent) |
169 ;; font-lock support | |
170 (make-local-variable 'font-lock-defaults) | |
171 (setq font-lock-defaults | |
172 '((icon-font-lock-keywords | |
173 icon-font-lock-keywords-1 | |
174 icon-font-lock-keywords-2 | |
175 ) | |
176 nil nil ((?_ . "w")) beginning-of-defun | |
177 (font-lock-comment-start-regexp . "#") | |
178 (font-lock-mark-block-function . mark-defun))) | |
179 ;; imenu support | |
180 (make-local-variable 'imenu-generic-expression) | |
181 (setq imenu-generic-expression icon-imenu-generic-expression) | |
182 ;; hideshow support | |
183 ;; we start from the assertion that `hs-special-modes-alist' is autoloaded. | |
184 (pushnew '(icon-mode "procedure" "end" icon-forward-sexp-function) | |
185 hs-special-modes-alist :test 'equal) | |
150 (run-hooks 'icon-mode-hook)) | 186 (run-hooks 'icon-mode-hook)) |
151 | 187 |
152 ;; This is used by indent-for-comment to decide how much to | 188 ;; This is used by indent-for-comment to decide how much to |
153 ;; indent a comment in Icon code based on its context. | 189 ;; indent a comment in Icon code based on its context. |
154 (defun icon-comment-indent () | 190 (defun icon-comment-indent () |
551 ;; Indent any comment following the text. | 587 ;; Indent any comment following the text. |
552 (or (looking-at comment-start-skip) | 588 (or (looking-at comment-start-skip) |
553 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) | 589 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) |
554 (progn (indent-for-comment) (beginning-of-line)))))))))) | 590 (progn (indent-for-comment) (beginning-of-line)))))))))) |
555 | 591 |
592 (defconst icon-font-lock-keywords-1 | |
593 (eval-when-compile | |
594 (list | |
595 ;; Fontify procedure name definitions. | |
596 '("^[ \t]*\\(procedure\\)[ \t]*\\(\\sw+\\)[ \t]*(" | |
597 (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t)))) | |
598 "Subdued level highlighting for `icon-mode'.") | |
599 | |
600 (defconst icon-font-lock-keywords-2 | |
601 (append | |
602 icon-font-lock-keywords-1 | |
603 (eval-when-compile | |
604 (list | |
605 ;; Fontify all type specifiers. | |
606 ;;"null" "string" "co-expression" "table" "integer" "cset" "set" "real" "file" "list" | |
607 (cons "\\<\\(c\\(o-expression\\|set\\)\\|file\\|integer\\|list\\|null\\|real\\|s\\(et\\|tring\\)\\|table\\)\\>"'font-lock-type-face) | |
608 ;; Fontify all keywords. | |
609 ;;"break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" "until" "case" "of" "while" "create" "every" "suspend" "default" "fail" "record" "then" | |
610 (cons "\\<\\(b\\(reak\\|y\\)\\|c\\(ase\\|reate\\)\\|d\\(efault\\|o\\)\\|e\\(lse\\|very\\)\\|fail\\|if\\|n\\(ext\\|ot\\)\\|of\\|re\\(cord\\|peat\\|turn\\)\\|suspend\\|t\\(hen\\|o\\)\\|until\\|while\\)\\>" 'font-lock-keyword-face) | |
611 ;; "end" "initial" | |
612 (cons (concat "\\<\\(end\\|initial\\)\\>") 'font-lock-builtin-face) | |
613 ;; Fontify all system variables. | |
614 ;;"&allocated" "&ascii" "&clock" "&col" "&collections" "&column" "&control" "&cset" "¤t" "&date" "&dateline" "&digits" "&dump" "&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" "®ions" "&resize" "&row" "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y" | |
615 (cons (concat "\\(&\\(a\\(llocated\\|scii\\)\\|c\\(lock\\|o\\(l\\(\\|lections\\|umn\\)\\|ntrol\\)\\|set\\|urrent\\)\\|d\\(ate\\(\\|line\\)\\|igits\\|ump\\)\\|e\\(rro\\(r\\(\\|number\\|text\\|value\\)\\|ut\\)\\|vent\\(code\\|source\\|value\\)\\)\\|f\\(ail\\|eatures\\|ile\\)\\|host\\|in\\(put\\|terval\\)\\|l\\(case\\|drag\\|e\\(tters\\|vel\\)\\|ine\\|press\\|release\\)\\|m\\(ain\\|drag\\|eta\\|press\\|release\\)\\|null\\|output\\|p\\(hi\\|i\\|os\\|rogname\\)\\|r\\(andom\\|drag\\|e\\(gions\\|size\\)\\|ow\\|press\\|release\\)\\|s\\(hift\\|ource\\|torage\\|ubject\\)\\|t\\(ime\\|race\\)\\|ucase\\|version\\|window\\|[exy]\\)\\)") 'font-lock-reference-face) | |
616 ;; global local static declarations and link files | |
617 (cons "^[ \t]*\\(global\\|link\\|local\\|static\\)\\(\\sw+\\>\\)*" | |
618 '((1 font-lock-builtin-face) | |
619 (font-lock-match-c-style-declaration-item-and-skip-to-next | |
620 (goto-char (or (match-beginning 2) (match-end 1))) nil | |
621 (1 (if (match-beginning 2) | |
622 font-lock-function-name-face | |
623 font-lock-variable-name-face))))) | |
624 ;; $define $elif $ifdef $ifdef $ifndef | |
625 (cons "^\\(\\$\\(define\\|elif\\|if\\(\\|def\\|ndef\\)\\|undef\\)\\)[ \t]+\\([^ \t\n]+\\)" | |
626 '((1 font-lock-builtin-face) (4 font-lock-variable-name-face nil t))) | |
627 ;; $dump $endif $else $include | |
628 (cons "^\\(\\$\\(dump\\|e\\(lse\\|ndif\\)\\|include\\)\\)\\>" 'font-lock-builtin-face) | |
629 ;; $warning $error | |
630 (cons "^\\(\\$\\(warning\\|error\\)\\)[ \t]+\\([^\n]+\\)" | |
631 '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t))) | |
632 ))) | |
633 "Gaudy level highlighting for `icon-mode'.") | |
634 | |
635 (defvar icon-font-lock-keywords icon-font-lock-keywords-1 | |
636 "Default expressions to highlight in `icon-mode'.") | |
637 | |
638 ;;;used by hs-minor-mode | |
639 (defun icon-forward-sexp-function (arg) | |
640 (if (> arg 0) | |
641 (re-search-forward "^[ \t]*end") | |
642 (re-search-backward "^[ \t]procedure"))) | |
643 | |
644 (provide 'icon-mode) | |
556 ;;; icon.el ends here | 645 ;;; icon.el ends here |