Mercurial > hg > xemacs-beta
comparison lisp/modes/c-comment.el @ 207:e45d5e7c476e r20-4b2
Import from CVS: tag r20-4b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:03:52 +0200 |
parents | 376386a54a3c |
children |
comparison
equal
deleted
inserted
replaced
206:d3e9274cbc4e | 207:e45d5e7c476e |
---|---|
1 ;;; c-comment.el --- edit C comments | 1 ;;; c-comment.el --- edit C comments |
2 | 2 |
3 ;; Keywords: c | 3 ;; Copyright (C) 1987, 1988, 1989 Kyle E. Jones |
4 | 4 ;; Copyright (C) 1997 Free Software Foundation, Inc. |
5 ;;; Copyright (C) 1987, 1988, 1989 Kyle E. Jones | 5 |
6 ;;; | 6 ;; Author: Kyle Jones <kyle_jones@wonderworks.com> |
7 ;;; Verbatim copies of this file may be freely redistributed. | 7 ;; Maintainer: XEmacs Development Team |
8 ;;; | 8 ;; Keywords: languages |
9 ;;; Modified versions of this file may be redistributed provided that this | 9 |
10 ;;; notice remains unchanged, the file contains prominent notice of | 10 ;; This file is part of XEmacs. |
11 ;;; author and time of modifications, and redistribution of the file | 11 |
12 ;;; is not further restricted in any way. | 12 ;; XEmacs is free software; you can redistribute it and/or modify it |
13 ;;; | 13 ;; under the terms of the GNU General Public License as published by |
14 ;;; This file is distributed `as is', without warranties of any kind. | 14 ;; the Free Software Foundation; either version 2, or (at your option) |
15 ;; any later version. | |
16 | |
17 ;; XEmacs is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with XEmacs; see the file COPYING. If not, write to | |
24 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
15 | 26 |
16 ;;; Synched up with: Not in FSF. | 27 ;;; Synched up with: Not in FSF. |
28 | |
29 ;;; Commentary: | |
30 | |
31 ;; | |
32 ;; Verbatim copies of this file may be freely redistributed. | |
33 ;; | |
34 ;; Modified versions of this file may be redistributed provided that this | |
35 ;; notice remains unchanged, the file contains prominent notice of | |
36 ;; author and time of modifications, and redistribution of the file | |
37 ;; is not further restricted in any way. | |
38 ;; | |
39 ;; This file is distributed `as is', without warranties of any kind. | |
40 | |
41 ;; sb [23-Oct-1997] Put into standard format, fixed an autoload cookie. | |
42 | |
43 ;;; Code: | |
17 | 44 |
18 (provide 'c-comment-edit) | 45 (provide 'c-comment-edit) |
19 | 46 |
20 (defvar c-comment-leader " *" | 47 (defvar c-comment-leader " *" |
21 "*Leader used when rebuilding edited C comments. The value of this variable | 48 "*Leader used when rebuilding edited C comments. The value of this variable |
54 '(goto-char (min (point-max) save-point))))) | 81 '(goto-char (min (point-max) save-point))))) |
55 | 82 |
56 (defmacro marker (pos &optional buffer) | 83 (defmacro marker (pos &optional buffer) |
57 (list 'set-marker '(make-marker) pos buffer)) | 84 (list 'set-marker '(make-marker) pos buffer)) |
58 | 85 |
59 | 86 (defvar c-comment-edit-map nil "Key map for c-comment-edit buffers") |
60 ;;;### autoload | 87 (if c-comment-edit-map |
88 nil | |
89 (setq c-comment-edit-map (make-sparse-keymap)) | |
90 (define-key c-comment-edit-map [(meta control c)] 'c-comment-edit-end) | |
91 (define-key c-comment-edit-map [(control c) (control c)] 'c-comment-edit-end) | |
92 (define-key c-comment-edit-map [(control c) (control ?\])] 'c-comment-edit-abort)) | |
93 | |
94 ;;;###autoload | |
61 (defun c-comment-edit (search-prefix) | 95 (defun c-comment-edit (search-prefix) |
62 "Edit multi-line C comments. | 96 "Edit multi-line C comments. |
63 This command allows the easy editing of a multi-line C comment like this: | 97 This command allows the easy editing of a multi-line C comment like this: |
64 /* | 98 /* |
65 * ... | 99 * ... |
80 current buffer (clipping restrictions apply). | 114 current buffer (clipping restrictions apply). |
81 | 115 |
82 Once located, the comment is copied into a temporary buffer, the comment | 116 Once located, the comment is copied into a temporary buffer, the comment |
83 leaders and delimiters are stripped away and the resulting buffer is | 117 leaders and delimiters are stripped away and the resulting buffer is |
84 selected for editing. The major mode of this buffer is controlled by | 118 selected for editing. The major mode of this buffer is controlled by |
85 the variable `c-comment-edit-mode'. | 119 the variable `c-comment-edit-mode'.\\<c-comment-edit-map> |
86 | 120 |
87 Use \\[c-comment-edit-end] when you have finished editing the comment. The | 121 Use \\[c-comment-edit-end] when you have finished editing the comment. The |
88 comment will be inserted into the original buffer with the appropriate | 122 comment will be inserted into the original buffer with the appropriate |
89 delimiters and indention, replacing the old version of the comment. If | 123 delimiters and indention, replacing the old version of the comment. If |
90 you don't want your edited version of the comment to replace the | 124 you don't want your edited version of the comment to replace the |
155 (goto-char (point-min)) | 189 (goto-char (point-min)) |
156 (if (looking-at "[ \n\t]") | 190 (if (looking-at "[ \n\t]") |
157 (delete-char 1)) | 191 (delete-char 1)) |
158 ;; restore cursor if possible | 192 ;; restore cursor if possible |
159 (goto-char (or marker (point-min))) | 193 (goto-char (or marker (point-min))) |
160 (set-buffer-modified-p nil)) | 194 (set-buffer-modified-p nil) |
195 (use-local-map c-comment-edit-map c-comment-buffer)) | |
161 ;; run user hook, if present. | 196 ;; run user hook, if present. |
162 (if c-comment-edit-hook | 197 (if c-comment-edit-hook |
163 (funcall c-comment-edit-hook)) | 198 (funcall c-comment-edit-hook)) |
164 ;; final admonition | 199 ;; final admonition |
165 (message | 200 (message |
291 (catch 'return-value | 326 (catch 'return-value |
292 (while list | 327 (while list |
293 (if (eq (car (car list)) buffer) | 328 (if (eq (car (car list)) buffer) |
294 (throw 'return-value (car list)) | 329 (throw 'return-value (car list)) |
295 (setq list (cdr list))))))) | 330 (setq list (cdr list))))))) |
296 | 331 |
297 ;; keys; | 332 ;;; c-comment.el ends here |
298 (define-key mode-specific-map "\e" 'c-comment-edit-end) | |
299 (define-key mode-specific-map "\C-]" 'c-comment-edit-abort) | |
300 | |
301 |