GNU bug report logs -
#28428
comment-search-backward with no comments
Previous Next
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
[Message part 1 (text/plain, inline)]
Your bug report
#28428: comment-search-backward with no comments
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 28428 <at> debbugs.gnu.org.
--
28428: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=28428
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Version: 27.1
I pushed the patch to `master`.
Stefan
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
I am using Emacs 26.0.50. In the cases that I tried, when there is no
comment in the portion of the buffer between the search limit and point,
`comment-search-backward' does not move point to the search limit before
raising an error. This behaviour contradicts its docstring. My message
to emacs-devel about this is at
http://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00193.html
Attached are a patch that seems to fix the problem, and a file
containing a test. Running the test without the change in the patch
fails, and passes with the change:
$ git checkout master
$ emacs -Q -batch -l lisp/newcomment.el -l /tmp/test.el \
-f ert-run-tests-batch-and-exit
----------------------------------------------------------------------
(ert-test-failed
((should
(=
(point)
limit))
:form
(= 70 41)
:value nil))
FAILED 1/1 test-comment-search-backward-absent
----------------------------------------------------------------------
$ git checkout test-comment-search-forward-absent
$ emacs -Q -batch -l lisp/newcomment.el -l /tmp/test.el \
-f ert-run-tests-batch-and-exit
----------------------------------------------------------------------
Running 1 tests (2017-09-12 03:31:48+0530)
passed 1/1 test-comment-search-backward-absent
----------------------------------------------------------------------
Raghu.
--
N. Raghavendra <raghu <at> hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
[0001-comment-search-backword-move-point-when-there-is-no-comment.patch (text/x-diff, inline)]
From eb8e32c6fe4a3d08be8b856b3ff4a300a2e69d4b Mon Sep 17 00:00:00 2001
From: "N. Raghavendra" <raghu <at> hri.res.in>
Date: Tue, 12 Sep 2017 01:41:16 +0530
Subject: [PATCH] comment-search-backword: move point when there is no comment
* lisp/newcomment.el (comment-search-backward): Move point to
LIMIT when there is no comment between LIMIT and point.
---
lisp/newcomment.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 8772b523..d849fc1 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -525,7 +525,9 @@ comment-search-backward
;; 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))
- (unless noerror (error "No comment"))
+ (progn
+ (goto-char limit)
+ (unless noerror (error "No comment")))
(beginning-of-line)
(let* ((end (match-end 0))
(cs (comment-search-forward end t))
--
2.7.4
[test.el (application/emacs-lisp, attachment)]
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.