> We could fix this within comment-dwim. I don't think we could because `comment-indent` is also a command. Maybe we could make `comment-dwim` do something more useful than calling `comment-indent` in that case, but that's "another problem". > However, I propose instead to change comment-indent (or possibly > comment-search-forward). +1 > - (let* ((eolpos (line-end-position)) > - (begpos (comment-search-forward eolpos t)) > + (let* ((startpos (comment-search-forward (line-end-position) t)) > + (begpos (or startpos > + ;; If we couldn't find a comment *starting* on > + ;; this line, see if we are already within a > + ;; multiline comment at BOL (bug#78003). > + (and (not continue) > + comment-use-syntax comment-use-global-state > + (let ((st (syntax-ppss (line-beginning-position)))) > + (and (nth 4 st) (< (nth 8 st) (point)) > + (point)))))) > + (multilinep (and (not startpos) begpos)) AFAICT we don't need to check (< (nth 8 st) (point)). Am I missing something? Also, I think the bug will still bite when `comment-insert-comment-function` is set. BTW, the patch looks simple in terms of the diff, but it makes the control flow (which is already not great) even more complicated. How 'bout the one below? Stefan