Function: comment-quote-nested-default
comment-quote-nested-default is a byte-compiled function defined in
newcomment.el.gz.
Signature
(comment-quote-nested-default CS CE UNP)
Documentation
Quote comment delimiters in the buffer.
It expects to be called with the buffer narrowed to a single comment.
It is used as a default for comment-quote-nested-function.
The arguments CS and CE are strings matching comment starting and ending delimiters respectively.
If UNP is non-nil, comments are unquoted instead.
To quote the delimiters, a \ is inserted after the first character of CS or CE. If CE is a single character it will change CE into !CS.
Source Code
;; Defined in /usr/src/emacs/lisp/newcomment.el.gz
(defun comment-quote-nested-default (cs ce unp)
"Quote comment delimiters in the buffer.
It expects to be called with the buffer narrowed to a single comment.
It is used as a default for `comment-quote-nested-function'.
The arguments CS and CE are strings matching comment starting and
ending delimiters respectively.
If UNP is non-nil, comments are unquoted instead.
To quote the delimiters, a \\ is inserted after the first
character of CS or CE. If CE is a single character it will
change CE into !CS."
(let ((re (concat (comment-quote-re ce unp)
"\\|" (comment-quote-re cs unp))))
(goto-char (point-min))
(while (re-search-forward re nil t)
(goto-char (match-beginning 0))
(forward-char 1)
(if unp (delete-char 1) (insert "\\"))
(when (= (length ce) 1)
;; If the comment-end is a single char, adding a \ after that
;; "first" char won't deactivate it, so we turn such a CE
;; into !CS. I.e. for pascal, we turn } into !{
(if (not unp)
(when (string= (match-string 0) ce)
(replace-match (concat "!" cs) t t))
(when (and (< (point-min) (match-beginning 0))
(string= (buffer-substring (1- (match-beginning 0))
(1- (match-end 0)))
(concat "!" cs)))
(backward-char 2)
(delete-char (- (match-end 0) (match-beginning 0)))
(insert ce)))))))