Mercurial > emacs
comparison lisp/progmodes/ada-mode.el @ 38446:f63fbebe03fb
(ada-mode): Avoid unneeded version checks.
Don't change compile-auto-highlight globally.
Don't bother with `font-lock-defaults' property since XEmacs
also understands the `font-lock-defaults' variable.
Use make-local-variable rather than make-variable-buffer-local.
Don't `defconst' comment-indent-function: keep the default.
Call easy-menu-add unconditionally.
(ada-create-keymap): Use [(shift tab)] so it works on both Emacsen.
(ada-create-menu): Use :included for Emacs as well.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 16 Jul 2001 15:12:19 +0000 |
parents | 7a94f1c588c4 |
children | 39ee7e7e2200 |
comparison
equal
deleted
inserted
replaced
38445:d91aa21f1e78 | 38446:f63fbebe03fb |
---|---|
5 | 5 |
6 ;; Author: Rolf Ebert <ebert@inf.enst.fr> | 6 ;; Author: Rolf Ebert <ebert@inf.enst.fr> |
7 ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de> | 7 ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de> |
8 ;; Emmanuel Briot <briot@gnat.com> | 8 ;; Emmanuel Briot <briot@gnat.com> |
9 ;; Maintainer: Emmanuel Briot <briot@gnat.com> | 9 ;; Maintainer: Emmanuel Briot <briot@gnat.com> |
10 ;; Ada Core Technologies's version: $Revision: 1.41 $ | 10 ;; Ada Core Technologies's version: $Revision: 1.42 $ |
11 ;; Keywords: languages ada | 11 ;; Keywords: languages ada |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
14 | 14 |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
32 ;;; This is a major rewrite of the file packaged with Emacs-20. The | 32 ;;; This is a major rewrite of the file packaged with Emacs-20. The |
33 ;;; ada-mode is composed of four lisp file, ada-mode.el, ada-xref.el, | 33 ;;; ada-mode is composed of four lisp file, ada-mode.el, ada-xref.el, |
34 ;;; ada-prj.el and ada-stmt.el. Only this file (ada-mode.el) is | 34 ;;; ada-prj.el and ada-stmt.el. Only this file (ada-mode.el) is |
35 ;;; completely independent from the GNU Ada compiler Gnat, distributed | 35 ;;; completely independent from the GNU Ada compiler Gnat, distributed |
36 ;;; by Ada Core Technologies. All the other files rely heavily on | 36 ;;; by Ada Core Technologies. All the other files rely heavily on |
37 ;;; features provides only by Gnat. | 37 ;;; features provided only by Gnat. |
38 ;;; | 38 ;;; |
39 ;;; Note: this mode will not work with Emacs 19. If you are on a VMS | 39 ;;; Note: this mode will not work with Emacs 19. If you are on a VMS |
40 ;;; system, where the latest version of Emacs is 19.28, you will need | 40 ;;; system, where the latest version of Emacs is 19.28, you will need |
41 ;;; another file, called ada-vms.el, that provides some required | 41 ;;; another file, called ada-vms.el, that provides some required |
42 ;;; functions. | 42 ;;; functions. |
1036 (set (make-local-variable 'comment-column) 40) | 1036 (set (make-local-variable 'comment-column) 40) |
1037 | 1037 |
1038 ;; Emacs 20.3 defines a comment-padding to insert spaces between | 1038 ;; Emacs 20.3 defines a comment-padding to insert spaces between |
1039 ;; the comment and the text. We do not want any, this is already | 1039 ;; the comment and the text. We do not want any, this is already |
1040 ;; included in comment-start | 1040 ;; included in comment-start |
1041 (unless ada-xemacs | 1041 (set (make-local-variable 'comment-padding) 0) |
1042 (progn | 1042 (set (make-local-variable 'parse-sexp-ignore-comments) t) |
1043 (if (ada-check-emacs-version 20 3) | 1043 (set (make-local-variable 'parse-sexp-lookup-properties) t) |
1044 (progn | |
1045 (set (make-local-variable 'parse-sexp-ignore-comments) t) | |
1046 (set (make-local-variable 'comment-padding) 0))) | |
1047 (set (make-local-variable 'parse-sexp-lookup-properties) t) | |
1048 )) | |
1049 | 1044 |
1050 (setq case-fold-search t) | 1045 (setq case-fold-search t) |
1051 (if (boundp 'imenu-case-fold-search) | 1046 (setq imenu-case-fold-search t) |
1052 (setq imenu-case-fold-search t)) | |
1053 | 1047 |
1054 (set (make-local-variable 'fill-paragraph-function) | 1048 (set (make-local-variable 'fill-paragraph-function) |
1055 'ada-fill-comment-paragraph) | 1049 'ada-fill-comment-paragraph) |
1056 | 1050 |
1057 (set (make-local-variable 'imenu-generic-expression) | 1051 (set (make-local-variable 'imenu-generic-expression) |
1059 | 1053 |
1060 ;; Support for compile.el | 1054 ;; Support for compile.el |
1061 ;; We just substitute our own functions to go to the error. | 1055 ;; We just substitute our own functions to go to the error. |
1062 (add-hook 'compilation-mode-hook | 1056 (add-hook 'compilation-mode-hook |
1063 (lambda() | 1057 (lambda() |
1064 (setq compile-auto-highlight 40) | 1058 (set (make-local-variable 'compile-auto-highlight) 40) |
1059 ;; FIXME: This has global impact! -stef | |
1065 (define-key compilation-minor-mode-map [mouse-2] | 1060 (define-key compilation-minor-mode-map [mouse-2] |
1066 'ada-compile-mouse-goto-error) | 1061 'ada-compile-mouse-goto-error) |
1067 (define-key compilation-minor-mode-map "\C-c\C-c" | 1062 (define-key compilation-minor-mode-map "\C-c\C-c" |
1068 'ada-compile-goto-error) | 1063 'ada-compile-goto-error) |
1069 (define-key compilation-minor-mode-map "\C-m" | 1064 (define-key compilation-minor-mode-map "\C-m" |
1070 'ada-compile-goto-error) | 1065 'ada-compile-goto-error))) |
1071 )) | 1066 |
1072 | 1067 ;; font-lock support |
1073 ;; font-lock support : | 1068 (set (make-local-variable 'font-lock-defaults) |
1074 ;; We need to set some properties for XEmacs, and define some variables | 1069 '(ada-font-lock-keywords |
1075 ;; for Emacs | 1070 nil t |
1076 | 1071 ((?\_ . "w") (?# . ".")) |
1077 (if ada-xemacs | 1072 beginning-of-line |
1078 ;; XEmacs | 1073 (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords))) |
1079 (put 'ada-mode 'font-lock-defaults | |
1080 '(ada-font-lock-keywords | |
1081 nil t ((?\_ . "w") (?# . ".")) beginning-of-line)) | |
1082 ;; Emacs | |
1083 (set (make-local-variable 'font-lock-defaults) | |
1084 '(ada-font-lock-keywords | |
1085 nil t | |
1086 ((?\_ . "w") (?# . ".")) | |
1087 beginning-of-line | |
1088 (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords))) | |
1089 ) | |
1090 | 1074 |
1091 ;; Set up support for find-file.el. | 1075 ;; Set up support for find-file.el. |
1092 (set (make-variable-buffer-local 'ff-other-file-alist) | 1076 (set (make-local-variable 'ff-other-file-alist) |
1093 'ada-other-file-alist) | 1077 'ada-other-file-alist) |
1094 (set (make-variable-buffer-local 'ff-search-directories) | 1078 (set (make-local-variable 'ff-search-directories) |
1095 'ada-search-directories) | 1079 'ada-search-directories) |
1096 (setq ff-post-load-hooks 'ada-set-point-accordingly | 1080 (setq ff-post-load-hooks 'ada-set-point-accordingly |
1097 ff-file-created-hooks 'ada-make-body) | 1081 ff-file-created-hooks 'ada-make-body) |
1098 (add-hook 'ff-pre-load-hooks 'ada-which-function-are-we-in) | 1082 (add-hook 'ff-pre-load-hooks 'ada-which-function-are-we-in) |
1099 | 1083 |
1164 (define-abbrev-table 'ada-mode-abbrev-table ()) | 1148 (define-abbrev-table 'ada-mode-abbrev-table ()) |
1165 (setq local-abbrev-table ada-mode-abbrev-table) | 1149 (setq local-abbrev-table ada-mode-abbrev-table) |
1166 | 1150 |
1167 ;; Support for indent-new-comment-line (Especially for XEmacs) | 1151 ;; Support for indent-new-comment-line (Especially for XEmacs) |
1168 (setq comment-multi-line nil) | 1152 (setq comment-multi-line nil) |
1169 (defconst comment-indent-function (lambda () comment-column)) | |
1170 | 1153 |
1171 (setq major-mode 'ada-mode) | 1154 (setq major-mode 'ada-mode) |
1172 (setq mode-name "Ada") | 1155 (setq mode-name "Ada") |
1173 | 1156 |
1174 (use-local-map ada-mode-map) | 1157 (use-local-map ada-mode-map) |
1175 | 1158 |
1176 (if ada-xemacs | 1159 (easy-menu-add ada-mode-menu ada-mode-map) |
1177 (funcall (symbol-function 'easy-menu-add) | |
1178 ada-mode-menu ada-mode-map)) | |
1179 | 1160 |
1180 (set-syntax-table ada-mode-syntax-table) | 1161 (set-syntax-table ada-mode-syntax-table) |
1181 | 1162 |
1182 (if ada-clean-buffer-before-saving | 1163 (if ada-clean-buffer-before-saving |
1183 (progn | 1164 (progn |
1191 | 1172 |
1192 ;; Run this after the hook to give the users a chance to activate | 1173 ;; Run this after the hook to give the users a chance to activate |
1193 ;; font-lock-mode | 1174 ;; font-lock-mode |
1194 | 1175 |
1195 (unless ada-xemacs | 1176 (unless ada-xemacs |
1196 (progn | 1177 (ada-initialize-properties) |
1197 (ada-initialize-properties) | 1178 (make-local-hook 'font-lock-mode-hook) |
1198 (make-local-hook 'font-lock-mode-hook) | 1179 (add-hook 'font-lock-mode-hook 'ada-deactivate-properties nil t)) |
1199 (add-hook 'font-lock-mode-hook 'ada-deactivate-properties nil t))) | |
1200 | 1180 |
1201 ;; the following has to be done after running the ada-mode-hook | 1181 ;; the following has to be done after running the ada-mode-hook |
1202 ;; because users might want to set the values of these variable | 1182 ;; because users might want to set the values of these variable |
1203 ;; inside the hook (MH) | 1183 ;; inside the hook (MH) |
1204 | 1184 |
3975 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent-conditional) | 3955 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent-conditional) |
3976 (define-key ada-mode-map "\C-m" 'ada-indent-newline-indent-conditional) | 3956 (define-key ada-mode-map "\C-m" 'ada-indent-newline-indent-conditional) |
3977 (define-key ada-mode-map "\t" 'ada-tab) | 3957 (define-key ada-mode-map "\t" 'ada-tab) |
3978 (define-key ada-mode-map "\C-c\t" 'ada-justified-indent-current) | 3958 (define-key ada-mode-map "\C-c\t" 'ada-justified-indent-current) |
3979 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region) | 3959 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region) |
3980 (if ada-xemacs | 3960 (define-key ada-mode-map [(shift tab)] 'ada-untab) |
3981 (define-key ada-mode-map '(shift tab) 'ada-untab) | |
3982 (define-key ada-mode-map [S-tab] 'ada-untab)) | |
3983 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist) | 3961 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist) |
3984 ;; We don't want to make meta-characters case-specific. | 3962 ;; We don't want to make meta-characters case-specific. |
3985 | 3963 |
3986 ;; Movement | 3964 ;; Movement |
3987 (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure) | 3965 (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure) |
4059 ["Make body for subprogram" ada-make-subprogram-body t])) | 4037 ["Make body for subprogram" ada-make-subprogram-body t])) |
4060 | 4038 |
4061 ) | 4039 ) |
4062 | 4040 |
4063 ;; Option menu present only if in Ada mode | 4041 ;; Option menu present only if in Ada mode |
4064 (setq m (append m (list (append (list "Options" | 4042 (setq m (append m (list (append '("Options" |
4065 (if ada-xemacs :included :visible) | 4043 :included (eq major-mode 'ada-mode)) |
4066 '(string= mode-name "Ada")) | |
4067 option)))) | 4044 option)))) |
4068 | 4045 |
4069 ;; Customize menu always present | 4046 ;; Customize menu always present |
4070 (setq m (append m '(["Customize" (customize-group 'ada) | 4047 (when (fboundp 'customize-group) |
4071 (>= emacs-major-version 20)]))) | 4048 (setq m (append m '(["Customize" (customize-group 'ada)])))) |
4072 | 4049 |
4073 ;; Goto and Edit menus present only if in Ada mode | 4050 ;; Goto and Edit menus present only if in Ada mode |
4074 (setq m (append m (list (append (list "Goto" | 4051 (setq m (append m (list (append '("Goto" |
4075 (if ada-xemacs :included :visible) | 4052 :included (eq major-mode 'ada-mode)) |
4076 '(string= mode-name "Ada")) | |
4077 goto) | 4053 goto) |
4078 (append (list "Edit" | 4054 (append '("Edit" |
4079 (if ada-xemacs :included :visible) | 4055 :included (eq major-mode 'ada-mode)) |
4080 '(string= mode-name "Ada")) | |
4081 edit)))) | 4056 edit)))) |
4082 | 4057 |
4083 (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode" m) | 4058 (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode" m) |
4084 (if ada-xemacs | 4059 (easy-menu-add ada-mode-menu ada-mode-map) |
4085 (progn | 4060 (when ada-xemacs |
4086 (easy-menu-add ada-mode-menu ada-mode-map) | 4061 ;; This looks bogus to me! -stef |
4087 (define-key ada-mode-map [menu-bar] ada-mode-menu) | 4062 (define-key ada-mode-map [menu-bar] ada-mode-menu) |
4088 (setq mode-popup-menu (cons "Ada mode" ada-mode-menu))) | 4063 (setq mode-popup-menu (cons "Ada mode" ada-mode-menu))))) |
4089 ) | |
4090 )) | |
4091 | 4064 |
4092 | 4065 |
4093 ;; ------------------------------------------------------- | 4066 ;; ------------------------------------------------------- |
4094 ;; Commenting/Uncommenting code | 4067 ;; Commenting/Uncommenting code |
4095 ;; The following two calls are provided to enhance the standard | 4068 ;; The following two calls are provided to enhance the standard |