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

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

[nongnu] elpa/go-mode 205672f 322/495: Use separate godoc commands for g


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 205672f 322/495: Use separate godoc commands for godoc and godoc-at-point
Date: Sat, 7 Aug 2021 09:05:40 -0400 (EDT)

branch: elpa/go-mode
commit 205672ff1f4e5637fc5613e9304a1cecc35df254
Author: Dominik Honnef <dominik@honnef.co>
Commit: Dominik Honnef <dominik@honnef.co>

    Use separate godoc commands for godoc and godoc-at-point
    
    godoc-and-godef needs to use godoc and doesn't support go doc.
    
    Closes gh-127
---
 NEWS       | 13 +++++++++++--
 go-mode.el | 27 +++++++++++++++++++--------
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
index 77358af..8e21c79 100644
--- a/NEWS
+++ b/NEWS
@@ -45,8 +45,11 @@ go-mode-1.4.0 (???)
    it had when Emacs started.
 
  * Add customizable variable godoc-command, which allows choosing
-   between using godoc and go doc. It defaults to go doc, which
-   differs from prior versions which always used godoc.
+   between using godoc and go doc, and generally specifying
+   alternative paths to those tools.
+
+   It defaults to go doc, which differs from prior versions which always
+   used godoc.
 
  * Add customizable variable godoc-use-completing-read, which allows
    turning on or off the completion of import paths in the godoc
@@ -68,6 +71,12 @@ go-mode-1.4.0 (???)
    choosing between strategies for finding an identifier's
    documentation.
 
+ * Add new function godoc-and-godef, which is the default function
+   used for godoc-at-point and matches the previous behaviour.
+
+ * Add new customizable variable godoc-and-godef-command, which allows
+   specifying the path to the godoc binary.
+
  * Add the function godoc-gogetdoc, which provides godoc-at-point
    functionality by using the third party tool gogetdoc.
 
diff --git a/go-mode.el b/go-mode.el
index f1b6a8a..929890d 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -262,11 +262,18 @@ mis-identifying them as gb projects."
   :group 'go)
 
 (defcustom godoc-command "go doc"
-  "Choose between using `godoc' and `go doc' for M-x godoc."
-  :type '(choice
-          (const :tag "godoc" "godoc")
-          (const :tag "go doc" "go doc"))
-  :group 'godoc)
+  "Which executable to use for `godoc'. This can either be
+'godoc' or 'go doc', both as an absolute path or an executable in
+PATH."
+  :type 'string
+  :group 'go)
+
+(defcustom godoc-and-godef-command "godoc"
+  "Which executable to use for `godoc' in
+`godoc-and-godef-command'. Must be 'godoc' and not 'go doc' and
+can be an absolute path or an executable in PATH."
+  :type 'string
+  :group 'go)
 
 (defcustom godoc-use-completing-read nil
   "Provide auto-completion for godoc. Only really desirable when using `godoc' 
instead of `go doc'."
@@ -303,11 +310,12 @@ Consider using godoc-gogetdoc instead for more accurate 
results."
              (first (car name-parts)))
         (if (not (godef--successful-p file))
             (message "%s" (godef--error file))
-          (godoc (format "%s %s"
+          (go--godoc (format "%s %s"
                          (file-name-directory file)
                          (if (or (string= first "type") (string= first 
"const"))
                              (cadr name-parts)
-                           (car name-parts))))))
+                           (car name-parts)))
+                    godoc-and-godef-command)))
     (file-error (message "Could not run godef binary"))))
 
 (defun godoc-gogetdoc (point)
@@ -1236,11 +1244,14 @@ you save any file, kind of defeating the point of 
autoloading."
 ;;;###autoload
 (defun godoc (query)
   "Show Go documentation for QUERY, much like M-x man."
+  (go--godoc query godoc-command))
+
+(defun go--godoc (query command)
   (interactive (list (godoc--read-query)))
   (unless (string= query "")
     (set-process-sentinel
      (start-process-shell-command "godoc" (godoc--get-buffer query)
-                                  (concat godoc-command " " query))
+                                  (concat command " " query))
      'godoc--buffer-sentinel)
     nil))
 



reply via email to

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