comparison lisp/progmodes/tcl.el @ 12515:33e32dc21948

(tcl-do-fill-paragraph): New function. (tcl-mode): Set up for paragraph filling.
author Tom Tromey <tromey@redhat.com>
date Sun, 09 Jul 1995 21:58:03 +0000
parents 83c518dd26c7
children 2f90abd1c659
comparison
equal deleted inserted replaced
12514:83c518dd26c7 12515:33e32dc21948
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.37 $ 9 ;; Version: $Revision: 1.38 $
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: 1995/07/09 18:52:16 $|$Revision: 1.37 $|~/modes/tcl.el.Z| 54 ;; $Date: 1995/07/09 21:30:32 $|$Revision: 1.38 $|~/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.38 1995/07/09 21:30:32 tromey
69 ;; (tcl-mode): Fixes to 19.29 paragraph variables.
70 ;;
68 ;; Revision 1.37 1995/07/09 18:52:16 tromey 71 ;; Revision 1.37 1995/07/09 18:52:16 tromey
69 ;; (tcl-do-auto-fill): Set fill-prefix. 72 ;; (tcl-do-auto-fill): Set fill-prefix.
70 ;; 73 ;;
71 ;; Revision 1.36 1995/07/09 01:07:57 tromey 74 ;; Revision 1.36 1995/07/09 01:07:57 tromey
72 ;; (tcl-imenu-create-index-function): Work with imenu from Emacs 19.29 75 ;; (tcl-imenu-create-index-function): Work with imenu from Emacs 19.29
320 (if (and (string-match "19\\." emacs-version) 323 (if (and (string-match "19\\." emacs-version)
321 (not (string-match "XEmacs" emacs-version))) 324 (not (string-match "XEmacs" emacs-version)))
322 (require 'imenu)) 325 (require 'imenu))
323 ())) 326 ()))
324 327
325 (defconst tcl-version "$Revision: 1.37 $") 328 (defconst tcl-version "$Revision: 1.38 $")
326 (defconst tcl-maintainer "Tom Tromey <tromey@drip.colorado.edu>") 329 (defconst tcl-maintainer "Tom Tromey <tromey@drip.colorado.edu>")
327 330
328 ;; 331 ;;
329 ;; User variables. 332 ;; User variables.
330 ;; 333 ;;
910 (setq paragraph-separate paragraph-start)) 913 (setq paragraph-separate paragraph-start))
911 (setq paragraph-start (concat "^$\\|" page-delimiter)) 914 (setq paragraph-start (concat "^$\\|" page-delimiter))
912 (setq paragraph-separate paragraph-start)) 915 (setq paragraph-separate paragraph-start))
913 (make-local-variable 'paragraph-ignore-fill-prefix) 916 (make-local-variable 'paragraph-ignore-fill-prefix)
914 (setq paragraph-ignore-fill-prefix t) 917 (setq paragraph-ignore-fill-prefix t)
918 (make-local-variable 'fill-paragraph-function)
919 (setq fill-paragraph-function 'tcl-do-fill-paragraph)
915 920
916 (make-local-variable 'indent-line-function) 921 (make-local-variable 'indent-line-function)
917 (setq indent-line-function 'tcl-indent-line) 922 (setq indent-line-function 'tcl-indent-line)
918 ;; Tcl doesn't require a final newline. 923 ;; Tcl doesn't require a final newline.
919 ;; (make-local-variable 'require-final-newline) 924 ;; (make-local-variable 'require-final-newline)
1658 (if (and tcl-pps-has-arg-6 1663 (if (and tcl-pps-has-arg-6
1659 tcl-use-hairy-comment-detector) 1664 tcl-use-hairy-comment-detector)
1660 (tcl-hairy-in-comment) 1665 (tcl-hairy-in-comment)
1661 (tcl-simple-in-comment))) 1666 (tcl-simple-in-comment)))
1662 1667
1668 (defun tcl-do-fill-paragraph (ignore)
1669 "fill-paragraph function for Tcl mode. Only fills in a comment."
1670 (let (in-comment col where)
1671 (save-excursion
1672 (end-of-line)
1673 (setq in-comment (tcl-in-comment))
1674 (if in-comment
1675 (progn
1676 (setq where (1+ (point)))
1677 (setq col (1- (current-column))))))
1678 (and in-comment
1679 (save-excursion
1680 (back-to-indentation)
1681 (= col (current-column)))
1682 ;; In a comment. Set the fill prefix, and find the paragraph
1683 ;; boundaries by searching for lines that look like
1684 ;; comment-only lines.
1685 (let ((fill-prefix (buffer-substring (progn
1686 (beginning-of-line)
1687 (point))
1688 where))
1689 p-start p-end)
1690 ;; Search backwards.
1691 (save-excursion
1692 (while (looking-at "^[ \t]*#")
1693 (forward-line -1))
1694 (forward-line)
1695 (setq p-start (point)))
1696
1697 ;; Search forwards.
1698 (save-excursion
1699 (while (looking-at "^[ \t]*#")
1700 (forward-line))
1701 (setq p-end (point)))
1702
1703 ;; Narrow and do the fill.
1704 (save-restriction
1705 (narrow-to-region p-start p-end)
1706 (fill-paragraph ignore)))))
1707 t)
1708
1663 (defun tcl-do-auto-fill () 1709 (defun tcl-do-auto-fill ()
1664 "Auto-fill function for Tcl mode. Only auto-fills in a comment." 1710 "Auto-fill function for Tcl mode. Only auto-fills in a comment."
1665 (let ((fill-prefix "# ") 1711 (let ((fill-prefix "# ")
1666 in-comment col) 1712 in-comment col)
1667 (save-excursion 1713 (save-excursion