GNU bug report logs - #28428
comment-search-backward with no comments

Previous Next

Package: emacs;

Reported by: "N. Raghavendra" <raghu <at> hri.res.in>

Date: Mon, 11 Sep 2017 22:38:02 UTC

Severity: normal

Fixed in version 27.1

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: "N. Raghavendra" <raghu <at> hri.res.in>
Cc: 28428 <at> debbugs.gnu.org
Subject: bug#28428: comment-search-backward with no comments
Date: Fri, 22 Sep 2017 12:40:58 -0400
>    (if (not (re-search-backward comment-start-skip limit t))
> -      (unless noerror (error "No comment"))
> +      (progn
> +        (goto-char limit)
> +        (unless noerror (error "No comment")))

That looks fine, thank you.  But I think the simpler patch below works
as well:

    diff --git a/lisp/newcomment.el b/lisp/newcomment.el
    index be6dbe3a4c..e32966e596 100644
    --- a/lisp/newcomment.el
    +++ b/lisp/newcomment.el
    @@ -524,7 +524,7 @@ comment-search-backward
       ;; comment-search-backward is only used to find the comment-column (in
       ;; comment-set-column) and to find the comment-start string (via
       ;; comment-beginning) in indent-new-comment-line, it should be harmless.
    -  (if (not (re-search-backward comment-start-skip limit t))
    +  (if (not (re-search-backward comment-start-skip limit 'move))
           (unless noerror (error "No comment"))
         (beginning-of-line)
         (let* ((end (match-end 0))

I wonder if there's code out there that depends on this behavior, tho,
since AFAIK it's been behaving this way "forever".


        Stefan




This bug report was last modified 7 years and 328 days ago.

Previous Next


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