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#21871: Emacs Lisp Mode (at least): spurious parens in column 0 don't get bold red highlighting. Date: Mon, 16 May 2016 00:50:54 +0300 Message-ID: <414b75b8-bb45-4640-4742-9f88b9ff5e75@yandex.ru> References: <20151110163034.GH2626@acm.fritz.box> <20151112185424.38599.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1463349144 14975 80.91.229.3 (15 May 2016 21:52:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 May 2016 21:52:24 +0000 (UTC) To: Alan Mackenzie , 21871@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 15 23:52:13 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 1b23xL-0005o9-5S for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 May 2016 23:52:11 +0200 Original-Received: from localhost ([::1]:41552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b23xK-00046i-C1 for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 May 2016 17:52:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b23xH-00040Z-7a for bug-gnu-emacs@gnu.org; Sun, 15 May 2016 17:52:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b23xC-0000ee-Uy for bug-gnu-emacs@gnu.org; Sun, 15 May 2016 17:52:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b23xC-0000ea-QS for bug-gnu-emacs@gnu.org; Sun, 15 May 2016 17:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b23xC-000272-E0 for bug-gnu-emacs@gnu.org; Sun, 15 May 2016 17:52:02 -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, 15 May 2016 21:52:02 +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.14633490658031 (code B ref 21871); Sun, 15 May 2016 21:52:02 +0000 Original-Received: (at 21871) by debbugs.gnu.org; 15 May 2016 21:51:05 +0000 Original-Received: from localhost ([127.0.0.1]:53045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b23wG-00025T-Tt for submit@debbugs.gnu.org; Sun, 15 May 2016 17:51:05 -0400 Original-Received: from mail-wm0-f45.google.com ([74.125.82.45]:37933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b23wE-00024z-Pn for 21871@debbugs.gnu.org; Sun, 15 May 2016 17:51:03 -0400 Original-Received: by mail-wm0-f45.google.com with SMTP id g17so108992066wme.1 for <21871@debbugs.gnu.org>; Sun, 15 May 2016 14:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=5eRg20JKTaSu+NmNg6mHYAT+Oumok0vuuCulKoTwcOg=; b=eExCZpsjDiHQlXuXOxQwrEthJNLNZksDooIsdh1vjctQB+V78gcjKwF2jfcVyuhw7v YyZRelfhzG7Wyu2ijlpW5uR85SqAS7vFftMqem8aX6VsicGyJQVN+MzhAQD8PEwrCm3b D4GV1I2ceiPIBP7EroefMxBS2fNvmzQ2DxCJhkRaqGVp3Fol2eVPEeoaw8AJWc+HziuB k+Ae69M4pzqn/KbK7mhFatcy92s0RJCGftvwudA+G8NGjQQBTCQl9d5KXwifGugdd/4B CAnay1ZxwEgkeBYTN7//L3eAlA17lfXSwak5qpwDRParFN7VTe1UecPSXcRMcJEXVIOq IAMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5eRg20JKTaSu+NmNg6mHYAT+Oumok0vuuCulKoTwcOg=; b=kvFY636RmCbrTQkA9IIlAxgtuvDLTavQtbxeyYsiKwjNr2WDiRWyb7LKT3W7YzTMig D90erVqUul7Q1ksPbYVLX+ngKMC70zSYFnnBnUidLa+p1C883KUujb7mNiZR2JPuqCnr mz2b9iGvq+Hf34UPgcQ8gOFJqfUshJy+e9LAb/M/zhrUkS8ZIexVEmoLi9ooKZI3M/2/ FD7EaUEzN76LhHw11mFd/5N+4WbBe7b7pBaoahPPyRzzz8R2jIo3s/yU7SzERkONbRXo 5aEdIT1XdD9eR00VUke+FL9X2ajEC/LzNPvevtSMLeh/LyZApnHL4nO8lmOnxRpu1gcp Kufw== X-Gm-Message-State: AOPr4FVSe/N2ikAOC3zxO79VvWdkD9nITn5COOTTE4FNkGt/l+o2IOr/XF8avUhB6OVzPA== X-Received: by 10.194.42.69 with SMTP id m5mr26716505wjl.89.1463349057102; Sun, 15 May 2016 14:50:57 -0700 (PDT) Original-Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id m140sm14989349wma.24.2016.05.15.14.50.55 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 May 2016 14:50:56 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1 In-Reply-To: <20151112185424.38599.qmail@mail.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:118269 Archived-At: 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." 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). 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). M-x beginning-of-defun does get confused, though. If *that* is problem what we want to detect, 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) ;; 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. (nconc keywords `((,(if defun-prompt-regexp (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")