Function: hui-select-comment
hui-select-comment is a byte-compiled function defined in
hui-select.el.
Signature
(hui-select-comment POS)
Documentation
Return rest of line from POS to newline.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-select.el
(defun hui-select-comment (pos)
"Return rest of line from POS to newline."
(setq hui-select-previous 'comment)
(save-excursion
(goto-char pos)
(let ((start-regexp (when (stringp comment-start)
(regexp-quote comment-start)))
(end-regexp (when (stringp comment-end)
(regexp-quote comment-end)))
bolp)
(cond
;; Beginning of a comment
((and (stringp comment-start)
(or (looking-at start-regexp)
(save-excursion
(and (skip-chars-backward comment-start)
(looking-at start-regexp)))))
(skip-chars-backward " \t")
(setq bolp (bolp)
pos (point))
(if (equal comment-end "")
(progn (end-of-line)
(hui-select-set-region pos (point)))
(if (stringp comment-end)
;; Skip over nested comments.
(let ((count 0)
(regexp (concat start-regexp "\\|" end-regexp)))
(catch 'done
(while (re-search-forward regexp nil t)
(if (string-equal (match-string 0) comment-start)
(setq count (1+ count))
;; End comment
(setq count (1- count))
(when (= count 0)
(when (looking-at "[ \t]*[\n\r]")
;; Don't include final newline unless the
;; comment is first thing on its line.
(goto-char (if bolp
(match-end 0)
(1- (match-end 0)))))
(throw 'done (hui-select-set-region
pos (point)))))))))))
;; End of a comment
((and (stringp comment-end)
(not (string-equal comment-end ""))
(or (looking-at end-regexp)
(and (skip-chars-backward comment-end)
(looking-at end-regexp))))
(goto-char (match-end 0))
(when (looking-at "[ \t]*[\n\r]")
(goto-char (match-end 0)))
(setq pos (point))
(skip-chars-forward " \t")
;; Skip over nested comments.
(let ((count 0)
(regexp (concat start-regexp "\\|" end-regexp)))
(catch 'done
(while (re-search-backward regexp nil t)
(if (string-equal (match-string 0) comment-end)
(setq count (1+ count))
;; Begin comment
(setq count (1- count))
(when (= count 0)
(skip-chars-backward " \t")
;; Don't include final newline unless the comment is
;; first thing on its line.
(unless (bolp)
(setq pos (1- pos)))
(throw 'done (hui-select-set-region
(point) pos))))))))))))