Mercurial > emacs
comparison lisp/simple.el @ 26356:533da0020196
(comment-region): Strip off white space at end of
comment-start.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 05 Nov 1999 13:36:19 +0000 |
parents | e3e54e862d5f |
children | 285ab8ddc125 |
comparison
equal
deleted
inserted
replaced
26355:81dd65f1709c | 26356:533da0020196 |
---|---|
2788 "Comment or uncomment each line in the region. | 2788 "Comment or uncomment each line in the region. |
2789 With just C-u prefix arg, uncomment each line in region. | 2789 With just C-u prefix arg, uncomment each line in region. |
2790 Numeric prefix arg ARG means use ARG comment characters. | 2790 Numeric prefix arg ARG means use ARG comment characters. |
2791 If ARG is negative, delete that many comment characters instead. | 2791 If ARG is negative, delete that many comment characters instead. |
2792 Comments are terminated on each line, even for syntax in which newline does | 2792 Comments are terminated on each line, even for syntax in which newline does |
2793 not end the comment. Blank lines do not get comments." | 2793 not end the comment. Blank lines do not get comments. |
2794 | |
2795 The strings used as comment starts are build from | |
2796 `comment-start' without trailing spaces and `comment-padding'." | |
2794 ;; if someone wants it to only put a comment-start at the beginning and | 2797 ;; if someone wants it to only put a comment-start at the beginning and |
2795 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x | 2798 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x |
2796 ;; is easy enough. No option is made here for other than commenting | 2799 ;; is easy enough. No option is made here for other than commenting |
2797 ;; every line. | 2800 ;; every line. |
2798 (interactive "*r\nP") | 2801 (interactive "*r\nP") |
2799 (or comment-start (error "No comment syntax is defined")) | 2802 (or comment-start (error "No comment syntax is defined")) |
2800 (if (> beg end) (let (mid) (setq mid beg beg end end mid))) | 2803 (if (> beg end) (let (mid) (setq mid beg beg end end mid))) |
2801 (save-excursion | 2804 (save-excursion |
2802 (save-restriction | 2805 (save-restriction |
2803 (let ((cs comment-start) (ce comment-end) | 2806 (let* ((comment-start |
2804 (cp (when comment-padding | 2807 (substring comment-start 0 |
2805 (make-string comment-padding ? ))) | 2808 (string-match "[ \t]*$" comment-start))) |
2806 numarg) | 2809 (cs comment-start) (ce comment-end) |
2810 (cp (when comment-padding | |
2811 (make-string comment-padding ? ))) | |
2812 numarg) | |
2807 (if (consp arg) (setq numarg t) | 2813 (if (consp arg) (setq numarg t) |
2808 (setq numarg (prefix-numeric-value arg)) | 2814 (setq numarg (prefix-numeric-value arg)) |
2809 ;; For positive arg > 1, replicate the comment delims now, | 2815 ;; For positive arg > 1, replicate the comment delims now, |
2810 ;; then insert the replicated strings just once. | 2816 ;; then insert the replicated strings just once. |
2811 (while (> numarg 1) | 2817 (while (> numarg 1) |