Skip to content

Commit

Permalink
[Fix clojure-emacs#1577] Show first line of docstring in ns browser
Browse files Browse the repository at this point in the history
  • Loading branch information
mallt committed May 22, 2016
1 parent 67ab8e4 commit 91125a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Rebind `cider-eval-last-sexp-and-replace` to `C-c C-v w`.
* Rebind `cider-eval-region` to `C-c C-v r`.
* Rebind `cider-eval-ns-form` to `C-c C-v n`.
* [#1577](https://github.com/clojure-emacs/cider/issues/1577): Show first line of docstring in ns browser.

### Bugs fixed

Expand Down
13 changes: 9 additions & 4 deletions cider-browse-ns.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ contents of the buffer are not reset before inserting TITLE and ITEMS."
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(cider-browse-ns--list (current-buffer)
namespace
(nrepl-dict-map #'cider-browse-ns--properties
(cider-sync-request:ns-vars-with-meta namespace)))
(setq-local cider-browse-ns-current-ns namespace)))
(let* ((ns-vars (nrepl-dict-map #'cider-browse-ns--properties
(cider-sync-request:ns-vars-with-meta namespace))))
(mapcar (lambda (ns-var)
(let* ((doc (nrepl-dict-get (cider-var-info (concat namespace "/" ns-var)) "doc"))
(first-doc-line (when doc (car (split-string doc "\n")))))
(concat ns-var " " first-doc-line)))
ns-vars))
(setq-local cider-browse-ns-current-ns namespace))))

;;;###autoload
(defun cider-browse-ns-all ()
Expand All @@ -143,7 +148,7 @@ contents of the buffer are not reset before inserting TITLE and ITEMS."
(defun cider-browse-ns--thing-at-point ()
"Get the thing at point.
Return a list of the type ('ns or 'var) and the value."
(let ((line (cider-string-trim (thing-at-point 'line))))
(let ((line (car (split-string (cider-string-trim (thing-at-point 'line)) " "))))
(if (string-match "\\." line)
(list 'ns line)
(list 'var (format "%s/%s"
Expand Down
2 changes: 2 additions & 0 deletions test/cider-browse-ns-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
(it "lists out all forms of a namespace with correct font-locks"
(spy-on 'cider-sync-request:ns-vars-with-meta :and-return-value
'(dict "blank?" (dict "arglists" "fn arg list")))
(spy-on 'cider-var-info :and-return-value
'(dict "doc" "docstring"))

(with-temp-buffer
(setq cider-browse-ns-buffer (buffer-name (current-buffer)))
Expand Down

0 comments on commit 91125a5

Please sign in to comment.