[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode c8c6bb0 275/495: go--function-name: return nil for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode c8c6bb0 275/495: go--function-name: return nil for anonymous functions |
Date: |
Sat, 7 Aug 2021 09:05:30 -0400 (EDT) |
branch: elpa/go-mode
commit c8c6bb0667091b0412c3714db32f7057a53b6f64
Author: Lowe Thiderman <lowe.thiderman@gmail.com>
Commit: Dominik Honnef <dominik@honnef.co>
go--function-name: return nil for anonymous functions
Also add a similar API to the other functions that modify things that
don't apply to anonymous functions; an optional argument that toggles
if the function should ignore anonymous functions or not. The function
returns nil if the argument is nil and point is in an anonymous
function.
---
go-mode.el | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 65fe48e..adf3927 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1757,7 +1757,7 @@ an error is raised."
;; If we are looking at an empty comment, add a single space in front of it.
((looking-at "^//$")
(forward-char 2)
- (insert (format " %s " (go--function-name))))
+ (insert (format " %s " (go--function-name t))))
;; If we are not looking at the function signature, we are looking at a
docstring.
;; Move to the beginning of the first word of it.
((not (looking-at "^func"))
@@ -1766,15 +1766,20 @@ an error is raised."
(t
(forward-line -1)
(newline)
- (insert (format "// %s " (go--function-name))))))
+ (insert (format "// %s " (go--function-name t))))))
-(defun go--function-name ()
+(defun go--function-name (&optional arg)
"Return the current function name as a string.
-Will skip anonymous functions since they do not have names."
- (save-excursion
- (go-goto-function-name t)
- (symbol-name (symbol-at-point))))
+If `arg' is non-nil anonymous functions will be ignored and the
+name returned will be of the top-level function.
+
+Returns nil otherwise."
+ (when (or (not (go--in-anonymous-funcion-p))
+ arg)
+ (save-excursion
+ (go-goto-function-name t)
+ (symbol-name (symbol-at-point)))))
(defun go--in-anonymous-funcion-p ()
"Return t if point is inside an anonymous function, nil otherwise."
- [nongnu] elpa/go-mode bf4a097 243/495: add Iwasaki Yudai to AUTHORS, (continued)
- [nongnu] elpa/go-mode bf4a097 243/495: add Iwasaki Yudai to AUTHORS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 498452d 244/495: Don't set old buffer as active after godef--find-file-line-column, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7041a20 245/495: Bump version to 1.2.1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bbaba91 246/495: Add godoc-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 26493e3 264/495: Fix bug in go-goto-function if point is on a non-docstring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fa29aea 265/495: go-goto-method-receiver: handle anonymous functions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3d801ed 268/495: Ignore anonymous functions if called with prefix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c0a3a16 269/495: Update README.md to reflect the latest version of the truth, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c849d72 273/495: Don't throw errors in some go-goto-* functions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 37b9f9c 272/495: Change handling of prefix args to consider them booleans, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c8c6bb0 275/495: go--function-name: return nil for anonymous functions,
ELPA Syncer <=
- [nongnu] elpa/go-mode f58910a 276/495: Reimplement go--in-function-p to do as the name says, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f44854b 278/495: More idiomatic docstrings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9424ab3 283/495: Map C-g f to goto-function and C-g n to goto-function-name, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode abc56d4 286/495: Rename go-goto-return-value to go-goto-return-values, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e4cd631 288/495: Update AUTHORS, automate process, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 63e67b1 290/495: go-goto-docstring: fix insertion of function name, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7c5e9ad 303/495: Avoid warning because of font-lock-syntactic-keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bdf353a 304/495: Use cl-lib instead of cl, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 82ebf74 302/495: Don't make ":", ", " or "=" electric, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a49cdb8 305/495: Evaluate (featurep 'xemacs) at compile time, ELPA Syncer, 2021/08/07