|
45 | 45 | (defvar cider-browse-ns-mode-map
|
46 | 46 | (let ((map (make-sparse-keymap)))
|
47 | 47 | (set-keymap-parent map cider-popup-buffer-mode-map)
|
48 |
| - (define-key map [return] #'cider-browse-ns-operate-on-point) |
| 48 | + (define-key map [return] #'cider-browse-ns-doc-at-point) |
49 | 49 | (define-key map "^" #'cider-browse-ns-all)
|
50 | 50 | (define-key map "n" #'next-line)
|
51 | 51 | (define-key map "p" #'previous-line)
|
|
115 | 115 | names))
|
116 | 116 | (setq-local cider-browse-ns-current-ns nil))))
|
117 | 117 |
|
118 |
| -(defun cider-browse-ns-operate-on-point () |
| 118 | +(defun cider-browse-ns--var-at-point () |
| 119 | + (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) |
| 120 | + (when (string-match " +\\(.+\\)" line) |
| 121 | + (format "%s/%s" cider-browse-ns-current-ns (match-string 1 line))))) |
| 122 | + |
| 123 | +(defun cider-browse-ns-doc-at-point () |
119 | 124 | "Expand browser according to thing at current point."
|
120 | 125 | (interactive)
|
121 |
| - (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) |
122 |
| - (cond |
123 |
| - ((= 1 (line-number-at-pos)) |
124 |
| - 'nothing-to-do) |
125 |
| - ((string-match " +\\(.+\\)" line) |
126 |
| - (cider-doc-lookup (format "%s/%s" cider-browse-ns-current-ns (match-string 1 line)))) |
127 |
| - (t |
128 |
| - (cider-browse-ns (replace-regexp-in-string " " "" line)))))) |
| 126 | + (-when-let (var (cider-browse-ns--var-at-point)) |
| 127 | + (cider-doc-lookup var))) |
129 | 128 |
|
130 | 129 | (defun cider-browse-ns-handle-mouse (event)
|
131 | 130 | "Handle mouse click EVENT."
|
132 | 131 | (interactive "e")
|
133 |
| - (cider-browse-ns-operate-on-point)) |
| 132 | + (cider-browse-ns-doc-at-point)) |
134 | 133 |
|
135 | 134 | (provide 'cider-browse-ns)
|
136 | 135 |
|
|
0 commit comments