Function: comment-make-extra-lines
comment-make-extra-lines is a byte-compiled function defined in
newcomment.el.gz.
Signature
(comment-make-extra-lines CS CE CCS CCE MIN-INDENT MAX-INDENT &optional BLOCK)
Documentation
Make the leading and trailing extra lines.
This is used for extra-line style (or box style if BLOCK is specified).
Source Code
;; Defined in /usr/src/emacs/lisp/newcomment.el.gz
(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)."
(let ((eindent 0))
(if (not block)
;; Try to match CS and CE's content so they align aesthetically.
(progn
(setq ce (comment-string-strip ce t t))
(when (string-match "\\(.+\\).*\n\\(.*?\\)\\1" (concat ce "\n" cs))
(setq eindent
(max (- (match-end 2) (match-beginning 2) (match-beginning 0))
0))))
;; box comment
(let* ((width (- max-indent min-indent))
(s (concat cs "a=m" cce))
(e (concat ccs "a=m" ce))
(c (if (string-match ".*\\S-\\S-" cs)
(aref cs (1- (match-end 0)))
(if (and (equal comment-end "") (string-match ".*\\S-" cs))
(aref cs (1- (match-end 0))) ?=)))
(re "\\s-*a=m\\s-*")
(_ (string-match re s))
(lcs (length cs))
(fill
(make-string (+ width (- (match-end 0)
(match-beginning 0) lcs 3)) c)))
(setq cs (replace-match fill t t s))
(when (and (not (string-match comment-start-skip cs))
(string-match "a=m" s))
;; The whitespace around CS cannot be ignored: put it back.
(setq re "a=m")
(setq fill (make-string (- width lcs) c))
(setq cs (replace-match fill t t s)))
(string-match re e)
(setq ce (replace-match fill t t e))))
(cons (concat cs "\n" (comment-make-bol-ws min-indent) ccs)
(concat cce "\n" (comment-make-bol-ws (+ min-indent eindent)) ce))))