unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Alan Mackenzie <acm@muc.de>, 21871@debbugs.gnu.org
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	[thread overview]
Message-ID: <414b75b8-bb45-4640-4742-9f88b9ff5e75@yandex.ru> (raw)
In-Reply-To: <20151112185424.38599.qmail@mail.muc.de>

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(")






  parent reply	other threads:[~2016-05-15 21:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 16:30 bug#21871: Emacs Lisp Mode (at least): spurious parens in column 0 don't get bold red highlighting Alan Mackenzie
     [not found] ` <mailman.2066.1447172952.7904.bug-gnu-emacs@gnu.org>
2015-11-12 12:44   ` Alan Mackenzie
2015-11-12 16:36     ` Glenn Morris
2015-11-12 18:12       ` Alan Mackenzie
     [not found] ` <mailman.2173.1447351928.7904.bug-gnu-emacs@gnu.org>
2015-11-12 18:54   ` Alan Mackenzie
2015-11-12 19:17     ` Eli Zaretskii
2016-05-15 21:50     ` Dmitry Gutov [this message]
2016-05-16 10:20       ` Alan Mackenzie
2016-05-16 13:18         ` Dmitry Gutov
2016-05-16 15:00           ` Andreas Röhler
2016-05-17  9:02           ` Alan Mackenzie
2017-09-02 13:19             ` Eli Zaretskii
2020-04-11 15:00 ` Noam Postavsky
2021-09-19 22:14 ` Stefan Kangas
2021-09-20 17:50   ` Alan Mackenzie
2021-09-21 23:07     ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=414b75b8-bb45-4640-4742-9f88b9ff5e75@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=21871@debbugs.gnu.org \
    --cc=acm@muc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).