From: "N. Raghavendra" <raghu@hri.res.in>
To: 28428@debbugs.gnu.org
Subject: bug#28428: comment-search-backward with no comments
Date: Tue, 12 Sep 2017 04:07:35 +0530 [thread overview]
Message-ID: <87377seua8.fsf@ailuros> (raw)
[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]
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@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-comment-search-backword-move-point-when-there-is-no-comment.patch --]
[-- Type: text/x-diff, Size: 1056 bytes --]
From eb8e32c6fe4a3d08be8b856b3ff4a300a2e69d4b Mon Sep 17 00:00:00 2001
From: "N. Raghavendra" <raghu@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.
---
| 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--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
[-- Attachment #3: test.el --]
[-- Type: application/emacs-lisp, Size: 667 bytes --]
next reply other threads:[~2017-09-11 22:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 22:37 N. Raghavendra [this message]
2017-09-22 16:40 ` bug#28428: comment-search-backward with no comments Stefan Monnier
2017-09-22 17:48 ` N. Raghavendra
2017-09-22 19:26 ` Stefan Monnier
2017-09-22 20:31 ` N. Raghavendra
2017-09-23 21:07 ` Stefan Monnier
2017-09-24 0:26 ` N. Raghavendra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87377seua8.fsf@ailuros \
--to=raghu@hri.res.in \
--cc=28428@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).