annotate lisp/tl/mu-comment.el @ 24:4103f0995bd7 r19-15b95

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