{Fix,Refactor} doom/describe-{setting,module}

This commit is contained in:
Henrik Lissner 2017-06-14 20:47:00 +02:00
parent 9c93c453e8
commit 633e693cab
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -5,15 +5,10 @@
"Open the documentation of SETTING (a keyword defined with `def-setting!')." "Open the documentation of SETTING (a keyword defined with `def-setting!')."
(interactive (interactive
;; TODO try to read setting from whole line ;; TODO try to read setting from whole line
(let ((keyword (thing-at-point 'symbol t))) (list (completing-read "Describe setting%s: "
(list (completing-read (mapcar #'car doom-settings)
(format "Describe setting%s: " nil t nil nil)))
(if (equal (substring keyword 0 1) ":") (let ((fn (cdr (assq (intern setting) doom-settings))))
(format " (default %s)" keyword)
""))
doom-settings
nil t nil nil keyword))))
(let ((fn (intern-soft (format "doom-setting--setter%s" setting))))
(unless fn (unless fn
(error "'%s' is not a valid DOOM setting" setting)) (error "'%s' is not a valid DOOM setting" setting))
(describe-function fn))) (describe-function fn)))
@ -25,10 +20,11 @@ submodule in the format, e.g. ':feature evil')."
(interactive (interactive
;; TODO try to read module from whole line ;; TODO try to read module from whole line
(list (completing-read "Describe module: " (list (completing-read "Describe module: "
(mapcar (lambda (x) (format "%s %s" (car x) (cdr x))) (cl-loop for (module . sub) in (reverse (hash-table-keys doom-modules))
(reverse (hash-table-keys doom-modules))) collect (format "%s %s" module sub))
nil t))) nil t)))
(destructuring-bind (category submodule) (mapcar #'intern (split-string module " ")) (destructuring-bind (category submodule)
(mapcar #'intern (split-string module " "))
(unless (member (cons category submodule) (doom--module-pairs)) (unless (member (cons category submodule) (doom--module-pairs))
(error "'%s' isn't a valid module" module)) (error "'%s' isn't a valid module" module))
(let ((doc-path (expand-file-name "README.org" (doom-module-path category submodule)))) (let ((doc-path (expand-file-name "README.org" (doom-module-path category submodule))))