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

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

[nongnu] elpa/go-mode fa29aea 265/495: go-goto-method-receiver: handle a


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode fa29aea 265/495: go-goto-method-receiver: handle anonymous functions
Date: Sat, 7 Aug 2021 09:05:28 -0400 (EDT)

branch: elpa/go-mode
commit fa29aea1dde1ddf21c8abf2c63938e6f30c2c9f9
Author: Lowe Thiderman <lowe.thiderman@gmail.com>
Commit: Dominik Honnef <dominik@honnef.co>

    go-goto-method-receiver: handle anonymous functions
---
 go-mode.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/go-mode.el b/go-mode.el
index 0207131..0217185 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1695,6 +1695,10 @@ If there is none, make space for one to be added."
 
 If there is none, add parenthesis to add one."
   (interactive)
+
+  (when (go--in-anonymous-funcion-p)
+    (error "Anonymous functions cannot have method receivers"))
+
   (go-goto-function)
   (forward-char 5)
   (when (not (looking-at "("))
@@ -1727,6 +1731,12 @@ If there is none, add one."
     (go-goto-function-name)
     (symbol-name (symbol-at-point))))
 
+(defun go--in-anonymous-funcion-p ()
+  "Return t if point is inside an anonymous function, nil otherwise."
+  (save-excursion
+    (go-goto-function)
+    (looking-at "func(")))
+
 (define-prefix-command 'go-goto-map)
 (define-key go-mode-map (kbd "C-c C-g") 'go-goto-map)
 



reply via email to

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