Skip to content

Commit

Permalink
fix(counsel-dash): install user docsets from kapeli.com
Browse files Browse the repository at this point in the history
instead of from the heroku domain which returns 404

dash-docs-el/dash-docs#23 (comment)
  • Loading branch information
zed committed Aug 11, 2024
1 parent fe604d1 commit ed420bd
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@
;; Note: can't use :config here -- too late for the hook to run then the
;; keys are invoked (causing the config) in the corresponding buffer
:init
(progn ;; M-x counsel-dash-install-docset
;; M-x counsel-dash-install-user-docset
(progn ;; M-x counsel-dash-install-docset (after using counsel-dash)
;; M-x counsel-dash-install-user-docset -> 404 from https://dashes-to-dashes.herokuapp.com/docsets/contrib
;;;; (setq url-debug t) ;; see *URL-DEBUG* buffer
(defun python3-doc ()
(interactive)
(setq-local counsel-dash-docsets
'("Pandas" "Python 3" "NumPy" "SciPy" "Matplotlib" "scikit-learn" "seaborn 0.11.0")))
'("Pandas" "Python 3" "NumPy" "SciPy" "Matplotlib" "scikit-learn" "seaborn")))

(add-hook 'python-mode-hook 'python3-doc)
(add-hook 'org-mode-hook 'python3-doc)

Expand All @@ -157,7 +159,37 @@
(interactive)
(setq-local
counsel-dash-docsets '("Bash")))
(add-hook 'sh-mode-hook 'bash-doc)))
(add-hook 'sh-mode-hook 'bash-doc))
:config

;; from https://github.com/dash-docs-el/dash-docs/issues/23#issuecomment-1694059091
(defun dash-docs-unofficial-docsets ()
"Return a list of lists with docsets contributed by users.
The first element is the docset's name second the docset's archive url."
(let ((user-docs (assoc-default 'docsets
(dash-docs-read-json-from-url
"https://kapeli.com/feeds/zzz/user_contributed/build/index.json"))))
(mapcar (lambda (docset)
(list
(assoc-default 'name docset)
(car docset)
(assoc-default 'archive docset)))
user-docs)))

(defun dash-docs-install-user-docset ()
"Download an unofficial docset with specified DOCSET-NAME and move its stuff to docsets-path."
(interactive)
(let* ((docsets (dash-docs-unofficial-docsets))
(docset-name (dash-docs-read-docset
"Install docset"
(mapcar 'car docsets)))
(docset (assoc-default docset-name docsets)))
(when (dash-docs--ensure-created-docsets-path (dash-docs-docsets-path))
(let ((url
(format "https://kapeli.com/feeds/zzz/user_contributed/build/%s/%s"
(car docset)
(cadr docset))))
(dash-docs--install-docset url (car docset)))))))

;; ** ripgrep
;;; type `e' in rg-mode to edit search results, `C-x C-s' to save them
Expand Down

0 comments on commit ed420bd

Please sign in to comment.