aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-09-03 01:45:18 +0000
committerStefan Monnier2002-09-03 01:45:18 +0000
commit3674a4a93ffd0ca2fcea0c3766502a5bebba786d (patch)
tree4ee04162a2ffdafc809db8e0c1cfc4a03e7ee4b1
parent6b2e4334c9e227ab16491870b3ff6f61dd848571 (diff)
downloademacs-3674a4a93ffd0ca2fcea0c3766502a5bebba786d.tar.gz
emacs-3674a4a93ffd0ca2fcea0c3766502a5bebba786d.zip
(comment-make-extra-lines): Only use the
dummy `=' char when there's really nothing else. Don't remove spaces if it leads to an incorrect comment.
-rw-r--r--lisp/newcomment.el43
1 files changed, 28 insertions, 15 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 8f7333a3e31..07c4e3a5d74 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -29,6 +29,8 @@
29 29
30;;; Bugs: 30;;; Bugs:
31 31
32;; - boxed comments in Perl are not properly uncommented because they are
33;; uncommented one-line at a time.
32;; - nested comments in sgml-mode are not properly quoted. 34;; - nested comments in sgml-mode are not properly quoted.
33;; - single-char nestable comment-start can only do the "\\s<+" stuff 35;; - single-char nestable comment-start can only do the "\\s<+" stuff
34;; if the corresponding closing marker happens to be right. 36;; if the corresponding closing marker happens to be right.
@@ -43,15 +45,16 @@
43 45
44;;; Todo: 46;;; Todo:
45 47
46;; - quantized steps in comment-alignment 48;; - rebox.el-style refill.
47;; - try to align tail comments 49;; - quantized steps in comment-alignment.
48;; - check what c-comment-line-break-function has to say 50;; - try to align tail comments.
49;; - spill auto-fill of comments onto the end of the next line 51;; - check what c-comment-line-break-function has to say.
52;; - spill auto-fill of comments onto the end of the next line.
50;; - uncomment-region with a consp (for blocks) or somehow make the 53;; - uncomment-region with a consp (for blocks) or somehow make the
51;; deletion of continuation markers less dangerous 54;; deletion of continuation markers less dangerous.
52;; - drop block-comment-<foo> unless it's really used 55;; - drop block-comment-<foo> unless it's really used.
53;; - uncomment-region on a subpart of a comment 56;; - uncomment-region on a subpart of a comment.
54;; - support gnu-style "multi-line with space in continue" 57;; - support gnu-style "multi-line with space in continue".
55;; - somehow allow comment-dwim to use the region even if transient-mark-mode 58;; - somehow allow comment-dwim to use the region even if transient-mark-mode
56;; is not turned on. 59;; is not turned on.
57 60
@@ -706,13 +709,23 @@ This is used for `extra-line' style (or `box' style if BLOCK is specified)."
706 (s (concat cs "a=m" cce)) 709 (s (concat cs "a=m" cce))
707 (e (concat ccs "a=m" ce)) 710 (e (concat ccs "a=m" ce))
708 (c (if (string-match ".*\\S-\\S-" cs) 711 (c (if (string-match ".*\\S-\\S-" cs)
709 (aref cs (1- (match-end 0))) ?=)) 712 (aref cs (1- (match-end 0)))
710 (_ (string-match "\\s-*a=m\\s-*" s)) 713 (if (and (equal comment-end "") (string-match ".*\\S-" cs))
714 (aref cs (1- (match-end 0))) ?=)))
715 (re "\\s-*a=m\\s-*")
716 (_ (string-match re s))
717 (lcs (length cs))
711 (fill 718 (fill
712 (make-string (+ width (- (match-end 0) 719 (make-string (+ width (- (match-end 0)
713 (match-beginning 0) (length cs) 3)) c))) 720 (match-beginning 0) lcs 3)) c)))
714 (setq cs (replace-match fill t t s)) 721 (setq cs (replace-match fill t t s))
715 (string-match "\\s-*a=m\\s-*" e) 722 (when (and (not (string-match comment-start-skip cs))
723 (string-match "a=m" s))
724 ;; The whitespace around CS cannot be ignored: put it back.
725 (setq re "a=m")
726 (setq fill (make-string (- width lcs) c))
727 (setq cs (replace-match fill t t s)))
728 (string-match re e)
716 (setq ce (replace-match fill t t e)))) 729 (setq ce (replace-match fill t t e))))
717 (cons (concat cs "\n" (make-string min-indent ? ) ccs) 730 (cons (concat cs "\n" (make-string min-indent ? ) ccs)
718 (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce)))) 731 (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce))))
@@ -749,7 +762,7 @@ indentation to be kept as it was before narrowing."
749 762
750(defun comment-region-internal (beg end cs ce 763(defun comment-region-internal (beg end cs ce
751 &optional ccs cce block lines indent) 764 &optional ccs cce block lines indent)
752 "Comment region BEG..END. 765 "Comment region BEG .. END.
753CS and CE are the comment start resp end string. 766CS and CE are the comment start resp end string.
754CCS and CCE are the comment continuation strings for the start resp end 767CCS and CCE are the comment continuation strings for the start resp end
755of lines (default to CS and CE). 768of lines (default to CS and CE).
@@ -828,7 +841,7 @@ rather than at left margin."
828;;;###autoload 841;;;###autoload
829(defun comment-region (beg end &optional arg) 842(defun comment-region (beg end &optional arg)
830 "Comment or uncomment each line in the region. 843 "Comment or uncomment each line in the region.
831With just \\[universal-argument] prefix arg, uncomment each line in region BEG..END. 844With just \\[universal-argument] prefix arg, uncomment each line in region BEG .. END.
832Numeric prefix arg ARG means use ARG comment characters. 845Numeric prefix arg ARG means use ARG comment characters.
833If ARG is negative, delete that many comment characters instead. 846If ARG is negative, delete that many comment characters instead.
834By default, comments start at the left margin, are terminated on each line, 847By default, comments start at the left margin, are terminated on each line,
@@ -892,7 +905,7 @@ The strings used as comment starts are built from
892 (nth 3 style)))))) 905 (nth 3 style))))))
893 906
894(defun comment-box (beg end &optional arg) 907(defun comment-box (beg end &optional arg)
895 "Comment out the BEG..END region, putting it inside a box. 908 "Comment out the BEG .. END region, putting it inside a box.
896The numeric prefix ARG specifies how many characters to add to begin- and 909The numeric prefix ARG specifies how many characters to add to begin- and
897end- comment markers additionally to what `comment-add' already specifies." 910end- comment markers additionally to what `comment-add' already specifies."
898 (interactive "*r\np") 911 (interactive "*r\np")