[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 64d4648: Fix numerical `comment-padding' value
From: |
Lars Ingebrigtsen |
Subject: |
master 64d4648: Fix numerical `comment-padding' value |
Date: |
Thu, 28 Jan 2021 03:57:56 -0500 (EST) |
branch: master
commit 64d464886983378b9fa62a38b31ec6fc996f587b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix numerical `comment-padding' value
* lisp/newcomment.el (comment-padright): Allow using a number for
`comment-padding', like the doc string says (bug#40056).
---
lisp/newcomment.el | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 4216fc1..ea47eec 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -832,12 +832,17 @@ Ensure that `comment-normalize-vars' has been called
before you use this."
(when (and (stringp str) (string-match "\\S-" str))
;; Separate the actual string from any leading/trailing padding
(string-match "\\`\\s-*\\(.*?\\)\\s-*\\'" str)
- (let ((s (match-string 1 str)) ;actual string
+ (let ((s (match-string 1 str)) ;actual string
(lpad (substring str 0 (match-beginning 1))) ;left padding
- (rpad (concat (substring str (match-end 1)) ;original right padding
- (substring comment-padding ;additional right padding
- (min (- (match-end 0) (match-end 1))
- (length comment-padding)))))
+ (rpad (concat
+ (substring str (match-end 1)) ;original right padding
+ (if (numberp comment-padding)
+ (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))))))
;; 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
@@ -852,7 +857,7 @@ Ensure that `comment-normalize-vars' has been called before
you use this."
(concat (mapconcat (lambda (c) (concat (regexp-quote (string c)) "?"))
lpad "") ;padding is not required
(regexp-quote s)
- (when multi "+") ;the last char of S might be repeated
+ (when multi "+") ;the last char of S might be repeated
(mapconcat (lambda (c) (concat (regexp-quote (string c)) "?"))
rpad "")))))) ;padding is not required
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 64d4648: Fix numerical `comment-padding' value,
Lars Ingebrigtsen <=