annotate lisp/tl/tu-comment.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents
children 4b173ad71786
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; tu-comment.el --- a comment out utility for Lisp programs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995,1996 MORIOKA Tomohiko
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6 ;; Created: 1995/10/27
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Version: $Id: tu-comment.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Keywords: comment, Lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;; This file is part of tl (Tiny Library).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; along with this program; see the file COPYING. If not, write to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;; - How to install.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 ;; 1. bytecompile this file and copy it to the apropriate directory.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;; 2. put the following lines to your ~/.emacs:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 ;; (autoload 'comment-sexp "tu-comment" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;; (global-set-key "\C-c\C-q" 'comment-sexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;; - How to use.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;; type `C-c C-q' at the beginning of S-expression you want to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 ;; comment out.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 (defvar comment-sexp-first-line-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 '((emacs-lisp-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 (lisp-interaction-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 (lisp-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44 (scheme-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45 (c-mode . comment-sexp-first-line-method-for-c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 (c++-mode . comment-sexp-middle-line-method-for-c++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 (defvar comment-sexp-middle-line-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 '((emacs-lisp-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 (lisp-interaction-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 (lisp-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 (scheme-mode . comment-sexp-middle-line-method-for-lisp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 (c-mode . comment-sexp-middle-line-method-for-c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 (c++-mode . comment-sexp-middle-line-method-for-c++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 (defvar comment-sexp-last-line-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 '((emacs-lisp-mode . comment-sexp-last-line-method-for-dummy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 (lisp-interaction-mode . comment-sexp-last-line-method-for-dummy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 (lisp-mode . comment-sexp-last-line-method-for-dummy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 (scheme-mode . comment-sexp-last-line-method-for-dummy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 (c-mode . comment-sexp-last-line-method-for-c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (c++-mode . comment-sexp-last-line-method-for-dummy)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 (defun comment-sexp-middle-line-method-for-lisp ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 (insert ";; ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (defun comment-sexp-middle-line-method-for-c++ ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (insert "// ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 (defun comment-sexp-first-line-method-for-c ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (insert "/* ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (defun comment-sexp-middle-line-method-for-c ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (insert " * ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (defun comment-sexp-last-line-method-for-c (c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (while (< 0 c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (insert " ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (setq c (1- c))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 (insert " */")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (defun comment-sexp-last-line-method-for-dummy (c))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 (defun comment-sexp ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (let ((c (current-column))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 (b (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 (e (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 (forward-sexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (narrow-to-region b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (untabify b e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (move-to-column c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (funcall
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (cdr (assq major-mode comment-sexp-first-line-method-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (while (< (point) (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (move-to-column c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 (funcall
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 (cdr (assq major-mode comment-sexp-middle-line-method-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (funcall
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (cdr (assq major-mode comment-sexp-last-line-method-alist)) c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 ;;; tu-comment.el ends here