mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Fix numerical `comment-padding' value
* lisp/newcomment.el (comment-padright): Allow using a number for `comment-padding', like the doc string says (bug#40056).
This commit is contained in:
parent
8992f8abf3
commit
64d4648869
1 changed files with 11 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue