GNU bug report logs - #66670
[PATCH] Use buffer-local comment-continue in comment-indent-new-line

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Sat, 21 Oct 2023 20:10:02 UTC

Severity: normal

Tags: patch

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: bug-gnu-emacs <at> gnu.org, Stefan Monnier <monnier <at> gnu.org>
Subject: Re: [PATCH] Use buffer-local comment-continue in
 comment-indent-new-line
Date: Sat, 21 Oct 2023 17:23:35 -0400
>                       ;; Recreate comment-continue from comment-start.
> -                     ;; FIXME: wrong if comment-continue was set explicitly!
>                       ;; FIXME: use prev line's continuation if available.
> -                     (comment-continue nil))
> +                     (comment-continue (if (local-variable-p 'comment-continue)
> +                                           comment-continue
> +                                         nil)))

Are you sure?  `comment-continue` is very rarely set globally.
Usually it's set buffer-locally by `comment-normalize-vars`.

> +(ert-deftest local-comment-continue-in-comment-indent-new-line ()
> +  (with-temp-buffer
> +    (setq-local comment-start "/* ")
> +    (setq-local comment-end "*/")
                               ^^
Out of symmetry, I'd have expected a SPC here.

> +    (insert "foo")
> +    (newline)
> +    (insert "bar")
> +    (forward-line -1)
> +    (end-of-line)
> +    (comment-region (point-min) (point-max))
> +    (should (equal (thing-at-point 'line) "/* foo\n"))
> +    (comment-indent-new-line)

You should also test it with that very same comment but when
`comment-start` and `comment-end` have been set to something like
"// " and "".


        Stefan





This bug report was last modified 144 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.