diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-19 16:48:59 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-19 16:48:59 -0700 |
commit | 07fcbb558d797272b9f43547da60beda485873a3 (patch) | |
tree | 77d5da14e9f9d9d8b1d877c70c01296fd3893796 /lisp/newcomment.el | |
parent | c9bdeff3e45a7ac84a74a81bb048046f82dddc91 (diff) | |
parent | fb81c8c3adf8633f2f617c82f6019aef630860c7 (diff) | |
download | emacs-07fcbb558d797272b9f43547da60beda485873a3.tar.gz |
Merge remote-tracking branch 'origin/master' into athena/unstable
Diffstat (limited to 'lisp/newcomment.el')
-rw-r--r-- | lisp/newcomment.el | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index ea47eec4fda..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 @@ -1300,7 +1308,11 @@ out." (let ((s (comment-padleft comment-end numarg))) (and s (if (string-match comment-end-skip s) s (comment-padright comment-end)))) - (if multi (comment-padright comment-continue numarg)) + (if multi + (or (comment-padright comment-continue numarg) + ;; `comment-padright' returns nil when + ;; `comment-continue' contains only whitespace + (and (stringp comment-continue) comment-continue))) (if multi (comment-padleft (comment-string-reverse comment-continue) numarg)) block |