From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#21871: Emacs Lisp Mode (at least): spurious parens in column 0 don't get bold red highlighting. Date: Mon, 16 May 2016 10:20:02 +0000 Message-ID: <20160516102002.GB2317@acm.fritz.box> References: <20151110163034.GH2626@acm.fritz.box> <20151112185424.38599.qmail@mail.muc.de> <414b75b8-bb45-4640-4742-9f88b9ff5e75@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1463420021 18291 80.91.229.3 (16 May 2016 17:33:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 May 2016 17:33:41 +0000 (UTC) Cc: 21871@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 16 19:33:30 2016 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 1b2MOG-0000IO-Bg for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 May 2016 19:33:12 +0200 Original-Received: from localhost ([::1]:45344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2MOC-00051S-Lb for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 May 2016 13:33:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2MO9-0004yE-9m for bug-gnu-emacs@gnu.org; Mon, 16 May 2016 13:33:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2MO5-0008Cw-RA for bug-gnu-emacs@gnu.org; Mon, 16 May 2016 13:33:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2MO5-0008Cm-OE for bug-gnu-emacs@gnu.org; Mon, 16 May 2016 13:33:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b2MO5-0007Lt-Jn for bug-gnu-emacs@gnu.org; Mon, 16 May 2016 13:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 May 2016 17:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21871 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21871-submit@debbugs.gnu.org id=B21871.146341992728195 (code B ref 21871); Mon, 16 May 2016 17:33:01 +0000 Original-Received: (at 21871) by debbugs.gnu.org; 16 May 2016 17:32:07 +0000 Original-Received: from localhost ([127.0.0.1]:54137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2MND-0007Kf-AP for submit@debbugs.gnu.org; Mon, 16 May 2016 13:32:07 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:55646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2MNC-0007Hk-1J for 21871@debbugs.gnu.org; Mon, 16 May 2016 13:32:06 -0400 Original-Received: (qmail 10532 invoked by uid 3782); 16 May 2016 10:20:03 -0000 Original-Received: from acm.muc.de (p548C61A4.dip0.t-ipconnect.de [84.140.97.164]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 16 May 2016 12:20:03 +0200 Original-Received: (qmail 17390 invoked by uid 1000); 16 May 2016 10:20:02 -0000 Content-Disposition: inline In-Reply-To: <414b75b8-bb45-4640-4742-9f88b9ff5e75@yandex.ru> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:118299 Archived-At: Hello, Dmitry. On Mon, May 16, 2016 at 12:50:54AM +0300, Dmitry Gutov wrote: > On 11/12/2015 08:54 PM, Alan Mackenzie wrote: > > The fix to bug #16247 meant no longer setting syntax-begin-function to a > > non-nil value. This is the condition which used to cause the appropriate > > font-lock-keywords form to get added to lisp-font-lock-keywords-1/2. It > > no longer is. > Looking into this, I'm not sure we still want to highlight them. The > aforementioned bug, now fixed, mirrored the justifications that we give > in the manual and the comments for the highlighting of parens in the 0th > column: > "The convention speeds up many Emacs operations, which would otherwise > have to scan back to the beginning of the buffer to analyze the syntax > of the code." Note this convention is still active. > and > ;; Try to detect when a string or comment contains something that > ;; looks like a defun and would thus confuse font-lock. > We don't have to scan back to the beginning of the buffer, we can use > syntax-ppss (and it's more reliable with bug#16247 fixed). Sorry, this isn't true. The scanning back to BOB is done at the C level, in function back_comment. syntax-ppss isn't suitable for use here (Stefan's view, not merely mine), because syntax-ppss doesn't react to changes in the syntax table, and suchlike. > font-lock doesn't get confused by something looking like a defun inside > a docstring (try it; I wasn't able to get it highlight something wrong). You might be getting confused, here. The scanning back to BOB which is slow doesn't just happen in font lock; it can (and does) happen anywhere. It's just font lock's job to warn the user about this, so that she can correct it by adding in a backslash, for example. Things do get confused, for example see bug #22884, where there was an open paren in column zero in our own C sources. > M-x beginning-of-defun does get confused, though. If *that* is problem > what we want to detect, ..... Not particularly. We want the user to be warned about things potentially going wrong in back_comment, and anything which calls it. The problem we want to fix is the lack of font-lock-warning-face on these parens in column 0. Anything beyond that is not for Emacs 25.1. > .... I think the patch should look like this: > diff --git a/lisp/font-lock.el b/lisp/font-lock.el > index 8ee9f69..eed2766 100644 > --- a/lisp/font-lock.el > +++ b/lisp/font-lock.el > @@ -1786,13 +1786,10 @@ font-lock-compile-keywords > (cons t (cons keywords > (mapcar #'font-lock-compile-keyword keywords)))) > (if (and (not syntactic-keywords) > - (let ((beg-function syntax-begin-function)) > - (or (eq beg-function 'beginning-of-defun) > - (if (symbolp beg-function) > - (get beg-function 'font-lock-syntax-paren-check)))) > - (not beginning-of-defun-function)) > + (not beginning-of-defun-function) > + open-paren-in-column-0-is-defun-start) No. open-paren-in-column-0-is-defun-start is a variable that the user can change at any time. We can't make our font-locking dependent upon what its value was at some time in the past. If open-paren-... belongs anywhere, it's in the form just beyond the end of your patch's text. Do you understand the consequences of taking out the check on syntax-begin-function? (I certainly don't.) It would be good if Stefan could express a view, here. > ;; Try to detect when a string or comment contains something that > - ;; looks like a defun and would thus confuse font-lock. > + ;; looks like a defun and would thus confuse beginning-of-defun. Also no. It's more general than that. I think "would thus confuse Emacs" would be more accurate. > (nconc keywords > `((,(if defun-prompt-regexp > (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(") -- Alan Mackenzie (Nuremberg, Germany).