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

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

[nongnu] elpa/go-mode 10281b7 202/495: add godoc-at-point


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 10281b7 202/495: add godoc-at-point
Date: Sat, 7 Aug 2021 09:05:13 -0400 (EDT)

branch: elpa/go-mode
commit 10281b73d6572886dfb5f798928e1478dcbbb669
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    add godoc-at-point
    
    show godoc for the function/method/type/variable at point. Due to
    current limitations in godef and godoc, a method lookup discards the
    type, which will result in documentation for both functions and methods
    with the same name.
---
 go-mode.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/go-mode.el b/go-mode.el
index b83027b..948942e 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -774,6 +774,23 @@ you save any file, kind of defeating the point of 
autoloading."
      'godoc--buffer-sentinel)
     nil))
 
+(defun godoc-at-point (point)
+  (interactive "d")
+  (condition-case nil
+      (let* ((output (godef--call point))
+             (file (car output))
+             (name-parts (split-string (cadr output) " "))
+             (first (car name-parts)))
+        (if (not (godef--successful-p file))
+            (message "%s" (godef--error file))
+          (godoc (format "%s %s"
+                         (mapconcat #'identity (butlast (split-string file 
"/") 1) "/")
+                         (if (or (string= first "type") (string= first 
"const"))
+                             (cadr name-parts)
+                           (car name-parts))))))
+    (file-error (message "Could not run godef binary"))))
+
+
 (defun go-goto-imports ()
   "Move point to the block of imports.
 



reply via email to

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