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

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

[nongnu] elpa/go-mode a16e2e0 266/495: Update docstring and comments for


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode a16e2e0 266/495: Update docstring and comments for go--in-function-p
Date: Sat, 7 Aug 2021 09:05:28 -0400 (EDT)

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

    Update docstring and comments for go--in-function-p
---
 go-mode.el | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 0217185..02c4344 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1615,28 +1615,31 @@ are below that anonymous function, go to the root 
function."
     (go-goto-function)))
 
 (defun go--in-function-p (compare-point)
-  "Return t if point is inside the function that starts at `compare-point', nil
-otherwise."
-  ;; Check that we are not looking at a top level function. If we are,
+  "Return t if `compare-point' is inside the function that point is currently 
on.
+This should only be called as a helper when point is looking at \"func\".
+
+Returns nil in all other cases."
+  ;; Check that we are not looking at a top level function. If we are, return 
nil.
   (when (not (looking-at "^func"))
-   (save-excursion
-     (go--goto-return-values)
-     ;; Try to place the point on the opening brace
-     (cond
-      ((looking-at "(")
-       (forward-list 1)
-       (forward-char 1))
-      ((not (looking-at "{"))
-       (forward-word 1)
-       (forward-char 1)))
-
-     (when (looking-at "{")
-       ;; Go past the body of the function and back inside of it.
-       (forward-list 1)
-       (backward-char 1)
-       ;; Finally, compare if our position is past the assert point.
-       ;; Return t if it is.
-       (< (point) compare-point)))))
+    (save-excursion
+      (go--goto-return-values)
+      ;; Try to place the point on the opening brace.
+      (cond
+       ((looking-at "(")
+        (forward-list 1)
+        (forward-char 1))
+       ((not (looking-at "{"))
+        (forward-word 1)
+        (forward-char 1)))
+
+      (when (looking-at "{")
+        ;; Go past the body of the function and back inside of it.
+        (forward-list 1)
+        (backward-char 1)
+        ;; Now that point is looking at the closing brace of the function
+        ;; body, compare if our position is earlier in the file than the
+        ;; comparing point. Return t if it is.
+        (< (point) compare-point)))))
 
 (defun go-goto-function-name ()
   "Go to the name of the current function.



reply via email to

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