From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#15251: 24.3.50; do-auto-fill "continues" comment from inside a string Date: Sun, 29 Sep 2013 06:59:17 +0300 Message-ID: <87y56gwa5m.fsf@yandex.ru> References: <87ioyisnjx.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380427218 24735 80.91.229.3 (29 Sep 2013 04:00:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Sep 2013 04:00:18 +0000 (UTC) To: 15251@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 29 06:00:21 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VQ8BA-0001vE-Jg for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 06:00:20 +0200 Original-Received: from localhost ([::1]:43313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ8BA-0001M9-0t for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 00:00:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ8B0-0001Lq-Ic for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 00:00:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQ8Au-00087z-De for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 00:00:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQ8Au-00084m-AC for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 00:00:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VQ8At-0007fP-Az for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 00:00:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Sep 2013 04:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15251 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15251-submit@debbugs.gnu.org id=B15251.138042717229372 (code B ref 15251); Sun, 29 Sep 2013 04:00:03 +0000 Original-Received: (at 15251) by debbugs.gnu.org; 29 Sep 2013 03:59:32 +0000 Original-Received: from localhost ([127.0.0.1]:44196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQ8AN-0007df-6o for submit@debbugs.gnu.org; Sat, 28 Sep 2013 23:59:31 -0400 Original-Received: from mail-ee0-f54.google.com ([74.125.83.54]:62828) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQ8AK-0007dU-RI for 15251@debbugs.gnu.org; Sat, 28 Sep 2013 23:59:29 -0400 Original-Received: by mail-ee0-f54.google.com with SMTP id e53so1996103eek.27 for <15251@debbugs.gnu.org>; Sat, 28 Sep 2013 20:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=5og5txp1Fwe81OtozF/qx0ITFfyPhD6gxqJ9Ro7HY8I=; b=d4PDSWmrFoDzoDaOu6RSX7m8fB1nljyERUJhpW5Ec9oaNpizPnGw6LZ3JPnuMJXIoA MsQJOdw1okpd9eAG1OoonRupTah3c8GIhujlmEh4Ps9LF5JXmpVWoCdT4crf7VE/UspV m71hIfGeWWD5c3G65t+UhsaPrQ7H0pu9/0gcKEr43SRiPi/NwOrTvjhKYxCjjiX9MIYH /rIiBZZqRWIgBB2Bomu7MFNrArdtCEOYX0c3njEDaZ3txA6jxIFk/HoIN1mzVXT7JpZa R8pR7h7Ie6gjRZ1H7GG5ITSOGpB36cmkdDFaRGabxU0WhAEy525eRXNddvbJWYPyhsLo SRzQ== X-Received: by 10.14.45.70 with SMTP id o46mr24866932eeb.19.1380427167519; Sat, 28 Sep 2013 20:59:27 -0700 (PDT) Original-Received: from axl (62-118-214.netrun.cytanet.com.cy. [62.228.118.214]) by mx.google.com with ESMTPSA id h52sm34808768eez.3.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 28 Sep 2013 20:59:26 -0700 (PDT) In-Reply-To: <87ioyisnjx.fsf@yandex.ru> (Dmitry Gutov's message of "Tue, 03 Sep 2013 04:26:26 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78788 Archived-At: Dmitry Gutov writes: > In certain conditions, if I press SPC, and a string on the current line > contains text matching `comment-start-skip', the filling is performed, > and the newly created line starts with a comment. > > Examples (point is at |, fill-column is 70): > > ruby-mode: > > aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa#{}a" a| > > press SPC => > > aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa#{}a" > #a > > js-mode: > > aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//a" aa| > > press SPC => > > aa = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//a" > //aa I've tracked this to misbehaving `comment-beginning'. Since we start outside of string, and the comment char(s) are inside the string on the same line, the check comparing the face at point to `font-lock-string-face' doesn't work. And in ruby-mode's case, since interpolations use a different face, even putting a similar guard to check at `cs' won't help. As I see it, we either have to use `syntax-ppss' here, or trust font-lock. The latter means not skipping other checks even if `comment-end-skip' is defined and doesn't match at point, and also only trusting "let's assume ... if we're on the same line" when font-lock-mode is disabled. How does this change look? Seems to work fine. (As an aside, I'm having hard time understanding which search is supposed to have set the match data used by `(match-end 0)' there. Is it `comment-search-backward'? Or `(looking-at comment-end-skip)'?) === modified file 'lisp/newcomment.el' --- lisp/newcomment.el 2013-06-18 17:57:56 +0000 +++ lisp/newcomment.el 2013-09-29 03:41:18 +0000 @@ -526,12 +526,13 @@ (and ;; For modes where comment-start and comment-end are the same, ;; the search above may have found a `ce' rather than a `cs'. - (or (if comment-end-skip (not (looking-at comment-end-skip))) - ;; Maybe font-lock knows that it's a `cs'? + (if comment-end-skip (not (looking-at comment-end-skip))) + (or ;; Maybe font-lock knows that it's a `cs'? (eq (get-text-property (match-end 0) 'face) 'font-lock-comment-face) - (unless (eq (get-text-property (point) 'face) - 'font-lock-comment-face) + (unless (or (eq (get-text-property (point) 'face) + 'font-lock-comment-face) + font-lock-mode) ;; Let's assume it's a `cs' if we're on the same line. (>= (line-end-position) pt))) ;; Make sure that PT is not past the end of the comment.