Mercurial > emacs
comparison lisp/progmodes/tcl.el @ 11787:635f5fb5d82a
Changed "Lucid Emacs" to "XEmacs".
Tcl's popup menu now added to existing one, courtesy
dfarmer@evolving.com (Doug Farmer)
author | Tom Tromey <tromey@redhat.com> |
---|---|
date | Tue, 09 May 1995 21:36:53 +0000 |
parents | 7823947372f9 |
children | 69cd9dade419 |
comparison
equal
deleted
inserted
replaced
11786:999e039b498b | 11787:635f5fb5d82a |
---|---|
4 | 4 |
5 ;; Maintainer: Tom Tromey <tromey@busco.lanl.gov> | 5 ;; Maintainer: Tom Tromey <tromey@busco.lanl.gov> |
6 ;; Author: Tom Tromey <tromey@busco.lanl.gov> | 6 ;; Author: Tom Tromey <tromey@busco.lanl.gov> |
7 ;; Chris Lindblad <cjl@lcs.mit.edu> | 7 ;; Chris Lindblad <cjl@lcs.mit.edu> |
8 ;; Keywords: languages tcl modes | 8 ;; Keywords: languages tcl modes |
9 ;; Version: $Revision: 1.27 $ | 9 ;; Version: $Revision: 1.28 $ |
10 | 10 |
11 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
12 | 12 |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | 13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
14 ;; it under the terms of the GNU General Public License as published by | 14 ;; it under the terms of the GNU General Public License as published by |
49 ;;; Commentary: | 49 ;;; Commentary: |
50 | 50 |
51 ;; LCD Archive Entry: | 51 ;; LCD Archive Entry: |
52 ;; tcl|Tom Tromey|tromey@busco.lanl.gov| | 52 ;; tcl|Tom Tromey|tromey@busco.lanl.gov| |
53 ;; Major mode for editing Tcl| | 53 ;; Major mode for editing Tcl| |
54 ;; $Date: 1994/10/11 02:01:27 $|$Revision: 1.27 $|~/modes/tcl.el.Z| | 54 ;; $Date: 1995/04/08 19:52:50 $|$Revision: 1.28 $|~/modes/tcl.el.Z| |
55 | 55 |
56 ;; CUSTOMIZATION NOTES: | 56 ;; CUSTOMIZATION NOTES: |
57 ;; * tcl-proc-list can be used to customize a list of things that | 57 ;; * tcl-proc-list can be used to customize a list of things that |
58 ;; "define" other things. Eg in my project I put "defvar" in this | 58 ;; "define" other things. Eg in my project I put "defvar" in this |
59 ;; list. | 59 ;; list. |
63 ;; * tcl-type-alist can be used to minimally customize indentation | 63 ;; * tcl-type-alist can be used to minimally customize indentation |
64 ;; according to context. | 64 ;; according to context. |
65 | 65 |
66 ;; Change log: | 66 ;; Change log: |
67 ;; $Log: tcl.el,v $ | 67 ;; $Log: tcl.el,v $ |
68 ;; Revision 1.28 1995/04/08 19:52:50 tromey | |
69 ;; (tcl-outline-level): New function | |
70 ;; (tcl-mode): Added outline-handling stuff. | |
71 ;; From Jesper Pedersen <blackie@imada.ou.dk> | |
72 ;; | |
68 ;; Revision 1.27 1994/10/11 02:01:27 tromey | 73 ;; Revision 1.27 1994/10/11 02:01:27 tromey |
69 ;; (tcl-mode): imenu-create-index-function made buffer local. | 74 ;; (tcl-mode): imenu-create-index-function made buffer local. |
70 ;; | 75 ;; |
71 ;; Revision 1.26 1994/09/01 18:06:24 tromey | 76 ;; Revision 1.26 1994/09/01 18:06:24 tromey |
72 ;; Added filename completion in inferior tcl mode | 77 ;; Added filename completion in inferior tcl mode |
208 ;; schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid) | 213 ;; schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid) |
209 ;; warsaw@nlm.nih.gov (Barry A. Warsaw) | 214 ;; warsaw@nlm.nih.gov (Barry A. Warsaw) |
210 ;; Carl Witty <cwitty@ai.mit.edu> | 215 ;; Carl Witty <cwitty@ai.mit.edu> |
211 ;; T. V. Raman <raman@crl.dec.com> | 216 ;; T. V. Raman <raman@crl.dec.com> |
212 ;; Jesper Pedersen <blackie@imada.ou.dk> | 217 ;; Jesper Pedersen <blackie@imada.ou.dk> |
218 ;; dfarmer@evolving.com (Doug Farmer) | |
213 | 219 |
214 ;; KNOWN BUGS: | 220 ;; KNOWN BUGS: |
215 ;; * indent-region should skip blank lines. (It does in v19, so I'm | 221 ;; * indent-region should skip blank lines. (It does in v19, so I'm |
216 ;; not motivated to fix it here). | 222 ;; not motivated to fix it here). |
217 ;; * In Tcl "#" is not always a comment character. This can confuse | 223 ;; * In Tcl "#" is not always a comment character. This can confuse |
251 ;; * Inferior should display in half the screen, not the whole screen. | 257 ;; * Inferior should display in half the screen, not the whole screen. |
252 ;; * Indentation should deal with "switch". | 258 ;; * Indentation should deal with "switch". |
253 ;; * Consider writing code to find help files automatically (for | 259 ;; * Consider writing code to find help files automatically (for |
254 ;; common cases). | 260 ;; common cases). |
255 ;; * `#' shouldn't insert `\#' when point is in string. | 261 ;; * `#' shouldn't insert `\#' when point is in string. |
256 ;; * '}' doesn't seem to reindent. | |
257 | 262 |
258 | 263 |
259 | 264 |
260 ;;; Code: | 265 ;;; Code: |
261 | 266 |
262 ;; I sure wish Emacs had a package that made it easy to extract this | 267 ;; I sure wish Emacs had a package that made it easy to extract this |
263 ;; sort of information. | 268 ;; sort of information. |
264 (defconst tcl-using-emacs-19 (string-match "19\\." emacs-version) | 269 (defconst tcl-using-emacs-19 (string-match "19\\." emacs-version) |
265 "Nil unless using Emacs 19 (Lucid or FSF).") | 270 "Nil unless using Emacs 19 (XEmacs or FSF).") |
266 | 271 |
267 ;; FIXME this will break on Emacs 19.100. | 272 ;; FIXME this will break on Emacs 19.100. |
268 (defconst tcl-using-emacs-19-23 | 273 (defconst tcl-using-emacs-19-23 |
269 (string-match "19\\.\\(2[3-9]\\|[3-9][0-9]\\)" emacs-version) | 274 (string-match "19\\.\\(2[3-9]\\|[3-9][0-9]\\)" emacs-version) |
270 "Nil unless using Emacs 19-23 or later.") | 275 "Nil unless using Emacs 19-23 or later.") |
271 | 276 |
272 (defconst tcl-using-lemacs-19 (string-match "Lucid" emacs-version) | 277 (defconst tcl-using-xemacs-19 (string-match "XEmacs" emacs-version) |
273 "Nil unless using Lucid Emacs).") | 278 "Nil unless using XEmacs).") |
274 | 279 |
275 (require 'comint) | 280 (require 'comint) |
276 | 281 |
277 ;; When compiling under GNU Emacs, load imenu during compilation. If | 282 ;; When compiling under GNU Emacs, load imenu during compilation. If |
278 ;; you have 19.22 or earlier, comment this out, or get imenu. | 283 ;; you have 19.22 or earlier, comment this out, or get imenu. |
279 (and (fboundp 'eval-when-compile) | 284 (and (fboundp 'eval-when-compile) |
280 (eval-when-compile | 285 (eval-when-compile |
281 (if (and (string-match "19\\." emacs-version) | 286 (if (and (string-match "19\\." emacs-version) |
282 (not (string-match "Lucid" emacs-version))) | 287 (not (string-match "XEmacs" emacs-version))) |
283 (require 'imenu)) | 288 (require 'imenu)) |
284 ())) | 289 ())) |
285 | 290 |
286 (defconst tcl-version "$Revision: 1.27 $") | 291 (defconst tcl-version "$Revision: 1.28 $") |
287 (defconst tcl-maintainer "Tom Tromey <tromey@busco.lanl.gov>") | 292 (defconst tcl-maintainer "Tom Tromey <tromey@drip.colorado.edu>") |
288 | 293 |
289 ;; | 294 ;; |
290 ;; User variables. | 295 ;; User variables. |
291 ;; | 296 ;; |
292 | 297 |
398 (modify-syntax-entry ?# "< " tcl-mode-syntax-table)) | 403 (modify-syntax-entry ?# "< " tcl-mode-syntax-table)) |
399 | 404 |
400 (defvar inferior-tcl-mode-map nil | 405 (defvar inferior-tcl-mode-map nil |
401 "Keymap used in Inferior Tcl mode.") | 406 "Keymap used in Inferior Tcl mode.") |
402 | 407 |
403 ;; Lucid Emacs menu. | 408 ;; XEmacs menu. |
404 (defvar tcl-lucid-menu | 409 (defvar tcl-xemacs-menu |
405 '("Tcl" | 410 '("Tcl" |
406 ["Beginning of function" tcl-beginning-of-defun t] | 411 ["Beginning of function" tcl-beginning-of-defun t] |
407 ["End of function" tcl-end-of-defun t] | 412 ["End of function" tcl-end-of-defun t] |
408 ["Mark function" tcl-mark-defun t] | 413 ["Mark function" tcl-mark-defun t] |
409 ["Indent region" indent-region (tcl-mark)] | 414 ["Indent region" indent-region (tcl-mark)] |
419 (and inferior-tcl-buffer (get-buffer inferior-tcl-buffer))] | 424 (and inferior-tcl-buffer (get-buffer inferior-tcl-buffer))] |
420 ["Restart Tcl process with file" tcl-restart-with-file t] | 425 ["Restart Tcl process with file" tcl-restart-with-file t] |
421 "----" | 426 "----" |
422 ["Tcl help" tcl-help-on-word tcl-help-directory-list] | 427 ["Tcl help" tcl-help-on-word tcl-help-directory-list] |
423 ["Send bug report" tcl-submit-bug-report t]) | 428 ["Send bug report" tcl-submit-bug-report t]) |
424 "Lucid Emacs menu for Tcl mode.") | 429 "XEmacs menu for Tcl mode.") |
425 | 430 |
426 ;; GNU Emacs does menus via keymaps. Do it in a function in case we | 431 ;; GNU Emacs does menus via keymaps. Do it in a function in case we |
427 ;; later decide to add it to inferior Tcl mode as well. | 432 ;; later decide to add it to inferior Tcl mode as well. |
428 (defun tcl-add-fsf-menu (map) | 433 (defun tcl-add-fsf-menu (map) |
429 (define-key map [menu-bar] (make-sparse-keymap)) | 434 (define-key map [menu-bar] (make-sparse-keymap)) |
430 ;; This fails in Emacs 19.22 and earlier. | 435 ;; This fails in Emacs 19.22 and earlier. |
431 (require 'lmenu) | 436 (require 'lmenu) |
432 (let ((menu (make-lucid-menu-keymap "Tcl" (cdr tcl-lucid-menu)))) | 437 (let ((menu (make-xemacs-menu-keymap "Tcl" (cdr tcl-xemacs-menu)))) |
433 (define-key map [menu-bar tcl] (cons "Tcl" menu)) | 438 (define-key map [menu-bar tcl] (cons "Tcl" menu)) |
434 ;; The following is intended to compute the key sequence | 439 ;; The following is intended to compute the key sequence |
435 ;; information for the menu. It doesn't work. | 440 ;; information for the menu. It doesn't work. |
436 (x-popup-menu nil menu))) | 441 (x-popup-menu nil menu))) |
437 | 442 |
462 (define-key tcl-mode-map "\C-c\C-t" 'inferior-tcl) | 467 (define-key tcl-mode-map "\C-c\C-t" 'inferior-tcl) |
463 (define-key tcl-mode-map "\C-c\C-x" 'tcl-eval-region) | 468 (define-key tcl-mode-map "\C-c\C-x" 'tcl-eval-region) |
464 (define-key tcl-mode-map "\C-c\C-s" 'switch-to-tcl) | 469 (define-key tcl-mode-map "\C-c\C-s" 'switch-to-tcl) |
465 | 470 |
466 ;; Make menus. | 471 ;; Make menus. |
467 (if tcl-using-emacs-19 | 472 (if (and tcl-using-emacs-19 (not tcl-using-xemacs-19)) |
468 (if tcl-using-lemacs-19 | 473 (progn |
469 ;; In Lucid, button 3 seems to be the standard for this. | 474 ;; In FSF 19, there is no standard button for the popup menu, |
470 (define-key tcl-mode-map 'button3 'tcl-popup-menu) | 475 ;; so I use shift-button2. |
471 ;; In FSF 19, there is no standard, so I use shift-button2. | |
472 (tcl-add-fsf-menu tcl-mode-map) | 476 (tcl-add-fsf-menu tcl-mode-map) |
473 (define-key tcl-mode-map [S-down-mouse-2] 'tcl-popup-menu)))) | 477 (define-key tcl-mode-map [S-down-mouse-2] 'tcl-popup-menu)))) |
474 | 478 |
475 (defun tcl-fill-inferior-map () | 479 (defun tcl-fill-inferior-map () |
476 (define-key inferior-tcl-mode-map "\t" 'comint-dynamic-complete) | 480 (define-key inferior-tcl-mode-map "\t" 'comint-dynamic-complete) |
650 ;; | 654 ;; |
651 | 655 |
652 ;; We use this because Lemacs 19.9 has what we need. | 656 ;; We use this because Lemacs 19.9 has what we need. |
653 (defconst tcl-pps-has-arg-6 | 657 (defconst tcl-pps-has-arg-6 |
654 (or tcl-using-emacs-19 | 658 (or tcl-using-emacs-19 |
655 (and tcl-using-lemacs-19 | 659 (and tcl-using-xemacs-19 |
656 (condition-case nil | 660 (condition-case nil |
657 (progn | 661 (progn |
658 (parse-partial-sexp (point) (point) nil nil nil t) | 662 (parse-partial-sexp (point) (point) nil nil nil t) |
659 t) | 663 t) |
660 (error nil)))) | 664 (error nil)))) |
748 (push-mark (point))) | 752 (push-mark (point))) |
749 (tcl-beginning-of-defun) | 753 (tcl-beginning-of-defun) |
750 (backward-paragraph)) | 754 (backward-paragraph)) |
751 | 755 |
752 ;; In GNU Emacs 19-23 and later, mark-defun works as advertised. I | 756 ;; In GNU Emacs 19-23 and later, mark-defun works as advertised. I |
753 ;; don't know about Lucid Emacs, so for now it and Emacs 18 just lose. | 757 ;; don't know about XEmacs, so for now it and Emacs 18 just lose. |
754 (fset 'tcl-mark-defun | 758 (fset 'tcl-mark-defun |
755 (if tcl-using-emacs-19-23 | 759 (if tcl-using-emacs-19-23 |
756 'mark-defun | 760 'mark-defun |
757 'tcl-internal-mark-defun)) | 761 'tcl-internal-mark-defun)) |
758 | 762 |
759 ;; In GNU Emacs 19, mark takes an additional "force" argument. I | 763 ;; In GNU Emacs 19, mark takes an additional "force" argument. I |
760 ;; don't know about Lucid Emacs, so I'm just assuming it is the same. | 764 ;; don't know about XEmacs, so I'm just assuming it is the same. |
761 ;; Emacs 18 doesn't have this argument. | 765 ;; Emacs 18 doesn't have this argument. |
762 (defun tcl-mark () | 766 (defun tcl-mark () |
763 "Return mark, or nil if none." | 767 "Return mark, or nil if none." |
764 (if tcl-using-emacs-19 | 768 (if tcl-using-emacs-19 |
765 (mark t) | 769 (mark t) |
894 (setq imenu-create-index-function 'tcl-imenu-create-index-function) | 898 (setq imenu-create-index-function 'tcl-imenu-create-index-function) |
895 (make-local-variable 'parse-sexp-ignore-comments) | 899 (make-local-variable 'parse-sexp-ignore-comments) |
896 | 900 |
897 (if tcl-using-emacs-19 | 901 (if tcl-using-emacs-19 |
898 (progn | 902 (progn |
899 ;; This can only be set to t in Emacs 19 and Lucid Emacs. | 903 ;; This can only be set to t in Emacs 19 and XEmacs. |
900 ;; Emacs 18 and Epoch lose. | 904 ;; Emacs 18 and Epoch lose. |
901 (setq parse-sexp-ignore-comments t) | 905 (setq parse-sexp-ignore-comments t) |
902 ;; Lucid Emacs has defun-prompt-regexp, but I don't believe | 906 ;; XEmacs has defun-prompt-regexp, but I don't believe |
903 ;; that it works for end-of-defun -- only for | 907 ;; that it works for end-of-defun -- only for |
904 ;; beginning-of-defun. | 908 ;; beginning-of-defun. |
905 (make-local-variable 'defun-prompt-regexp) | 909 (make-local-variable 'defun-prompt-regexp) |
906 (setq defun-prompt-regexp tcl-omit-ws-regexp) | 910 (setq defun-prompt-regexp tcl-omit-ws-regexp) |
907 ;; The following doesn't work in Lucid Emacs 19.6, but maybe | 911 ;; The following doesn't work in Lucid Emacs 19.6, but maybe |
908 ;; it will appear in later versions. | 912 ;; it will appear in later versions. |
909 (make-local-variable 'add-log-current-defun-function) | 913 (make-local-variable 'add-log-current-defun-function) |
910 (setq add-log-current-defun-function 'add-log-tcl-defun)) | 914 (setq add-log-current-defun-function 'add-log-tcl-defun)) |
911 (setq parse-sexp-ignore-comments nil)) | 915 (setq parse-sexp-ignore-comments nil)) |
912 | 916 |
913 ;; Put Tcl menu into menubar for Lucid Emacs. This happens | 917 ;; Put Tcl menu into menubar for XEmacs. This happens |
914 ;; automatically for GNU Emacs. | 918 ;; automatically for GNU Emacs. |
915 (if (and tcl-using-lemacs-19 | 919 (if (and tcl-using-xemacs-19 |
916 current-menubar | 920 current-menubar |
917 (not (assoc "Tcl" current-menubar))) | 921 (not (assoc "Tcl" current-menubar))) |
918 (progn | 922 (progn |
919 (set-buffer-menubar (copy-sequence current-menubar)) | 923 (set-buffer-menubar (copy-sequence current-menubar)) |
920 (add-menu nil "Tcl" tcl-lucid-menu))) | 924 (add-menu nil "Tcl" tcl-lucid-menu))) |
925 ;; Append Tcl menu to popup menu for XEmacs. | |
926 (if (and tcl-using-xemacs-19 (not (boundp 'mode-popup-menu))) | |
927 (setq mode-popup-menu tcl-xemacs-menu)) | |
921 | 928 |
922 (run-hooks 'tcl-mode-hook)) | 929 (run-hooks 'tcl-mode-hook)) |
923 | 930 |
924 | 931 |
925 | 932 |
1957 (comment-region beg end -1)) | 1964 (comment-region beg end -1)) |
1958 | 1965 |
1959 | 1966 |
1960 | 1967 |
1961 ;; | 1968 ;; |
1962 ;; Lucid menu support. | 1969 ;; XEmacs menu support. |
1963 ;; Taken from schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid), | 1970 ;; Taken from schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid), |
1964 ;; who wrote a different Tcl mode. | 1971 ;; who wrote a different Tcl mode. |
1965 ;; We also have support for menus in FSF. We do this by | 1972 ;; We also have support for menus in FSF. We do this by |
1966 ;; loading the Lucid menu emulation code. | 1973 ;; loading the XEmacs menu emulation code. |
1967 ;; | 1974 ;; |
1968 | 1975 |
1969 (defun tcl-popup-menu (e) | 1976 (defun tcl-popup-menu (e) |
1970 (interactive "@e") | 1977 (interactive "@e") |
1971 (and tcl-using-emacs-19 | 1978 (and tcl-using-emacs-19 |
1972 (not tcl-using-lemacs-19) | 1979 (not tcl-using-xemacs-19) |
1973 (if tcl-using-emacs-19-23 | 1980 (if tcl-using-emacs-19-23 |
1974 (require 'lmenu) | 1981 (require 'lmenu) |
1975 ;; CAVEATS: | 1982 ;; CAVEATS: |
1976 ;; * lmenu.el provides 'menubar, which is bogus. | 1983 ;; * lmenu.el provides 'menubar, which is bogus. |
1977 ;; * lmenu.el causes menubars to be turned on everywhere. | 1984 ;; * lmenu.el causes menubars to be turned on everywhere. |
1978 ;; Doubly bogus! | 1985 ;; Doubly bogus! |
1979 ;; Both of these problems are fixed in Emacs 19.23. People | 1986 ;; Both of these problems are fixed in Emacs 19.23. People |
1980 ;; using an Emacs before that just suffer. | 1987 ;; using an Emacs before that just suffer. |
1981 (require 'menubar "lmenu"))) ;; This is annoying | 1988 (require 'menubar "lmenu"))) ;; This is annoying |
1982 ;; IMHO popup-menu should be autoloaded in FSF Emacs. Oh well. | 1989 ;; IMHO popup-menu should be autoloaded in FSF Emacs. Oh well. |
1983 (popup-menu tcl-lucid-menu)) | 1990 (popup-menu tcl-xemacs-menu)) |
1984 | 1991 |
1985 | 1992 |
1986 | 1993 |
1987 ;; | 1994 ;; |
1988 ;; Quoting and unquoting functions. | 1995 ;; Quoting and unquoting functions. |
2029 tcl-command-switches | 2036 tcl-command-switches |
2030 tcl-prompt-regexp | 2037 tcl-prompt-regexp |
2031 inferior-tcl-source-command | 2038 inferior-tcl-source-command |
2032 tcl-using-emacs-19 | 2039 tcl-using-emacs-19 |
2033 tcl-using-emacs-19-23 | 2040 tcl-using-emacs-19-23 |
2034 tcl-using-lemacs-19 | 2041 tcl-using-xemacs-19 |
2035 tcl-proc-list | 2042 tcl-proc-list |
2036 tcl-proc-regexp | 2043 tcl-proc-regexp |
2037 tcl-typeword-list | 2044 tcl-typeword-list |
2038 tcl-keyword-list | 2045 tcl-keyword-list |
2039 tcl-font-lock-keywords | 2046 tcl-font-lock-keywords |