]> git.eshelyaron.com Git - emacs.git/commitdiff
(comment-region-default): Don't triple the
authorRichard M. Stallman <rms@gnu.org>
Sat, 22 Dec 2007 18:39:16 +0000 (18:39 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 22 Dec 2007 18:39:16 +0000 (18:39 +0000)
comment starter if the first region line isn't indented enough.

lisp/ChangeLog
lisp/newcomment.el

index 8ced758706b732d450939ac92cd461a884c48b7a..43ee81cf12b39afc7a1e920db123514dbb6199b8 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-22  Richard Stallman  <rms@gnu.org>
+
+       * newcomment.el (comment-region-default): Don't triple the
+       comment starter if the first region line isn't indented enough.
+
 2007-12-21  Martin Rudalics  <rudalics@gmx.at>
 
        * autoinsert.el (auto-insert-alist): Remove nonsensical precision
index 1841b51e3055356d7ae977d66aa9e1a4de889b7b..23a645d2c8c847e3d307d55946a46cffc3e71234 100644 (file)
@@ -1095,16 +1095,22 @@ The strings used as comment starts are built from
      ((< numarg 0) (uncomment-region beg end (- numarg)))
      (t
       (let ((multi-char (/= (string-match "[ \t]*\\'" comment-start) 1))
-           indent)
+           indent triple)
        (if (eq (nth 3 style) 'multi-char)
-           (setq indent multi-char)
+           (save-excursion
+             (goto-char beg)
+             (setq indent multi-char
+                   ;; Triple if we will put the comment starter at the margin
+                   ;; and the first line of the region isn't indented
+                   ;; at least two spaces.
+                   triple (and (not multi-char) (looking-at "\t\\|  "))))
          (setq indent (nth 3 style)))
 
        ;; In Lisp and similar modes with one-character comment starters,
        ;; double it by default if `comment-add' says so.
        ;; If it isn't indented, triple it.
        (if (and (null arg) (not multi-char))
-           (setq numarg (* comment-add (if indent 1 2)))
+           (setq numarg (* comment-add (if triple 2 1)))
          (setq numarg (1- (prefix-numeric-value arg))))
 
        (comment-region-internal