summaryrefslogtreecommitdiff
path: root/lisp/newcomment.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2016-01-15 12:32:32 +0000
committerAlan Mackenzie <acm@muc.de>2016-01-15 12:32:32 +0000
commit016b3d5894b8c424eab262aeefc646c6cd03a70a (patch)
tree4a3c57665547fb33192307f82bae4768a3b3da62 /lisp/newcomment.el
parent3ffe81e245d854a694ae1734f1b6a995bdc5e724 (diff)
downloademacs-016b3d5894b8c424eab262aeefc646c6cd03a70a.tar.gz
In comment-dwim with style `extra-line', respect indent-tabs-mode.
This fixes bug #22369. * lisp/newcomment.el (comment-make-bol-ws): New function. (comment-make-extra-lines): Use new function instead of a crude `make-string'.
Diffstat (limited to 'lisp/newcomment.el')
-rw-r--r--lisp/newcomment.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 88ed08d4429..80b52ed9561 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -990,6 +990,14 @@ comment markers."
(goto-char (point-max))))))
(set-marker end nil))
+(defun comment-make-bol-ws (len)
+ "Make a white-space string of width LEN for use at BOL.
+When `indent-tabs-mode' is non-nil, tab characters will be used."
+ (if (and indent-tabs-mode (> tab-width 0))
+ (concat (make-string (/ len tab-width) ?\t)
+ (make-string (% len tab-width) ? ))
+ (make-string len ? )))
+
(defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block)
"Make the leading and trailing extra lines.
This is used for `extra-line' style (or `box' style if BLOCK is specified)."
@@ -1025,8 +1033,8 @@ This is used for `extra-line' style (or `box' style if BLOCK is specified)."
(setq cs (replace-match fill t t s)))
(string-match re e)
(setq ce (replace-match fill t t e))))
- (cons (concat cs "\n" (make-string min-indent ? ) ccs)
- (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce))))
+ (cons (concat cs "\n" (comment-make-bol-ws min-indent) ccs)
+ (concat cce "\n" (comment-make-bol-ws (+ min-indent eindent)) ce))))
(defmacro comment-with-narrowing (beg end &rest body)
"Execute BODY with BEG..END narrowing.