[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logic. |
Date: |
Sat, 7 Aug 2021 09:06:15 -0400 (EDT) |
branch: elpa/go-mode
commit d17d21060b16a77f9ee28ff453e674225acbf1b1
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Improve go-fontify-variables logic.
Previously when go-fontify-variables was nil we would avoid fontifying
variables by swapping in the "default" face instead of
"font-lock-variable-name-face". This worked, but recently I've noticed
it had unintended side effects. Namely it doesn't play well when other
modes (such as vc diff) add overlay faces. The "default" font lock
face overrides the overlay background, so your Go variables look bad
in vc diff buffers.
Fix by instead zeroing out the relevant match data so nothing gets
font locked at all.
Closes: #368 [via git-merge-pr]
---
go-mode.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 6340fa2..1675280 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -411,9 +411,6 @@ For mode=set, all covered lines will have this weight."
st)
"Syntax table for Go mode.")
-(defvar go--default-face 'default
- "A variable to refer to `default' face for use in font lock rules.")
-
(defun go--fontify-type-switch-case-pre ()
"Move point to line following the end of case statement.
@@ -445,7 +442,7 @@ statements."
;; Post-match form that runs after last sub-match.
(go--fontify-param-post)
;; Subexp 1 is the param variable name, if any.
- (1 ,(if go-fontify-variables 'font-lock-variable-name-face
'go--default-face))
+ (1 font-lock-variable-name-face nil t)
;; Subexp 2 is the param type name, if any. We set the LAXMATCH
;; flag to allow optional regex groups.
(2 font-lock-type-face nil t)))
@@ -467,7 +464,7 @@ statements."
;; Match variable names in var decls, constant names in const
;; decls, and type names in type decls.
(go--match-decl
- (1 ,(if go-fontify-variables 'font-lock-variable-name-face
'go--default-face) nil t)
+ (1 font-lock-variable-name-face nil t)
(2 font-lock-constant-face nil t)
(3 font-lock-type-face nil t))
@@ -1439,6 +1436,10 @@ the next comma or to the closing paren."
(while (and (not found-match) (not done))
(if go--fontify-param-has-name
(when (looking-at go--named-param-re)
+ (when (not go-fontify-variables)
+ (let ((md (match-data)))
+ (setf (nth 2 md) nil (nth 3 md) nil)
+ (set-match-data md)))
(setq found-match t))
(when (looking-at go--unnamed-param-re)
(setq found-match t)))
@@ -1546,14 +1547,16 @@ gets highlighted by the font lock keyword."
(let ((md (match-data)))
(cond
((string= decl "var")
- (setf (nth 4 md) nil (nth 5 md) nil (nth 6 md) nil (nth 7 md)
nil))
+ (setf (nth 4 md) nil (nth 5 md) nil (nth 6 md) nil (nth 7 md)
nil)
+ (when (not go-fontify-variables)
+ (setf (nth 2 md) nil (nth 3 md) nil)))
((string= decl "const")
(setf (nth 2 md) nil (nth 3 md) nil (nth 6 md) nil (nth 7 md)
nil))
((string= decl "type")
(setf (nth 2 md) nil (nth 3 md) nil (nth 4 md) nil (nth 5 md)
nil)))
(set-match-data md)))
- (t
+ (go-fontify-variables
(save-match-data
;; Left side of ":=" assignmnet.
(when (looking-at ".*:=")
- [nongnu] elpa/go-mode 592bd4b 440/495: indent: fix various cases with dangling operators, (continued)
- [nongnu] elpa/go-mode 592bd4b 440/495: indent: fix various cases with dangling operators, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 35a5ddc 445/495: indent: fix decl statements with dangling "=", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f9174b2 458/495: Improve go-dot-mod-mode font lock regexp, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 91b37c4 461/495: Disable output during indentation tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d712cf3 470/495: Make yes-or-no-p's PROMPT end in a space, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd2f6d2 467/495: Fix multiline func signature fontification., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b91a6cd 479/495: Fix composite literal key fontification, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 85a20da 482/495: Only fontify ident keys in composite literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 53c76cd 480/495: Speed up slow fontification after unclosed parens., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8bfc70a 484/495: Fix accidental old style backquote comma use., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logic.,
ELPA Syncer <=
- [nongnu] elpa/go-mode 3497434 495/495: Fix fontification of chained map types., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8d1594f 295/495: Automatically detect goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 734d523 488/495: Move some defconsts up to fix compiler warnings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 51f507c 315/495: Complete list of commands in mode docstring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 004575e 330/495: Don't leave godef buffer around, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 409cc64 344/495: cmd/oracle: usability improvements to "describe", "referrers", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d9d47fa 332/495: go.tools/oracle: change -ptalog default to ""., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd236e5 367/495: cmd/guru: emacs: update default-directory, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2db2ff6 333/495: go.tools/oracle: change -pos flag syntax from "file pos-pos" to file:pos-pos., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 17a7d8a 370/495: cmd/guru: emacs: add function for expandiong region, ELPA Syncer, 2021/08/07