1 ;;; c-comment-edit2.el --- C Comment Edit
3 ;; This file is not part of Emacs
5 ;; Copyright (C) 1987 Kyle Jones
7 ;; Maintainer: Jari Aalto
8 ;; Keywords: extensions
14 ;; This program is free software; you can redistribute it and/or modify it
15 ;; under the terms of the GNU General Public License as published by the Free
16 ;; Software Foundation; either version 2 of the License, or (at your option)
19 ;; This program is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with program; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
29 ;; Visit <http://www.gnu.org/copyleft/gpl.html> for more information
34 ;; .................................................. &t-documentation ...
39 ;; Date: 12 Jan 89 17:36:19 GMT
41 ;; Attached is an enhanced version of the `c-comment-edit' package, last
42 ;; posted sometime in 1987.
44 ;; c-comment-edit is a command that copies a C comment into a
45 ;; temporary buffer for editing under a more suitable major mode
46 ;; (usually text-mode). Once the comment is edited,
47 ;; c-comment-edit-end (normally bound to C-c ESC) replaces the old
48 ;; comment with the edited version, adding comment delimiters and
49 ;; leaders as necessary. c-comment-edit is ideal for large comments
59 ;; o c-comment-edit no longer uses a recursive-edit so multiple
60 ;; c-comment-edit's be running simultaneously.
61 ;; o c-comment-edit will now search forward from point for a comment if
62 ;; point is not within a comment.
63 ;; o c-comment-edit-hook is provided.
64 ;; o Bill Carpenter's c-comment-leader-regexp fixed was incorporated.
71 ;; ......................................................... &t-history ...
74 ;; Mar 03 2001 [jari] 20.7 v1.18 Released
75 ;; - Added ###autoload items.
77 ;; Mar 23 1998 [jari] 19.34 v1.12 Released
78 ;; - Byte compile errors fixed.
80 ;; Aug 11 1997 [jari] 19.28 v1.11 Released
81 ;; - The example setup at the end worked fine, execept if used inside
82 ;; the function. The last line was not adjusted to
84 ;; ***********/ but to *********
87 ;; That is; the last */ was not shifted to the end of line.
88 ;; - corrected the example.
90 ;; Feb 24 1997 [jari] 19.28 v1.10 Released
91 ;; - Rick Flower <flower@ms31.sp.trw.com> reported that c-indent-command
92 ;; wasn't seen by 19.15 byte compiler. Now requires cc-mode.
94 ;; Feb 26 1997 [jari] 19.28 v1.9 Released
95 ;; - Small error in window configuration restore corrected.
97 ;; Dec 11 1996 [jari] 19.28 v1.6-1.8 Released
98 ;; - Some minor byte compilation corrections. Window configuration
99 ;; bug corrected. c-comment-edit-at-point corrected in C++ mode.
101 ;; May 27 1996 [jari] 19.28 v1.5 Released
102 ;; - Added saving/restoring the frame configuration. Previously the
103 ;; window layout was destroyed when the c-comment-edit-end was
104 ;; finished. Now windows are restored as they were.
105 ;; - Made this package 18.xx compatible again.
107 ;; Apr 30 1996 [jari] 19.28 v1.4 Released
108 ;; - Jerome Santini <santini@chambord.univ-orleans.fr> reported problems
109 ;; in 19.30 with the font-lock code. Now the eval-when-compile
110 ;; forms take in effect only if font-lock is not present. This was
112 ;; - Renamed all the rest functions to have prefix "c-comment". This
113 ;; follows the GNU package guidelines.
114 ;; - Added defontifying a comment in separate buffer to get clear look.
116 ;; Oct 14 1995 [jari] 19.28 v1.3 Released
117 ;; - Corrected the LCD entry, that was mistakenly modified.
119 ;; Sep 8 1995 [jari] 19.28 v1.2 NotReleased
120 ;; - Cleaned up the Newsereader headers and presedved only 'date:'
121 ;; of original introduction
122 ;; within-c-comment-p :! renamed to comment-area, more general
123 ;; - Added new function c-comment-edit-at-point. If point is inside of a
124 ;; comment, the comment is edited. Otherwise, a new comment is created
125 ;; at point. [jcolman]
126 ;; - Cleared byte-compiler errors. Added optional parameters to main function
127 ;; c-comment-edit. Main also now returns more gracefully, if comment
128 ;; syntax isn't defined. This really should be made more general..
130 ;; Sep 4 1995 [jari] 19.28 v1.1 NotReleased
131 ;; - Jake Colman <jcolman@j51.com> sent mail asking to crrect some
132 ;; things. Great that I get user feedback!
133 ;; - kill-all-local-variables call removed
134 ;; - renamed c-comment-edit-after-hook --> c-comment-edit-exit-hook
135 ;; and moved it to the end of defun.
136 ;; - The fill-column setting has been adjusted to include "/*" (-2 from the
137 ;; original setting).
138 ;; - When edited comment is inserted back, the colors are gone. This has been
139 ;; corrected to re-fontify the comment if font-lock-mode is on.
140 ;; - Added c-comment-edit-load-hook
142 ;; Apr 28 1995 [jari] 19.28 v0.2 NotReleased
143 ;; - After talking with Kyle directly, he said that I should load
144 ;; this .el with some other name, because he didn't plan to have
145 ;; any enhancement support. He said that I had been among the very
146 ;; few that had ever asked any changes to this module.
147 ;; - On my behalf, since this is almost identical copy of the
148 ;; original, I have no objections that someone else modifies this
149 ;; .el with the "c-comment-edit2.el" -- I do plan to update this if it has
150 ;; errors that are caused by me of course, but right now I don't
151 ;; think it misses anything crucial. Just drop me a note, I love to hear
152 ;; about new improvements.
154 ;; Feb 22 1995 [jari] 19.28 v0.1 NotReleased
155 ;; - I had used this intensively when 18.57 was still around in our
156 ;; envinronment (about 4 moths ago), but when I moved to 19.28
157 ;; I found some incompatibilities in keybindings and I dislike the
158 ;; comment syntax which left first line empty. Now there is variable
159 ;; to configure 1st line layout.
160 ;; - Now ESC ESC terminates in 19 and ESC in 18.
161 ;; - Added few confortable variables
162 ;; * c-comment-edit-bname , c-comment-edit-empty-1-line
163 ;; * c-comment-edit-other-buffer , c-comment-edit-C-buf
164 ;; * c-comment-edit-[bc,ec]
166 ;; * c-comment-edit-end-hook
167 ;; * c-comment-edit-after-hook
169 ;; - touched original code:
171 ;; - there was one problem with this, the hook was too early
172 ;; run compared to kill-local-var, so if you turned on some minor
173 ;; mode, it was effectively lost. --> now the hook runs last.
174 ;; * c-comment-edit-end
175 ;; - Added the new functionality here, many changes, sets global
176 ;; variables + runs hooks
178 ;; - There is an EXAMPLE section at the end of this file which is one of
179 ;; my favourite C/C++ function header. And cleanup function to
180 ;; retain the format after comment has been added too.
184 ;;{{{ setup: bind, hooks
189 (load "c-mode" 'noerr) ;Hm, XEmacs 19.13 lacks this?
190 (eval-when-compile (require 'cl))
192 ;;; .......................................................... &v-bind ...
194 (defvar c-com-mode-map nil "C comment edit map")
198 (setq c-com-mode-map (make-sparse-keymap))
200 (if (string< emacs-version "19")
202 (define-key c-com-mode-map "\C-c\C-c" 'c-comment-edit-end)
203 (define-key c-com-mode-map "\e" 'c-comment-edit-abort))
204 (define-key c-com-mode-map "\C-c\C-c" 'c-comment-edit-end)
205 (define-key c-com-mode-map "\e\e" 'c-comment-edit-abort)))
207 ;;; ......................................................... &v-hooks ...
209 (defvar c-comment-edit-hook nil
210 "*Function to call whenever `c-comment-edit' is used.
211 The function is called just before the `c-comment-edit' function allows you to
212 begin editing the comment.")
214 (defvar c-comment-edit-exit-hook nil
215 "*Enables you to do some cleanup after edit is done, not called
216 if user aborted the action. Buffer is already inserted back when this
219 (defvar c-comment-edit-end-hook nil
220 "*When user has pressed C-c or ESC to complete editing, the
221 Comment prefix lines are drawn. After it has completed drawing,
222 and the buffer is in ready to be inserted back, this hook will be called. ")
224 (defvar c-comment-edit-load-hook nil
225 "*Run when file has been loaded.")
228 ;;{{{ setup: read-only vars
230 ;;; ....................................................... &v-private ...
231 ;;; These are set by funcs, user can check the values in hooks.
233 (defconst c-comment-edit-beg-c nil
234 "After the comment is edited, this variable contains
235 begin MARK of comment.")
237 (defconst c-comment-edit-end-c nil
238 "After the comment is edited, this variable contains
239 end MARK of comment.")
241 (defconst c-comment-edit-bufc nil
242 "After the comment is edited, this variable contains C-code buffer name,
243 where comment edited belonged.")
246 ;;{{{ setup: -- user config
248 ;;; .......................................................... &v-conf ...
250 (defvar c-comment-window-register ?w
251 "*Which register to use to save window configuration.")
254 (defvar c-comment-leader " *"
255 "*Leader used when rebuilding edited C comments. The value of this variable
256 should be a two-character string. Values of \" \", \" *\" and \"**\"
257 produce the comment styles:
264 (defconst c-comment-leader-regexp "^[ ]*\\(\\*\\*\\|\\*\\)?[ ]?"
265 "Regexp used to match C comment leaders.")
267 (defvar c-comment-edit-mode 'text-mode
268 "*Major mode used by `c-comment-edit' when editing C comments.")
270 (defvar c-comment-edit-buffer-alist nil
271 "Assoc list of C buffers and their associated comment buffers.
272 Elements are of the form (C-BUFFER COMMENT-BUFFER COMMENT-START COMMENT-END)
273 COMMENT-START and COMMENT-END are markers in the C-BUFFER.")
275 (defvar c-comment-edit-bname " *C Comment Edit*"
276 "*buffer name to edit the comment")
278 (defvar c-comment-edit-empty-1-line nil
279 "*This determines if the first comment line will be left empty
282 * comment begin, when value is t
286 (defvar c-comment-edit-other-buffer t
287 "*Set to nil if you want to edit in full buffer")
292 ;;; ########################################################## &Macros ###
294 (defmacro c-comment-save-point (&rest body)
295 "Save value of point, evalutes FORMS and restore value of point.
296 If the saved value of point is no longer valid go to (point-max).
297 The variable `save-point' is lambda-bound to the value of point for
298 the duration of this call."
299 (list 'let '((save-point (point)))
300 (list 'unwind-protect
302 '(goto-char (min (point-max) save-point)))))
304 (defmacro c-comment-marker (pos &optional buffer)
305 (list 'set-marker '(make-marker) pos buffer))
309 ;;; ########################################################### &Funcs ###
313 ;;; ----------------------------------------------------------------------
315 (defun c-comment-save-state ()
316 "Save window configuration."
317 (if (fboundp 'point-to-register-compatibility-binding)
319 (symbol-function 'point-to-register-compatibility-binding)
320 c-comment-window-register
323 ;;; ----------------------------------------------------------------------
325 (defun c-comment-restore-state ()
326 "Save window configuration."
327 (if (and c-comment-window-register
328 (get-register c-comment-window-register)
329 (fboundp 'jump-to-register-compatibility-binding))
331 (symbol-function 'jump-to-register-compatibility-binding)
332 c-comment-window-register)))
334 ;;; ----------------------------------------------------------------------
336 (defun c-comment-area (beg end)
337 "Searches area bounds delimited by strings BEG and END.
338 First searches backward, them forward.
341 (beg-point . end-point)
345 (c-comment-save-point
346 (search-backward beg)
350 (if (< (point) pp) (cons p pp) nil))
354 ;;; ----------------------------------------------------------------------
356 (defun c-comment-find-buffer (&optional buffer)
357 (or buffer (setq buffer (current-buffer)))
358 (let ((list c-comment-edit-buffer-alist))
361 (if (eq (nth 1 (car list)) buffer)
362 (throw 'return-value (car list))
363 (setq list (cdr list)))))))
365 ;;; ----------------------------------------------------------------------
367 (defun c-comment-find-c-buffer (&optional buffer)
368 (or buffer (setq buffer (current-buffer)))
369 (let ((list c-comment-edit-buffer-alist))
372 (if (eq (car (car list)) buffer)
373 (throw 'return-value (car list))
374 (setq list (cdr list)))))))
380 ;;; ----------------------------------------------------------------------
381 ;;; 1995-09-07 Jake Colman <jcolman@j51.com> supplied basic code
384 (defun c-comment-edit-at-point ()
385 "Edit C comment at point.
386 If point is inside of a comment, the comment is edited. Otherwise, a new
387 comment is created at point.
390 (let* ((cs comment-start)
393 (when (memq major-mode '(c-mode c++-mode cc-mode))
394 ;; override the comment settings, because C++ has
395 ;; "//" and "" by default and that's not what we want
396 (setq cs "/*" ce "*/"))
398 (if (c-comment-area cs ce)
400 ;; The catch is, that we first create a comment and then
401 ;; pass control to the main.
402 (setq comment (concat cs " " ce))
404 (goto-char (- (point) (length comment))) ;go inside it
406 (c-comment-edit nil))))
408 ;;; ----------------------------------------------------------------------
410 (defun c-comment-edit-end ()
412 C comment is replaced by its edited counterpart in the appropriate C buffer.
413 Indentation will be the same as the original."
415 (let ((tuple (c-comment-find-buffer))
416 (line1-empty c-comment-edit-empty-1-line)
422 (error "Not a c-comment-edit buffer."))
424 (let ((inhibit-quit t)
425 (c-comment-c-buffer (car tuple))
426 (c-comment-buffer (nth 1 tuple))
427 (c-comment-start (nth 2 tuple))
428 (c-comment-end (nth 3 tuple)))
432 ;; rebuild the comment
433 (goto-char (point-min))
435 (if (null line1-empty)
439 (if (string= c-comment-leader " ")
444 (if (not (eolp)) (insert c-comment-leader " ")))
449 (if (and (eq 1 i) (null line1-empty))
451 (insert c-comment-leader (if (eolp) "" " ")))
454 (if (not (char-equal (preceding-char) ?\n))
457 (insert (if (string= c-comment-leader " *") " */" "*/"))
459 ;; indent if necessary
462 (set-buffer c-comment-c-buffer)
463 (goto-char c-comment-start)
465 (goto-char (point-min))
466 (unless (zerop indention)
467 ;; first line is already indented
471 (indent-to indention)
474 (setq edited t) ;Raise the Flag
475 (run-hooks 'c-comment-edit-end-hook)
477 ;; replace the old comment with the new
480 (setq char-count (- (point-max) (point-min)) )
481 (set-buffer c-comment-c-buffer)
483 (delete-region c-comment-start c-comment-end)
484 (goto-char c-comment-start)
486 (insert-buffer c-comment-buffer)
488 ;; save values for possible hook function
490 (setq c-comment-edit-beg-c (marker-position c-comment-start)
491 c-comment-edit-end-c (+ c-comment-edit-beg-c char-count)
492 c-comment-edit-bufc c-comment-c-buffer)
494 ;; The colors vanished, when we deleted that region and inserted
495 ;; new comment into buffer, lets get them back
497 (if (and (featurep 'font-lock)
498 (symbol-value 'font-lock-mode))
500 (symbol-function 'font-lock-fontify-region)
501 c-comment-edit-beg-c c-comment-edit-end-c))))
504 (message "No change.")))
506 ;; .................................................. cond
508 (c-comment-restore-state)
510 ;; switch to the C buffer
512 (if (get-buffer-window c-comment-c-buffer)
513 (select-window (get-buffer-window c-comment-c-buffer))
514 (switch-to-buffer c-comment-c-buffer))
516 ;; delete the window viewing the comment buffer
518 (and (get-buffer-window c-comment-buffer)
519 (delete-window (get-buffer-window c-comment-buffer)))
521 ;; unlink the tuple from c-comment-edit-buffer-alist
523 (setq c-comment-edit-buffer-alist
524 (delq tuple c-comment-edit-buffer-alist))
526 ;; let Emacs reclaim various resources
529 (set-buffer c-comment-buffer)
530 (set-buffer-modified-p nil)
531 (kill-buffer c-comment-buffer))
533 ;; Now kill the markers so that they don't consume resources
535 (set-marker c-comment-start nil)
536 (set-marker c-comment-end nil))
538 (if edited ;only if touched the contents
539 (run-hooks 'c-comment-edit-exit-hook))))
544 ;;; ----------------------------------------------------------------------
546 (defun c-comment-edit-abort ()
547 "Abort a c-comment-edit with no change."
549 (let* ((tuple (c-comment-find-buffer))
550 (c-comment-c-buffer (car tuple))
551 (c-comment-buffer (nth 1 tuple))
552 (c-comment-start (nth 2 tuple))
553 (c-comment-end (nth 3 tuple)))
556 (error "Not a c-comment-edit buffer."))
558 ;; switch to the C buffer
560 (if (get-buffer-window c-comment-c-buffer)
561 (select-window (get-buffer-window c-comment-c-buffer))
562 (switch-to-buffer c-comment-c-buffer))
564 (let ((inhibit-quit t))
566 (set-buffer c-comment-buffer)
567 (set-buffer-modified-p nil)
568 (if c-comment-edit-other-buffer
570 (kill-buffer c-comment-buffer))
571 ;; unlink the tuple from c-comment-edit-buffer-alist
572 (setq c-comment-edit-buffer-alist
573 (delq tuple c-comment-edit-buffer-alist))
574 (set-marker c-comment-start nil)
575 (set-marker c-comment-end nil)
576 (message "Aborted with no change.")
577 (c-comment-restore-state))))
582 ;;; ----------------------------------------------------------------------
585 (defun c-comment-edit (&optional search-prefix com-start com-end)
586 "Edit multi-line C comments.
587 This command allows the easy editing of a multi-line C comment like this:
592 The comment may be indented or flush with the left margin.
594 If point is within a comment, that comment is used. Otherwise the
595 comment to be edited is found by searching forward from point.
597 With one \\[universal-argument] searching starts after moving back one
599 With two \\[universal-argument]'s searching starts at the beginning of the
600 current or proceeding C function.
601 With three \\[universal-argument]'s searching starts at the beginning of the
603 With four \\[universal-argument]'s searching starts at the beginning of the
604 current buffer (clipping restrictions apply).
606 Once located, the comment is copied into a temporary buffer, the comment
607 leaders and delimiters are stripped away and the resulting buffer is
608 selected for editing. The major mode of this buffer is controlled by
609 the variable `c-comment-edit-mode'.
611 Use \\[c-comment-edit-end] when you have finished editing the comment. The
612 comment will be inserted into the original buffer with the appropriate
613 delimiters and indention, replacing the old version of the comment. If
614 you don't want your edited version of the comment to replace the
615 original, use \\[c-comment-edit-abort]."
618 (let ((inhibit-quit t)
619 (bname c-comment-edit-bname)
620 (other-bedit c-comment-edit-other-buffer)
624 c-comment-fill-column
630 ((and com-start com-end) ;don't touch they are set.
633 ((memq major-mode '(c-mode c++-mode cc-mode))
634 ;; override the comment settings, because C++ has
635 ;; "//" and "" by default and that's not what we want
636 (setq cs "/*" ce "*/"))
639 (setq cs (or comment-start
641 (setq ce (or comment-end
644 ;; What was the prefix arg ?
646 (cond ((equal search-prefix '(4))
647 (backward-paragraph))
648 ((equal search-prefix '(16))
651 (backward-paragraph))
652 ((equal search-prefix '(64))
654 ((equal search-prefix '(256))
655 (goto-char (point-min))))
657 (if (and (null search-prefix)
658 (setq tem (c-comment-area cs ce)))
659 (setq c-comment-start (c-comment-marker (car tem))
660 c-comment-end (c-comment-marker (cdr tem)))
663 (c-comment-save-point
665 (setq start (- (point) (length cs)))
670 (concat "No C comment found. Check comment-start: "
673 (setq c-comment-start (c-comment-marker start))
674 (setq c-comment-end (c-comment-marker end))))
676 ;; calculate the correct fill-column for the comment
678 (setq c-comment-fill-column
681 (goto-char c-comment-start)
682 (+ (length comment-start) (current-column)))))
684 ;; create the comment buffer
686 (setq c-comment-buffer
687 (generate-new-buffer (concat (buffer-name) bname)))
689 ;; link into the c-comment-edit-buffer-alist
691 (setq c-comment-edit-buffer-alist
692 (cons (list (current-buffer) c-comment-buffer
693 c-comment-start c-comment-end)
694 c-comment-edit-buffer-alist))
696 ;; copy to the comment to the comment-edit buffer
698 (copy-to-buffer c-comment-buffer
699 (+ c-comment-start 2) (- c-comment-end 2))
701 ;; mark the position of point, relative to the beginning of the
702 ;; comment, in the comment buffer. (if point is within a comment.)
704 (or search-prefix (< (point) c-comment-start)
705 (setq marker (c-comment-marker (+ (- (point) c-comment-start 2) 1)
707 ;; ...............................................................
708 ;; select the comment buffer for editing
710 (c-comment-save-state)
712 (if (null other-bedit)
713 (switch-to-buffer c-comment-buffer)
714 (switch-to-buffer-other-window c-comment-buffer))
716 ;; remove the comment leaders and delimiters
718 (goto-char (point-min))
721 (and (re-search-forward c-comment-leader-regexp nil t)
722 (replace-match "" nil t))
725 ;; run appropriate major mode
727 (funcall (or c-comment-edit-mode 'fundamental-mode))
729 ;; override user's default fill-column here since it will lose if
730 ;; the comment is indented in the C buffer.
732 (setq fill-column c-comment-fill-column)
734 ;; delete one leading whitespace char
736 (goto-char (point-min))
738 (if (looking-at "[ \n\t]")
741 ;; restore cursor if possible
743 (goto-char (or marker (point-min)))
745 ;; defontify to get a clear look at text
747 (put-text-property (point-min) (point-max) 'face 'default)
749 (set-buffer-modified-p nil))
750 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ let end ^^^
752 (use-local-map c-com-mode-map)
753 (run-hooks 'c-comment-edit-hook)
756 (substitute-command-keys
757 (concat "Type \\[c-comment-edit-end] to end edit, "
758 "\\[c-comment-edit-abort] to abort with no change.")))))
760 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ catch end ^^^
765 ;;; ......................................................... &example ...
767 ;; - Here is ready setup, which you could use right away.
768 ;; - I am used to program all my C/C++ function like this, where the
769 ;; header is just before each function:
771 ;; /*************************************************************************
772 ;; * <PUBLIC> FUNCTION: MyFunc
773 ;; *************************************************************************
775 ;; * - This is function is the main entry point to class myClass.
776 ;; * it handles reading the oracle database....
779 ;; * - Note, that the oracle connection must be verified before your're
780 ;; * using this function....
783 ;; * - Creates object errorAtom which hold data about the promlem occurred.
785 ;; *************************************************************************/
786 ;; errorAtom_c *myClass_c::Execute(char * ptr)
792 ;; - In order to maintain the '*****' breaks correctly you have to use some
793 ;; cleanup function like one below. It detects if the Comment has
794 ;; '****' in it and does nothing if it's regular comment.
796 ;; - Remember that when the comment has been edited, the comment style you
797 ;; choosed, affects the function. This supposes you have use the 'one star'
800 ;; Setting proper hooks.
801 ;; I seldom need M-c (capitalize word) in C/C++
802 ;; If you use many hooks, use command add-hook instead.
804 ;; (setq c++-mode-hook 'c++-my-hook)
805 ;; (defun c++-my-hook ()
806 ;; (local-set-key "\M-c" 'c-comment-edit))
808 ;; (setq c-mode-hook 'c-my-hook)
809 ;; (defun c-my-hook ()
810 ;; (local-set-key "\M-c" 'c-comment-edit))
812 ;; (defun my-com-end ()
813 ;; "C- comment edit cleanup."
814 ;; (let* ((sep (make-string 70 ?* )) ;what separator you want to use
815 ;; (fix-re "[-=*] [-=*][-=*]" ) ;the gap " " is in buffer
816 ;; (back-step 3) ;depends on the fix-re
817 ;; (break-re " +[-=*][-=*][-=*]*") ;at least two continuous chars
820 ;; ;; To preserve indentation. Remember that C-comment markers are
821 ;; ;; added to the beginning
823 ;; (untabify (point-min) (point-max))
826 ;; ;; - We are in comment buffer now, so we can move freely with goto-char
827 ;; ;; - fix all break-marked lines to certain length
829 ;; (goto-char (point-min))
830 ;; (while (re-search-forward fix-re nil t)
831 ;; (backward-char back-step) (kill-line) (insert sep))
833 ;; ;; - Check if the last line has separator == it is function header
834 ;; ;; - The last line holds "*/", so look at the previous one.
836 ;; (goto-char (point-max)) (forward-line -1)
839 ;; ((looking-at break-re)
840 ;; ;; Remove that lonely "*/" and shift it one line up
842 ;; (goto-char (point-max)) (beginning-of-line)
844 ;; (backward-delete-char 1)
845 ;; (insert "/"))) ;terminate C comment
846 ;; nil)) ;hook must return this
850 (provide 'c-comment-edit)
851 (run-hooks 'c-comment-edit-load-hook)
853 ;;; c-comment-edit2.el ends here