aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tromey1994-05-22 03:38:07 +0000
committerTom Tromey1994-05-22 03:38:07 +0000
commit9aa88f3e283b1366cdd34dbecb2091400bbd1199 (patch)
tree810a0274185e6340c92f30e3b1df9d11dc95989e
parent1691b32b5923469f1ddd8be7f626d4869f8279b4 (diff)
downloademacs-9aa88f3e283b1366cdd34dbecb2091400bbd1199.tar.gz
emacs-9aa88f3e283b1366cdd34dbecb2091400bbd1199.zip
Fixed menu support.
-rw-r--r--lisp/progmodes/tcl.el174
1 files changed, 96 insertions, 78 deletions
diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index 0ed1029bd49..b86de1402b2 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -6,7 +6,7 @@
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.6 $ 9;; Version: $Revision: 1.7 $
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12 12
@@ -51,7 +51,7 @@
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/04/23 16:23:36 $|$Revision: 1.6 $|~/modes/tcl.el.Z| 54;; $Date: 1994/05/03 01:23:42 $|$Revision: 1.7 $|~/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
@@ -65,6 +65,9 @@
65 65
66;; Change log: 66;; Change log:
67;; $Log: tcl.el,v $ 67;; $Log: tcl.el,v $
68; Revision 1.7 1994/05/03 01:23:42 tromey
69; *** empty log message ***
70;
68; Revision 1.6 1994/04/23 16:23:36 tromey 71; Revision 1.6 1994/04/23 16:23:36 tromey
69; Wrote tcl-indent-for-comment 72; Wrote tcl-indent-for-comment
70; 73;
@@ -187,6 +190,7 @@
187;; common cases). 190;; common cases).
188;; * M-; sometimes fails (try on "if [blah] then {") 191;; * M-; sometimes fails (try on "if [blah] then {")
189;; * `#' shouldn't insert `\#' in string. 192;; * `#' shouldn't insert `\#' in string.
193;; * Add bug-reporting code.
190 194
191 195
192 196
@@ -289,34 +293,6 @@ quoted for Tcl.")
289 293
290(defvar tcl-mode-map () 294(defvar tcl-mode-map ()
291 "Keymap used in Tcl mode.") 295 "Keymap used in Tcl mode.")
292(if tcl-mode-map
293 ()
294 (setq tcl-mode-map (make-sparse-keymap))
295 (define-key tcl-mode-map "{" 'tcl-electric-char)
296 (define-key tcl-mode-map "}" 'tcl-electric-brace)
297 (define-key tcl-mode-map "[" 'tcl-electric-char)
298 (define-key tcl-mode-map "]" 'tcl-electric-char)
299 (define-key tcl-mode-map ";" 'tcl-electric-char)
300 (define-key tcl-mode-map "#" 'tcl-electric-hash)
301 ;; FIXME.
302 (define-key tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun)
303 ;; FIXME.
304 (define-key tcl-mode-map "\e\C-e" 'tcl-end-of-defun)
305 ;; FIXME.
306 (define-key tcl-mode-map "\e\C-h" 'mark-tcl-function)
307 (define-key tcl-mode-map "\e\C-q" 'indent-tcl-exp)
308 (define-key tcl-mode-map "\177" 'backward-delete-char-untabify)
309 (define-key tcl-mode-map "\t" 'tcl-indent-command)
310 (define-key tcl-mode-map "\M-;" 'tcl-indent-for-comment)
311 (define-key tcl-mode-map "\M-\C-x" 'tcl-eval-defun)
312 (and (fboundp 'comment-region)
313 (define-key tcl-mode-map "\C-c\C-c" 'comment-region))
314 (define-key tcl-mode-map "\C-c\C-d" 'tcl-help-on-word)
315 (define-key tcl-mode-map "\C-c\C-e" 'tcl-eval-defun)
316 (define-key tcl-mode-map "\C-c\C-l" 'tcl-load-file)
317 (define-key tcl-mode-map "\C-c\C-p" 'inferior-tcl)
318 (define-key tcl-mode-map "\C-c\C-r" 'tcl-eval-region)
319 (define-key tcl-mode-map "\C-c\C-z" 'switch-to-tcl))
320 296
321(defvar tcl-mode-syntax-table nil 297(defvar tcl-mode-syntax-table nil
322 "Syntax table in use in Tcl-mode buffers.") 298 "Syntax table in use in Tcl-mode buffers.")
@@ -348,21 +324,6 @@ quoted for Tcl.")
348 324
349(defvar inferior-tcl-mode-map nil 325(defvar inferior-tcl-mode-map nil
350 "Keymap used in Inferior Tcl mode.") 326 "Keymap used in Inferior Tcl mode.")
351(if inferior-tcl-mode-map
352 ()
353 ;; FIXME Use keymap inheritance here? FIXME we override comint
354 ;; keybindings here. Maybe someone has a better set?
355 (setq inferior-tcl-mode-map (copy-keymap comint-mode-map))
356 (define-key inferior-tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun)
357 (define-key inferior-tcl-mode-map "\e\C-e" 'tcl-end-of-defun)
358 (define-key inferior-tcl-mode-map "\177" 'backward-delete-char-untabify)
359 (define-key inferior-tcl-mode-map "\M-\C-x" 'tcl-eval-defun)
360 (define-key inferior-tcl-mode-map "\C-c\C-d" 'tcl-help-on-word)
361 (define-key inferior-tcl-mode-map "\C-c\C-e" 'tcl-eval-defun)
362 (define-key inferior-tcl-mode-map "\C-c\C-l" 'tcl-load-file)
363 (define-key inferior-tcl-mode-map "\C-c\C-p" 'inferior-tcl)
364 (define-key inferior-tcl-mode-map "\C-c\C-r" 'tcl-eval-region)
365 (define-key inferior-tcl-mode-map "\C-c\C-z" 'switch-to-tcl))
366 327
367;; Lucid Emacs menu. 328;; Lucid Emacs menu.
368(defvar tcl-lucid-menu 329(defvar tcl-lucid-menu
@@ -380,7 +341,77 @@ quoted for Tcl.")
380 ["Send file to Tcl process" tcl-load-file t] 341 ["Send file to Tcl process" tcl-load-file t]
381 ["Restart Tcl process with file" tcl-restart-with-file t] 342 ["Restart Tcl process with file" tcl-restart-with-file t]
382 "----" 343 "----"
383 ["Tcl help" tcl-help-on-word t])) 344 ["Tcl help" tcl-help-on-word t])
345 "Lucid Emacs menu for Tcl mode.")
346
347;; GNU Emacs does menus via keymaps. Do it in a function in case we
348;; later decide to add it to inferior Tcl mode as well.
349(defun tcl-add-fsf-menu (map)
350 (define-key map [menu-bar] (make-sparse-keymap))
351 (require 'lmenu)
352 (define-key map [menu-bar tcl]
353 (cons "Tcl" (make-lucid-menu-keymap "Tcl" tcl-lucid-menu))))
354
355(defun tcl-fill-mode-map ()
356 (define-key tcl-mode-map "{" 'tcl-electric-char)
357 (define-key tcl-mode-map "}" 'tcl-electric-brace)
358 (define-key tcl-mode-map "[" 'tcl-electric-char)
359 (define-key tcl-mode-map "]" 'tcl-electric-char)
360 (define-key tcl-mode-map ";" 'tcl-electric-char)
361 (define-key tcl-mode-map "#" 'tcl-electric-hash)
362 ;; FIXME.
363 (define-key tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun)
364 ;; FIXME.
365 (define-key tcl-mode-map "\e\C-e" 'tcl-end-of-defun)
366 ;; FIXME.
367 (define-key tcl-mode-map "\e\C-h" 'mark-tcl-function)
368 (define-key tcl-mode-map "\e\C-q" 'indent-tcl-exp)
369 (define-key tcl-mode-map "\177" 'backward-delete-char-untabify)
370 (define-key tcl-mode-map "\t" 'tcl-indent-command)
371 (define-key tcl-mode-map "\M-;" 'tcl-indent-for-comment)
372 (define-key tcl-mode-map "\M-\C-x" 'tcl-eval-defun)
373 (and (fboundp 'comment-region)
374 (define-key tcl-mode-map "\C-c\C-c" 'comment-region))
375 (define-key tcl-mode-map "\C-c\C-d" 'tcl-help-on-word)
376 (define-key tcl-mode-map "\C-c\C-e" 'tcl-eval-defun)
377 (define-key tcl-mode-map "\C-c\C-l" 'tcl-load-file)
378 (define-key tcl-mode-map "\C-c\C-p" 'inferior-tcl)
379 (define-key tcl-mode-map "\C-c\C-r" 'tcl-eval-region)
380 (define-key tcl-mode-map "\C-c\C-z" 'switch-to-tcl)
381
382 ;; Make menus.
383 (if tcl-using-emacs-19
384 (if tcl-using-lemacs-19
385 ;; In Lucid, button 3 seems to be the standard for this.
386 (define-key tcl-mode-map 'button3 'tcl-popup-menu)
387 ;; In FSF 19, there is no standard, so I use shift-button2.
388 (tcl-add-fsf-menu tcl-mode-map)
389 (define-key tcl-mode-map [S-down-mouse-2] 'tcl-popup-menu))))
390
391(defun tcl-fill-inferior-map ()
392 (define-key inferior-tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun)
393 (define-key inferior-tcl-mode-map "\e\C-e" 'tcl-end-of-defun)
394 (define-key inferior-tcl-mode-map "\177" 'backward-delete-char-untabify)
395 (define-key inferior-tcl-mode-map "\M-\C-x" 'tcl-eval-defun)
396 (define-key inferior-tcl-mode-map "\C-c\C-d" 'tcl-help-on-word)
397 (define-key inferior-tcl-mode-map "\C-c\C-e" 'tcl-eval-defun)
398 (define-key inferior-tcl-mode-map "\C-c\C-l" 'tcl-load-file)
399 (define-key inferior-tcl-mode-map "\C-c\C-p" 'inferior-tcl)
400 (define-key inferior-tcl-mode-map "\C-c\C-r" 'tcl-eval-region)
401 (define-key inferior-tcl-mode-map "\C-c\C-z" 'switch-to-tcl))
402
403(if tcl-mode-map
404 ()
405 (setq tcl-mode-map (make-sparse-keymap))
406 (tcl-fill-mode-map))
407
408(if inferior-tcl-mode-map
409 ()
410 ;; FIXME Use keymap inheritance here? FIXME we override comint
411 ;; keybindings here. Maybe someone has a better set?
412 (setq inferior-tcl-mode-map (copy-keymap comint-mode-map))
413 (tcl-fill-inferior-map))
414
384 415
385(defvar inferior-tcl-buffer nil 416(defvar inferior-tcl-buffer nil
386 "*The current inferior-tcl process buffer. 417 "*The current inferior-tcl process buffer.
@@ -429,8 +460,6 @@ Several functions exist which are useful to run from your
429`tcl-mode-hook' (see each function's documentation for more 460`tcl-mode-hook' (see each function's documentation for more
430information): 461information):
431 462
432 tcl-install-menubar
433 Puts a \"Tcl\" menu on the menubar. Doesn't work in Emacs 18.
434 tcl-guess-application 463 tcl-guess-application
435 Guesses a default setting for `tcl-application' based on any 464 Guesses a default setting for `tcl-application' based on any
436 \"#!\" line at the top of the file. 465 \"#!\" line at the top of the file.
@@ -465,7 +494,7 @@ after changing this list.")
465 494
466(defvar tcl-typeword-list 495(defvar tcl-typeword-list
467 '("global" "upvar") 496 '("global" "upvar")
468 "List of Tcl keywords deonting \"type\". Used only for highlighting. 497 "List of Tcl keywords denoting \"type\". Used only for highlighting.
469Call `tcl-set-font-lock-keywords' after changing this list.") 498Call `tcl-set-font-lock-keywords' after changing this list.")
470 499
471;; Generally I've picked control operators to be keywords. 500;; Generally I've picked control operators to be keywords.
@@ -713,17 +742,20 @@ Commands:
713 (setq mode-name "Tcl") 742 (setq mode-name "Tcl")
714 (setq local-abbrev-table tcl-mode-abbrev-table) 743 (setq local-abbrev-table tcl-mode-abbrev-table)
715 (set-syntax-table tcl-mode-syntax-table) 744 (set-syntax-table tcl-mode-syntax-table)
745
716 (make-local-variable 'paragraph-start) 746 (make-local-variable 'paragraph-start)
717 (setq paragraph-start (concat "^$\\|" page-delimiter)) 747 (setq paragraph-start (concat "^$\\|" page-delimiter))
718 (make-local-variable 'paragraph-separate) 748 (make-local-variable 'paragraph-separate)
719 (setq paragraph-separate paragraph-start) 749 (setq paragraph-separate paragraph-start)
720 (make-local-variable 'paragraph-ignore-fill-prefix) 750 (make-local-variable 'paragraph-ignore-fill-prefix)
721 (setq paragraph-ignore-fill-prefix t) 751 (setq paragraph-ignore-fill-prefix t)
752
722 (make-local-variable 'indent-line-function) 753 (make-local-variable 'indent-line-function)
723 (setq indent-line-function 'tcl-indent-line) 754 (setq indent-line-function 'tcl-indent-line)
724 ;; Tcl doesn't require a final newline. 755 ;; Tcl doesn't require a final newline.
725 ;; (make-local-variable 'require-final-newline) 756 ;; (make-local-variable 'require-final-newline)
726 ;; (setq require-final-newline t) 757 ;; (setq require-final-newline t)
758
727 (make-local-variable 'comment-start) 759 (make-local-variable 'comment-start)
728 (setq comment-start "# ") 760 (setq comment-start "# ")
729 (make-local-variable 'comment-start-skip) 761 (make-local-variable 'comment-start-skip)
@@ -732,10 +764,12 @@ Commands:
732 (setq comment-column 40) 764 (setq comment-column 40)
733 (make-local-variable 'comment-end) 765 (make-local-variable 'comment-end)
734 (setq comment-end "") 766 (setq comment-end "")
767
735 (make-local-variable 'font-lock-keywords) 768 (make-local-variable 'font-lock-keywords)
736 (setq font-lock-keywords tcl-font-lock-keywords) 769 (setq font-lock-keywords tcl-font-lock-keywords)
737 (setq imenu-create-index-function 'tcl-imenu-create-index-function) 770 (setq imenu-create-index-function 'tcl-imenu-create-index-function)
738 (make-local-variable 'parse-sexp-ignore-comments) 771 (make-local-variable 'parse-sexp-ignore-comments)
772
739 (if tcl-using-emacs-19 773 (if tcl-using-emacs-19
740 (progn 774 (progn
741 ;; This can only be set to t in Emacs 19 and Lucid Emacs. 775 ;; This can only be set to t in Emacs 19 and Lucid Emacs.
@@ -751,6 +785,16 @@ Commands:
751 (make-local-variable 'add-log-current-defun-function) 785 (make-local-variable 'add-log-current-defun-function)
752 (setq add-log-current-defun-function 'add-log-tcl-defun)) 786 (setq add-log-current-defun-function 'add-log-tcl-defun))
753 (setq parse-sexp-ignore-comments nil)) 787 (setq parse-sexp-ignore-comments nil))
788
789 ;; Put Tcl menu into menubar for Lucid Emacs. This happens
790 ;; automatically for GNU Emacs.
791 (if (and tcl-using-lemacs-19
792 current-menubar
793 (not (assoc "Tcl" current-menubar)))
794 (progn
795 (set-buffer-menubar (copy-sequence current-menubar))
796 (add-menu nil "Tcl" tcl-lucid-menu)))
797
754 (run-hooks 'tcl-mode-hook)) 798 (run-hooks 'tcl-mode-hook))
755 799
756 800
@@ -1797,37 +1841,12 @@ The first line is assumed to look like \"#!.../program ...\"."
1797;; Lucid menu support. 1841;; Lucid menu support.
1798;; Taken from schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid), 1842;; Taken from schmid@fb3-s7.math.TU-Berlin.DE (Gregor Schmid),
1799;; who wrote a different Tcl mode. 1843;; who wrote a different Tcl mode.
1800;; We also have simple support for menus in FSF. We do this by 1844;; We also have support for menus in FSF. We do this by
1801;; loading the Lucid menu emulation code. 1845;; loading the Lucid menu emulation code.
1802;; 1846;;
1803 1847
1804;; Put this into your tcl-mode-hook.
1805(defun tcl-install-menubar ()
1806 (and tcl-using-emacs-19
1807 (not tcl-using-lemacs-19)
1808 (if tcl-using-emacs-19.23
1809 (require 'lmenu)
1810 ;; CAVEATS:
1811 ;; * lmenu.el provides 'menubar, which is bogus.
1812 ;; * lmenu.el causes menubars to be turned on everywhere.
1813 ;; Doubly bogus!
1814 ;; Both of these problems are fixed in Emacs 19.23. People
1815 ;; using an Emacs before that just suffer.
1816 (require 'menubar "lmenu")))
1817 (if (not (assoc "Tcl" current-menubar))
1818 (progn
1819 (set-buffer-menubar (copy-sequence current-menubar))
1820 (add-menu nil "Tcl" (cdr tcl-lucid-menu))))
1821 ;; You might want to do something like the below. I have it
1822 ;; commented out because it overrides existing bindings.
1823 ;; For Lucid:
1824 ;; (define-key tcl-mode-map 'button3 'tcl-popup-menu)
1825 ;; For FSF:
1826 ;; (define-key tcl-mode-map [down-mouse-3] 'tcl-popup-menu)
1827 )
1828
1829(defun tcl-popup-menu (e) 1848(defun tcl-popup-menu (e)
1830 (interactive "e") 1849 (interactive "@e")
1831 (and tcl-using-emacs-19 1850 (and tcl-using-emacs-19
1832 (not tcl-using-lemacs-19) 1851 (not tcl-using-lemacs-19)
1833 (if tcl-using-emacs-19.23 1852 (if tcl-using-emacs-19.23
@@ -1839,8 +1858,7 @@ The first line is assumed to look like \"#!.../program ...\"."
1839 ;; Both of these problems are fixed in Emacs 19.23. People 1858 ;; Both of these problems are fixed in Emacs 19.23. People
1840 ;; using an Emacs before that just suffer. 1859 ;; using an Emacs before that just suffer.
1841 (require 'menubar "lmenu"))) ;; This is annoying 1860 (require 'menubar "lmenu"))) ;; This is annoying
1842 ;;(mouse-set-point e) 1861 ;; IMHO popup-menu should be autoloaded in FSF Emacs. Oh well.
1843 ;; IMHO popup-menu should be autoloaded. Oh well.
1844 (popup-menu tcl-lucid-menu)) 1862 (popup-menu tcl-lucid-menu))
1845 1863
1846 1864