Function: prolog-comment-limits
prolog-comment-limits is a byte-compiled function defined in
prolog.el.gz.
Signature
(prolog-comment-limits)
Documentation
Return the current comment limits plus the comment type (block or line).
The comment limits are the range of a block comment or the range that contains all adjacent line comments (i.e. all comments that starts in the same column with no empty lines or non-whitespace characters between them).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/prolog.el.gz
;;;; Comment filling
(defun prolog-comment-limits ()
"Return the current comment limits plus the comment type (block or line).
The comment limits are the range of a block comment or the range that
contains all adjacent line comments (i.e. all comments that starts in
the same column with no empty lines or non-whitespace characters
between them)."
(let ((here (point))
lit-limits-b lit-limits-e lit-type beg end
)
(save-restriction
;; Widen to catch comment limits correctly.
(widen)
(setq end (line-end-position)
beg (line-beginning-position))
(save-excursion
(beginning-of-line)
(setq lit-type (if (search-forward-regexp "%" end t) 'line 'block))
; (setq lit-type 'line)
;(if (search-forward-regexp "^[ \t]*%" end t)
; (setq lit-type 'line)
; (if (not (search-forward-regexp "%" end t))
; (setq lit-type 'block)
; (if (not (= (forward-line 1) 0))
; (setq lit-type 'block)
; (setq done t
; ret (prolog-comment-limits)))
; ))
(if (eq lit-type 'block)
(progn
(goto-char here)
(when (looking-at "/\\*") (forward-char 2))
(when (and (looking-at "\\*") (> (point) (point-min))
(forward-char -1) (looking-at "/"))
(forward-char 1))
(when (save-excursion (search-backward "/*" nil t))
(list (save-excursion (search-backward "/*") (point))
(or (search-forward "*/" nil t) (point-max)) lit-type)))
;; line comment
(setq lit-limits-b (- (point) 1)
lit-limits-e end)
(condition-case nil
(if (progn (goto-char lit-limits-b)
(looking-at "%"))
(let ((col (current-column)) done)
(setq beg (point)
end lit-limits-e)
;; Always at the beginning of the comment
;; Go backward now
(beginning-of-line)
(while (and (zerop (setq done (forward-line -1)))
(search-forward-regexp "^[ \t]*%"
(line-end-position) t)
(= (+ 1 col) (current-column)))
(setq beg (- (point) 1)))
(when (= done 0)
(forward-line 1))
;; We may have a line with code above...
(when (and (zerop (setq done (forward-line -1)))
(search-forward "%" (line-end-position) t)
(= (+ 1 col) (current-column)))
(setq beg (- (point) 1)))
(when (= done 0)
(forward-line 1))
;; Go forward
(goto-char lit-limits-b)
(beginning-of-line)
(while (and (zerop (forward-line 1))
(search-forward-regexp "^[ \t]*%"
(line-end-position) t)
(= (+ 1 col) (current-column)))
(setq end (line-end-position)))
(list beg end lit-type))
(list lit-limits-b lit-limits-e lit-type)
)
(error (list lit-limits-b lit-limits-e lit-type))))
))))