From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Toby Cubitt Newsgroups: gmane.emacs.bugs Subject: bug#41793: `comment-only-p' erroneously flags blank lines as comments Date: Wed, 10 Jun 2020 18:53:31 +0100 Message-ID: <20200610175331.GA23889@bb84> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="20529"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) To: 41793@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 10 20:03:45 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj54j-0005BQ-Gd for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jun 2020 20:03:45 +0200 Original-Received: from localhost ([::1]:56722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jj54i-0000B3-Hf for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jun 2020 14:03:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jj535-00070Y-5Z for bug-gnu-emacs@gnu.org; Wed, 10 Jun 2020 14:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jj534-0001y2-R9 for bug-gnu-emacs@gnu.org; Wed, 10 Jun 2020 14:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jj534-0007Tt-MG for bug-gnu-emacs@gnu.org; Wed, 10 Jun 2020 14:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Toby Cubitt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jun 2020 18:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41793 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159181208628712 (code B ref -1); Wed, 10 Jun 2020 18:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Jun 2020 18:01:26 +0000 Original-Received: from localhost ([127.0.0.1]:35299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj52T-0007T2-UR for submit@debbugs.gnu.org; Wed, 10 Jun 2020 14:01:26 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53022) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj52R-0007Su-Tn for submit@debbugs.gnu.org; Wed, 10 Jun 2020 14:01:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jj52R-00066O-Ln for bug-gnu-emacs@gnu.org; Wed, 10 Jun 2020 14:01:23 -0400 Original-Received: from sanddollar.geekisp.com ([216.168.135.167]:45176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1jj52Q-0001s3-SD for bug-gnu-emacs@gnu.org; Wed, 10 Jun 2020 14:01:23 -0400 Original-Received: (qmail 11990 invoked by uid 1003); 10 Jun 2020 17:54:46 -0000 Original-Received: from bb84.localdomain (localhost.geekisp.com [127.0.0.1]) by localhost.geekisp.com (tmda-ofmipd) with ESMTP; Wed, 10 Jun 2020 13:54:44 -0400 Original-Received: by bb84.localdomain (Postfix, from userid 1000) id 3C2DFC2A4C; Wed, 10 Jun 2020 18:53:31 +0100 (BST) Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.11 (Ladyburn) X-Primary-Address: toby@dr-qubit.org Received-SPF: neutral client-ip=216.168.135.167; envelope-from=tsc25@cantab.net; helo=sanddollar.geekisp.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/10 13:54:40 X-ACL-Warn: Detected OS = OpenBSD 4.x-5.x [fuzzy] X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181821 Archived-At: In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.16) of 2020-04-28 On the following text, with point at | (comment-only-p (point) (1+ (point))) returns t when it should probably return nil: " | test" This impacts commands like `comment-or-uncomment-region'. This is because the current implementation of `comment-only-p' fails to check the return value of (comment-forward): (defun comment-only-p (beg end) "Return non-nil if the text between BEG and END is all comments." (save-excursion (goto-char beg) (comment-forward (point-max)) (<= end (point)))) The correct implementation should probably be: (defun comment-only-p (beg end) "Return non-nil if the text between BEG and END is all comments." (save-excursion (goto-char beg) (and (comment-forward (point-max)) (<= end (point))))) Tested on 26.3, but implementation of `comment-only-p' is unchanged in latest git. Cheers, Toby -- Dr T. S. Cubitt Reader (Associate Professor) in Quantum Information Royal Society University Research Fellow Department of Computer Science University College London email: tsc25@cantab.net web: www.dr-qubit.org