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

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

[nongnu] elpa/go-mode 53f50f7 299/495: Make godoc command and completion


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 53f50f7 299/495: Make godoc command and completion configurable
Date: Sat, 7 Aug 2021 09:05:35 -0400 (EDT)

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

    Make godoc command and completion configurable
    
    Introduce godoc-command that allows choosing between godoc and godoc.
    Introduce godoc-use-completing-read that allows turning on or off the
    use of completing-read for import paths in godoc.
    
    Default to go doc and no completion, which differs from the old enforced
    combination of godoc and completion. This is done because go doc is
    generally the more useful tool.
    
    Closes gh-101
---
 NEWS       |  9 +++++++++
 go-mode.el | 31 +++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 50e24dc..339b0a9 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,15 @@ go-mode-1.4.0 (???)
    could be used from inside a projectile-switch-project-hook,
    directory variables or some other way of invoking per-project code.
 
+ * Add 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.
+
+ * Add variable godoc-use-completing-read, which allows turning on or
+   off the completion of import paths in godoc. This is only really
+   useful when using godoc instead of go doc, and thus defaults to
+   off.
+
 go-mode-1.3.1 (2015-07-03)
 
  * The 1.3.0 release forgot to update the version in the package
diff --git a/go-mode.el b/go-mode.el
index f763562..7124edb 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -169,6 +169,10 @@ won't."
   "Options specific to `cover`."
   :group 'go)
 
+(defgroup godoc nil
+  "Options specific to `godoc'."
+  :group 'go)
+
 (defcustom go-fontify-function-calls t
   "Fontify function and method calls if this is non-nil."
   :type 'boolean
@@ -254,6 +258,18 @@ mis-identifying them as gb projects."
   :type '(repeat function)
   :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)
+
+(defcustom godoc-use-completing-read nil
+  "Provide auto-completion for godoc. Only really desirable when using `godoc' 
instead of `go doc'."
+  :type 'boolean
+  :group 'godoc)
+
 (defun go--kill-new-message (url)
   "Make URL the latest kill and print a message."
   (kill-new url)
@@ -1116,11 +1132,14 @@ you save any file, kind of defeating the point of 
autoloading."
   (let* ((bounds (bounds-of-thing-at-point 'symbol))
          (symbol (if bounds
                      (buffer-substring-no-properties (car bounds)
-                                                     (cdr bounds)))))
-    (completing-read (if symbol
-                         (format "godoc (default %s): " symbol)
-                       "godoc: ")
-                     (go--old-completion-list-style (go-packages)) nil nil nil 
'go-godoc-history symbol)))
+                                                     (cdr bounds))))
+         (prompt (if symbol
+                     (format "godoc (default %s): " symbol)
+                   "godoc: ")))
+    (if godoc-use-completing-read
+        (completing-read prompt
+                         (go--old-completion-list-style (go-packages)) nil nil 
nil 'go-godoc-history symbol)
+      (read-from-minibuffer prompt symbol nil nil 'go-godoc-history))))
 
 (defun godoc--get-buffer (query)
   "Get an empty buffer for a godoc query."
@@ -1153,7 +1172,7 @@ you save any file, kind of defeating the point of 
autoloading."
   (unless (string= query "")
     (set-process-sentinel
      (start-process-shell-command "godoc" (godoc--get-buffer query)
-                                  (concat "godoc " query))
+                                  (concat godoc-command " " query))
      'godoc--buffer-sentinel)
     nil))
 



reply via email to

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