emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/go-mode bd2f6d2 467/495: Fix multiline func signature font


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode bd2f6d2 467/495: Fix multiline func signature fontification.
Date: Sat, 7 Aug 2021 09:06:10 -0400 (EDT)

branch: elpa/go-mode
commit bd2f6d21196da95447c330cca7d35fb0a6798b4a
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>

    Fix multiline func signature fontification.
    
    Now that we use the proper anchor mechanism, we can just have the
    "pre" form return the position of the closing param list ")", and set
    font-lock-multiline, and basically that is it.
    
    I thought I was going to have to add something to
    font-lock-extend-region-functions, but that didn't seem necessary. If
    there are further cases of missing fontification we can try adding the
    region extending function for param lists.
    
    Closes: #315 [via git-merge-pr]
---
 go-mode.el                | 21 ++++++++++++++-------
 test/go-font-lock-test.el | 11 ++++++++++-
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 6ac749a..0722769 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1278,7 +1278,15 @@ func foo(i, j int) {}
 "
   (setq go--fontify-param-has-name (eq
                                     (go--parameter-list-type (point-max))
-                                    'present)))
+                                    'present))
+  ;; Return position of closing paren so we process the entire
+  ;; multiline param list.
+  (save-excursion
+    (let ((depth (go-paren-level)))
+      (while (and
+              (re-search-forward ")" nil t)
+              (> (go-paren-level) depth))))
+    (point)))
 
 (defun go--match-param-start (end)
   "Search for the starting of param lists.
@@ -1352,12 +1360,11 @@ the next comma or to the closing paren."
 
 (defun go--search-next-comma (end)
   "Search forward from point for a comma whose nesting level is
-the same as point. If it reaches the end of line or a closing
-parenthesis before a comma, it stops at it. Return non-nil if
-comma was found."
+the same as point. If it reaches a closing parenthesis before a
+comma, it stops at it. Return non-nil if comma was found."
   (let ((orig-level (go-paren-level)))
     (while (and (< (point) end)
-                (or (looking-at-p "[^,)\n]")
+                (or (looking-at-p "[^,)]")
                     (> (go-paren-level) orig-level)))
       (forward-char))
     (when (and (looking-at-p ",")
@@ -1575,8 +1582,8 @@ with goflymake \(see URL 
`https://github.com/dougm/goflymake'), gocode
 \(see URL `https://github.com/dominikh/yasnippet-go')"
 
   ;; Font lock
-  (set (make-local-variable 'font-lock-defaults)
-       '(go--build-font-lock-keywords))
+  (setq font-lock-defaults '(go--build-font-lock-keywords))
+  (setq font-lock-multiline t)
 
   ;; Indentation
   (set (make-local-variable 'indent-line-function) #'go-mode-indent-line)
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index 06845bc..bbe62cf 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -25,7 +25,16 @@
   (should-fontify "KfuncK(VaV ...TintT) { }")
   (should-fontify "KfuncK(VaV ...KinterfaceK{}) { }")
 
-  (should-fontify "KfuncK(KinterfaceK { FfooF() }, TstringT) KinterfaceK{}"))
+  (should-fontify "KfuncK(KinterfaceK { FfooF() }, TstringT) KinterfaceK{}")
+
+  (should-fontify "
+KfuncK FfooF(
+  VaV TcatT, VbV KinterfaceK { FbarkF() },
+  VcV TbananaT,
+) (
+  VwhyV TdothisT,
+  VjustV TstopT,
+) { }"))
 
 (ert-deftest go--fontify-decls ()
   (should-fontify "KvarK VfooV TintT")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]