summaryrefslogtreecommitdiff
path: root/cider-interaction.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@tradeo.com>2014-08-05 15:00:38 +0300
committerBozhidar Batsov <bozhidar@tradeo.com>2014-08-05 15:00:38 +0300
commitde77b59ee86c83b457fa49c6df47a6fc9247d725 (patch)
tree3fad4e021cdac52a13116f280317eb5e25a17663 /cider-interaction.el
parentec2ae0de1dc42dfee2c6c0c5b434031a75c0e42e (diff)
Refactor a bit the grimoire code
Diffstat (limited to 'cider-interaction.el')
-rw-r--r--cider-interaction.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/cider-interaction.el b/cider-interaction.el
index 4f016b51..d173e044 100644
--- a/cider-interaction.el
+++ b/cider-interaction.el
@@ -1472,6 +1472,15 @@ under point, prompts for a var."
(interactive "P")
(cider-read-symbol-name "Symbol: " 'cider-grimoire-web-lookup query))
+(defun cider-create-grimoire-buffer (content)
+ "Create a new grimoire buffer with CONTENT."
+ (with-current-buffer (cider-popup-buffer "*cider grimoire*" t)
+ (read-only-mode -1)
+ (insert content)
+ (read-only-mode +1)
+ (goto-char (point-min))
+ (current-buffer)))
+
(defun cider-grimoire-lookup (symbol)
"Look up the grimoire documentation for SYMBOL."
(-if-let (var-info (cider-var-info symbol))
@@ -1482,18 +1491,13 @@ under point, prompts for a var."
;; TODO: add a whitelist of supported namespaces
(url-retrieve (cider-grimoire-url name ns (cider--clojure-version))
(lambda (status)
+ ;; we need to strip the http header
(goto-char (point-min))
(re-search-forward "^$")
(delete-region (point-min) (point))
(delete-blank-lines)
- (text-mode)
- (cider-popup-buffer-mode +1)
- (read-only-mode +1)
- (pop-to-buffer (current-buffer))
- (goto-char (point-min))
- (when (get-buffer "*cider grimoire*")
- (kill-buffer "*cider grimoire*"))
- (rename-buffer "*cider grimoire*"))))
+ ;; and create a new buffer with whatever is left
+ (pop-to-buffer (cider-create-grimoire-buffer (buffer-string))))))
(message "Symbol %s not resolved" symbol)))
(defun cider-grimoire (query)