comparison lisp/progmodes/tcl.el @ 7629:5f634da854fd

Fixed mark-defun for 19.23. More menu fixes.
author Tom Tromey <tromey@redhat.com>
date Sun, 22 May 1994 20:12:44 +0000
parents 6fe5a25c0107
children 9a0846bcbb31
comparison
equal deleted inserted replaced
7628:6fe5a25c0107 7629:5f634da854fd
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.9 $ 9 ;; Version: $Revision: 1.10 $
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/05/22 05:26:51 $|$Revision: 1.9 $|~/modes/tcl.el.Z| 54 ;; $Date: 1994/05/22 20:02:03 $|$Revision: 1.10 $|~/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.10 1994/05/22 20:02:03 tromey
69 ; Fixed bug with M-;.
70 ; Wrote bug-reporting code.
71 ;
68 ; Revision 1.9 1994/05/22 05:26:51 tromey 72 ; Revision 1.9 1994/05/22 05:26:51 tromey
69 ; Fixes for imenu. 73 ; Fixes for imenu.
70 ; 74 ;
71 ; Revision 1.8 1994/05/22 03:38:07 tromey 75 ; Revision 1.8 1994/05/22 03:38:07 tromey
72 ; Fixed menu support. 76 ; Fixed menu support.
183 ;; * Need C-x C-e binding (tcl-eval-last-exp). 187 ;; * Need C-x C-e binding (tcl-eval-last-exp).
184 ;; * Write indent-region function that is faster than indenting each 188 ;; * Write indent-region function that is faster than indenting each
185 ;; line individually. 189 ;; line individually.
186 ;; * tcl-figure-type should stop at "beginning of line" (only ws 190 ;; * tcl-figure-type should stop at "beginning of line" (only ws
187 ;; before point, and no "\" on previous line). (see tcl-real-command-p). 191 ;; before point, and no "\" on previous line). (see tcl-real-command-p).
188 ;; * Fix beginning-of-defun. I believe this will be fully possible in
189 ;; FSF Emacs 19.23
190 ;; * overrides some comint keybindings; fix. 192 ;; * overrides some comint keybindings; fix.
191 ;; * Trailing \ will eat blank lines. Should deal with this. 193 ;; * Trailing \ will eat blank lines. Should deal with this.
192 ;; (this would help catch some potential bugs). 194 ;; (this would help catch some potential bugs).
193 ;; * Inferior should display in half the screen, not the whole screen. 195 ;; * Inferior should display in half the screen, not the whole screen.
194 ;; * Indentation should deal with "switch". 196 ;; * Indentation should deal with "switch".
200 202
201 ;;; Code: 203 ;;; Code:
202 204
203 (require 'comint) 205 (require 'comint)
204 206
205 (defconst tcl-version "$Revision$") 207 (defconst tcl-version "$Revision: 1.10 $")
206 (defconst tcl-maintainer "Tom Tromey <tromey@busco.lanl.gov>") 208 (defconst tcl-maintainer "Tom Tromey <tromey@busco.lanl.gov>")
207 209
208 ;; 210 ;;
209 ;; User variables. 211 ;; User variables.
210 ;; 212 ;;
335 ;; Lucid Emacs menu. 337 ;; Lucid Emacs menu.
336 (defvar tcl-lucid-menu 338 (defvar tcl-lucid-menu
337 '("Tcl" 339 '("Tcl"
338 ["Beginning of function" tcl-beginning-of-defun t] 340 ["Beginning of function" tcl-beginning-of-defun t]
339 ["End of function" tcl-end-of-defun t] 341 ["End of function" tcl-end-of-defun t]
340 ["Mark function" mark-tcl-function t] 342 ["Mark function" tcl-mark-defun t]
341 ["Indent region" indent-region t] 343 ["Indent region" indent-region t]
342 ["Comment region" comment-region t] 344 ["Comment region" comment-region t]
343 ["Uncomment region" tcl-uncomment-region t] 345 ["Uncomment region" tcl-uncomment-region t]
344 "----" 346 "----"
345 ["Show Tcl process buffer" inferior-tcl t] 347 ["Show Tcl process buffer" inferior-tcl t]
353 355
354 ;; GNU Emacs does menus via keymaps. Do it in a function in case we 356 ;; GNU Emacs does menus via keymaps. Do it in a function in case we
355 ;; later decide to add it to inferior Tcl mode as well. 357 ;; later decide to add it to inferior Tcl mode as well.
356 (defun tcl-add-fsf-menu (map) 358 (defun tcl-add-fsf-menu (map)
357 (define-key map [menu-bar] (make-sparse-keymap)) 359 (define-key map [menu-bar] (make-sparse-keymap))
360 ;; This fails in Emacs 19.22 and earlier.
358 (require 'lmenu) 361 (require 'lmenu)
359 (define-key map [menu-bar tcl] 362 (define-key map [menu-bar tcl]
360 (cons "Tcl" (make-lucid-menu-keymap "Tcl" tcl-lucid-menu)))) 363 (cons "Tcl" (make-lucid-menu-keymap "Tcl" (cdr tcl-lucid-menu)))))
361 364
362 (defun tcl-fill-mode-map () 365 (defun tcl-fill-mode-map ()
363 (define-key tcl-mode-map "{" 'tcl-electric-char) 366 (define-key tcl-mode-map "{" 'tcl-electric-char)
364 (define-key tcl-mode-map "}" 'tcl-electric-brace) 367 (define-key tcl-mode-map "}" 'tcl-electric-brace)
365 (define-key tcl-mode-map "[" 'tcl-electric-char) 368 (define-key tcl-mode-map "[" 'tcl-electric-char)
369 ;; FIXME. 372 ;; FIXME.
370 (define-key tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun) 373 (define-key tcl-mode-map "\e\C-a" 'tcl-beginning-of-defun)
371 ;; FIXME. 374 ;; FIXME.
372 (define-key tcl-mode-map "\e\C-e" 'tcl-end-of-defun) 375 (define-key tcl-mode-map "\e\C-e" 'tcl-end-of-defun)
373 ;; FIXME. 376 ;; FIXME.
374 (define-key tcl-mode-map "\e\C-h" 'mark-tcl-function) 377 (define-key tcl-mode-map "\e\C-h" 'tcl-mark-defun)
375 (define-key tcl-mode-map "\e\C-q" 'indent-tcl-exp) 378 (define-key tcl-mode-map "\e\C-q" 'indent-tcl-exp)
376 (define-key tcl-mode-map "\177" 'backward-delete-char-untabify) 379 (define-key tcl-mode-map "\177" 'backward-delete-char-untabify)
377 (define-key tcl-mode-map "\t" 'tcl-indent-command) 380 (define-key tcl-mode-map "\t" 'tcl-indent-command)
378 (define-key tcl-mode-map "\M-;" 'tcl-indent-for-comment) 381 (define-key tcl-mode-map "\M-;" 'tcl-indent-for-comment)
379 (define-key tcl-mode-map "\M-\C-x" 'tcl-eval-defun) 382 (define-key tcl-mode-map "\M-\C-x" 'tcl-eval-defun)
648 (fset 'tcl-beginning-of-defun 651 (fset 'tcl-beginning-of-defun
649 (if tcl-using-emacs-19 652 (if tcl-using-emacs-19
650 'beginning-of-defun 653 'beginning-of-defun
651 'tcl-internal-beginning-of-defun)) 654 'tcl-internal-beginning-of-defun))
652 655
653 ;; Only FSF Emacs 19 works correctly using end-of-defun. Emacs 18 and 656 ;; Ditto end-of-defun.
654 ;; Lucid need our own function.
655 (fset 'tcl-end-of-defun 657 (fset 'tcl-end-of-defun
656 (if (and tcl-using-emacs-19 (not tcl-using-lemacs-19)) 658 (if tcl-using-emacs-19
657 'end-of-defun 659 'end-of-defun
658 'tcl-internal-end-of-defun)) 660 'tcl-internal-end-of-defun))
661
662 ;; Internal mark-defun that is used for losing Emacsen.
663 (defun tcl-internal-mark-defun ()
664 "Put mark at end of Tcl function, point at beginning."
665 (interactive)
666 (push-mark (point))
667 (tcl-end-of-defun)
668 (if tcl-using-emacs-19
669 (push-mark (point) nil t)
670 (push-mark (point)))
671 (tcl-beginning-of-defun)
672 (backward-paragraph))
673
674 ;; In GNU Emacs 19.23 and later, mark-defun works as advertised. I
675 ;; don't know about Lucid Emacs, so for now it and Emacs 18 just lose.
676 (fset 'tcl-mark-defun
677 (if tcl-using-emacs-19.23
678 'mark-defun
679 'tcl-internal-mark-defun))
659 680
660 681
661 682
662 ;; 683 ;;
663 ;; Some helper functions. 684 ;; Some helper functions.
1093 (goto-char containing-sexp)) 1114 (goto-char containing-sexp))
1094 (+ (current-indentation) tcl-indent-level))))))))) 1115 (+ (current-indentation) tcl-indent-level)))))))))
1095 1116
1096 1117
1097 1118
1098 (defun mark-tcl-function ()
1099 "Put mark at end of Tcl function, point at beginning."
1100 (interactive)
1101 (push-mark (point))
1102 (tcl-end-of-defun)
1103 (if tcl-using-emacs-19
1104 (push-mark (point) nil t)
1105 (push-mark (point)))
1106 (tcl-beginning-of-defun)
1107 (backward-paragraph))
1108
1109
1110
1111 (defun indent-tcl-exp () 1119 (defun indent-tcl-exp ()
1112 "Indent each line of the Tcl grouping following point." 1120 "Indent each line of the Tcl grouping following point."
1113 (interactive) 1121 (interactive)
1114 (let ((indent-stack (list nil)) 1122 (let ((indent-stack (list nil))
1115 (contain-stack (list (point))) 1123 (contain-stack (list (point)))