From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#15251: 24.3.50; do-auto-fill "continues" comment from inside a string Date: Sun, 29 Sep 2013 15:12:57 +0200 Message-ID: <52482759.1070804@easy-emacs.de> References: <87ioyisnjx.fsf@yandex.ru> <87y56gwa5m.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1380460339 28109 80.91.229.3 (29 Sep 2013 13:12:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Sep 2013 13:12:19 +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 15:12:22 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 1VQGnN-00029b-GD for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 15:12:21 +0200 Original-Received: from localhost ([::1]:44749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGnN-0000Fo-0J for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 09:12:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGnD-0000CV-Iz for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:12:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQGn4-0002uc-VK for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:12:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGn4-0002uY-RP for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VQGn4-0005Ax-FA for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Sep 2013 13:12:02 +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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.138046026819807 (code B ref -1); Sun, 29 Sep 2013 13:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Sep 2013 13:11:08 +0000 Original-Received: from localhost ([127.0.0.1]:44582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQGmB-00059O-66 for submit@debbugs.gnu.org; Sun, 29 Sep 2013 09:11:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42838) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQGm9-00059G-8x for submit@debbugs.gnu.org; Sun, 29 Sep 2013 09:11:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQGm1-0002PM-SZ for submit@debbugs.gnu.org; Sun, 29 Sep 2013 09:11:04 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGm1-0002PI-Pc for submit@debbugs.gnu.org; Sun, 29 Sep 2013 09:10:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGlv-0008Hs-JT for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:10:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQGlo-0002O0-HM for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:10:51 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.10]:53794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQGlo-0002Ns-7d for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 09:10:44 -0400 Original-Received: from purzel.sitgens (brln-4dba32f8.pool.mediaWays.net [77.186.50.248]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MFE4N-1Vc5HN0idP-00GG5V; Sun, 29 Sep 2013 15:10:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <87y56gwa5m.fsf@yandex.ru> X-Provags-ID: V02:K0:KaOuKHHH+CZwXbEgK8LBLnrVOqww3KdqEuFRh22GgUP F4rR6nwzKiYjBLV+EcT4hQro6V9ewHwSut+infVqSCQeWADI+A 5KQ32pDnVBXbbDHyzbp5IbbidqF02o7y02JNtAfP6CFA/8VnCn DAPAU8lepPYCLdAdg9Lg9circ529Zhd0dIYpYYPLNwmATpwg21 bVD3WYobpPr2058ZrVRI7NOwetQhzFghNH/VB8wDeRoE8SukVo H6hWGfgwm4eF6PF5rIxeL38SIhJg7O05aSW74xH4x4ZrZjfFue k/V7MgtMDwm6FH9Ovq+WBH8dsQHxyKCsWrPGk1pJnuR2crRLfx 3S2fMDNb4G6jvwhu2TKfOnuiaehVjbwvaDOYxp0e8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:78794 Archived-At: Am 29.09.2013 05:59, schrieb Dmitry Gutov: > 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. > > > > > Reading the face for detecting basic things like comment is terrible. What did the author smoke when writing this ;) BTW from my experience jumping to (nth 8 (syntax-ppss)) works well.