GNU bug report logs -
#21871
Emacs Lisp Mode (at least): spurious parens in column 0 don't get bold red highlighting.
Previous Next
Reported by: Alan Mackenzie <acm <at> muc.de>
Date: Tue, 10 Nov 2015 16:29:01 UTC
Severity: normal
Found in versions 24.5, 24.4
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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(")
This bug report was last modified 3 years and 302 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.