summaryrefslogtreecommitdiff
path: root/lisp/newcomment.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-07-18 14:49:48 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-07-18 14:49:48 +0200
commitd2f9295a1fc0416760652b5e22f913c6ca2d80e6 (patch)
tree6cce9def2997fb9a81c8696f04a3920c53470d9e /lisp/newcomment.el
parent5ade22c2f89f85883232875c63fda70bb0a75c0d (diff)
downloademacs-d2f9295a1fc0416760652b5e22f913c6ca2d80e6.tar.gz
Don't shorten comment padding if the padding isn't spaces
* lisp/newcomment.el (comment-padright): Don't shorten non-space padding (bug#6822). (comment-padleft): Ditto.
Diffstat (limited to 'lisp/newcomment.el')
-rw-r--r--lisp/newcomment.el20
1 files changed, 14 insertions, 6 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index a5bfb067954..57a52effd14 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -840,9 +840,13 @@ Ensure that `comment-normalize-vars' has been called before you use this."
(make-string (min comment-padding
(- (match-end 0) (match-end 1)))
?\s)
- (substring comment-padding ;additional right padding
- (min (- (match-end 0) (match-end 1))
- (length comment-padding))))))
+ (if (not (string-match-p "\\`\\s-" comment-padding))
+ ;; If the padding isn't spaces, then don't
+ ;; shorten the padding.
+ comment-padding
+ (substring comment-padding ;additional right padding
+ (min (- (match-end 0) (match-end 1))
+ (length comment-padding)))))))
;; We can only duplicate C if the comment-end has multiple chars
;; or if comments can be nested, else the comment-end `}' would
;; be turned into `}}}' where only the first ends the comment
@@ -876,9 +880,13 @@ Ensure that `comment-normalize-vars' has been called before you use this."
;; Only separate the left pad because we assume there is no right pad.
(string-match "\\`\\s-*" str)
(let ((s (substring str (match-end 0)))
- (pad (concat (substring comment-padding
- (min (- (match-end 0) (match-beginning 0))
- (length comment-padding)))
+ (pad (concat (if (not (string-match-p "\\`\\s-" comment-padding))
+ ;; If the padding isn't spaces, then don't
+ ;; shorten the padding.
+ comment-padding
+ (substring comment-padding
+ (min (- (match-end 0) (match-beginning 0))
+ (length comment-padding))))
(match-string 0 str)))
(c (aref str (match-end 0))) ;the first non-space char of STR
;; We can only duplicate C if the comment-end has multiple chars