Dynamic comment prefix generator

Heime <[email protected]> Wed, 01 Jul 2026 12:35:42 +0000
Newsgroups gmane.emacs.help
Message-ID <tjKIiEgO9DD8bkd7a5102AHv426IVFqOf9TUHtJuQ45pyCSMFSjtxI_rLRr8FrJJG6iZPOS8R5si0rqTjuL4K8Sux7geTDn_KbbH4R660T8=@protonmail.com>
This code constructs a list of pairs, where each pair consists 
of a formatted string prefix and a corresponding number. For 
example, (klevels ";;;" 2) produces ((";;; <1>" . 1) (";;; <2>" . 2)

(defun klevels (prefix n)
  (cl-loop for i from 1 to n
            collect (cons (format "%s %s%d%s" prefix "<" i ">") i)))

To make the prefix dynamically based on the major mode's comment 
character.  For single character comment strings, I want to repeat 
it three times.
comment declarations.