2017-06-08 11:47:56 +02:00
|
|
|
;;; core/autoload/help.el -*- lexical-binding: t; -*-
|
2017-05-27 14:31:08 +02:00
|
|
|
|
2018-02-19 20:27:18 -05:00
|
|
|
(defvar doom--module-mode-alist
|
|
|
|
'((c-mode :lang cc)
|
|
|
|
(c++-mode :lang cc)
|
|
|
|
(objc++-mode :lang cc)
|
|
|
|
(java-mode :lang java)
|
|
|
|
(csharp-mode :lang csharp)
|
|
|
|
(clojure-mode :lang clojure)
|
|
|
|
(emacs-lisp-mode :lang emacs-lisp)
|
|
|
|
(go-mode :lang go)
|
|
|
|
(haskell-mode :lang haskell)
|
|
|
|
(js2-mode :lang javascript)
|
|
|
|
(julia-mode :lang julia)
|
|
|
|
(latex-mode :lang latex)
|
|
|
|
(LaTeX-mode :lang latex)
|
|
|
|
(ledger-mode :lang ledger)
|
|
|
|
(lua-mode :lang lua)
|
|
|
|
(markdown-mode :lang markdown)
|
|
|
|
(gfm-mode :lang markdown)
|
|
|
|
(ocaml-mode :lang ocaml)
|
|
|
|
(org-mode :lang org)
|
|
|
|
(perl-mode :lang perl)
|
|
|
|
(php-mode :lang php)
|
|
|
|
(hack-mode :lang php)
|
|
|
|
(plantuml-mode :lang plantuml)
|
|
|
|
(purescript-mode :lang purescript)
|
|
|
|
(python-mode :lang python)
|
|
|
|
(restclient-mode :lang rest)
|
|
|
|
(ruby-mode :lang ruby)
|
|
|
|
(rust-mode :lang rust)
|
|
|
|
(scala-mode :lang scala)
|
|
|
|
(sh-mode :lang sh)
|
|
|
|
(swift-mode :lang swift)
|
|
|
|
(typescript-mode :lang typescript)
|
|
|
|
(web-mode :lang web)
|
|
|
|
(css-mode :lang web)
|
|
|
|
(scss-mode :lang web)
|
|
|
|
(sass-mode :lang web)
|
|
|
|
(less-css-mode :lang web)
|
|
|
|
(stylus-mode :lang web))
|
|
|
|
"TODO")
|
|
|
|
|
2018-05-20 12:13:05 +02:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Helpers
|
|
|
|
;;
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-active-minor-modes ()
|
|
|
|
"Return a list of active minor-mode symbols."
|
|
|
|
(cl-loop for mode in minor-mode-list
|
|
|
|
if (and (boundp mode) (symbol-value mode))
|
|
|
|
collect mode))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Commands
|
|
|
|
;;
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom/describe-setting (setting)
|
|
|
|
"Open the documentation of SETTING (a keyword defined with `def-setting!').
|
|
|
|
|
|
|
|
Defaults to the "
|
|
|
|
(interactive
|
|
|
|
(let ((sym (symbol-at-point)))
|
|
|
|
(list (completing-read "Describe setting: "
|
|
|
|
(sort (mapcar #'car doom-settings) #'string-lessp)
|
|
|
|
nil t (if (keywordp sym) (symbol-name sym))))))
|
|
|
|
(let ((fn (cdr (assq (intern setting) doom-settings))))
|
|
|
|
(unless fn
|
|
|
|
(error "'%s' is not a valid DOOM setting" setting))
|
|
|
|
(describe-function fn)))
|
|
|
|
|
2017-05-27 14:31:08 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom/describe-module (module)
|
|
|
|
"Open the documentation of MODULE (a string that represents the category and
|
2018-01-28 03:00:25 -05:00
|
|
|
submodule in the format, e.g. ':feature evil').
|
|
|
|
|
|
|
|
Defaults to either a) the module at point (in init.el), b) the module derived
|
2018-02-19 20:27:18 -05:00
|
|
|
from a `featurep!' or `require!' call, c) the module that the current file is
|
|
|
|
in, or d) the module associated with the current major mode (see
|
|
|
|
`doom--module-mode-alist')."
|
2017-05-27 14:31:08 +02:00
|
|
|
(interactive
|
2018-01-28 03:00:25 -05:00
|
|
|
(let ((module
|
2018-01-31 06:41:51 +03:00
|
|
|
(cond ((and buffer-file-name
|
2018-02-19 20:27:18 -05:00
|
|
|
(eq major-mode 'emacs-lisp-mode)
|
|
|
|
(string= (file-name-nondirectory buffer-file-name)
|
|
|
|
"init.el")
|
|
|
|
(thing-at-point 'sexp t)))
|
2018-01-28 03:00:25 -05:00
|
|
|
((save-excursion
|
2018-05-20 12:06:50 +02:00
|
|
|
(require 'smartparens)
|
2018-02-19 20:27:18 -05:00
|
|
|
(ignore-errors
|
|
|
|
(sp-beginning-of-sexp)
|
|
|
|
(unless (eq (char-after) ?\()
|
|
|
|
(backward-char))
|
|
|
|
(let ((sexp (sexp-at-point)))
|
|
|
|
(when (memq (car-safe sexp) '(featurep! require!))
|
|
|
|
(format "%s %s" (nth 1 sexp) (nth 2 sexp)))))))
|
|
|
|
((and buffer-file-name
|
|
|
|
(when-let* ((mod (doom-module-from-path buffer-file-name)))
|
|
|
|
(format "%s %s" (car mod) (cdr mod)))))
|
|
|
|
((when-let* ((mod (cdr (assq major-mode doom--module-mode-alist))))
|
|
|
|
(format "%s %s"
|
|
|
|
(symbol-name (car mod))
|
|
|
|
(symbol-name (cadr mod))))))))
|
2018-01-28 03:00:25 -05:00
|
|
|
(list (completing-read "Describe module: "
|
|
|
|
(cl-loop for (module . sub) in (reverse (hash-table-keys doom-modules))
|
|
|
|
collect (format "%s %s" module sub))
|
2018-05-14 18:32:26 +02:00
|
|
|
nil t nil nil module))))
|
2017-06-25 02:04:50 +02:00
|
|
|
(cl-destructuring-bind (category submodule)
|
2017-06-14 20:47:00 +02:00
|
|
|
(mapcar #'intern (split-string module " "))
|
2018-03-02 17:45:15 -05:00
|
|
|
(unless (doom-module-p category submodule)
|
2017-05-27 14:31:08 +02:00
|
|
|
(error "'%s' isn't a valid module" module))
|
2018-05-20 12:13:05 +02:00
|
|
|
(let ((doc-path (doom-module-path category submodule "README.org")))
|
2017-05-27 14:31:08 +02:00
|
|
|
(unless (file-exists-p doc-path)
|
|
|
|
(error "There is no documentation for this module"))
|
|
|
|
(find-file doc-path))))
|
2018-03-12 12:51:05 -04:00
|
|
|
|
2018-05-07 18:10:58 +02:00
|
|
|
;;;###autoload
|
2018-05-20 12:13:05 +02:00
|
|
|
(defun doom/describe-active-minor-mode (mode)
|
|
|
|
"Get information on an active minor mode. Use `describe-minor-mode' for a
|
|
|
|
selection of all minor-modes, active or not."
|
|
|
|
(interactive
|
|
|
|
(list (completing-read "Minor mode: "
|
|
|
|
(doom-active-minor-modes))))
|
|
|
|
(describe-minor-mode-from-symbol
|
|
|
|
(cl-typecase mode
|
|
|
|
(string (intern mode))
|
|
|
|
(symbol mode)
|
|
|
|
(t (error "Expected a symbol/string, got a %s" (type-of mode))))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom/what-face (&optional pos)
|
|
|
|
"Shows all faces and overlay faces at point.
|
|
|
|
|
|
|
|
Interactively prints the list to the echo area. Noninteractively, returns a list
|
|
|
|
whose car is the list of faces and cadr is the list of overlay faces."
|
2018-05-07 18:10:58 +02:00
|
|
|
(interactive)
|
2018-05-20 12:13:05 +02:00
|
|
|
(let* ((pos (or pos (point)))
|
|
|
|
(faces (let ((face (get-text-property pos 'face)))
|
|
|
|
(if (keywordp (car-safe face))
|
|
|
|
(list face)
|
|
|
|
(cl-loop for f in (doom-enlist face) collect f))))
|
|
|
|
(overlays (cl-loop for ov in (overlays-at pos (1+ pos))
|
|
|
|
nconc (doom-enlist (overlay-get ov 'face)))))
|
|
|
|
(cond ((called-interactively-p 'any)
|
|
|
|
(message "%s %s\n%s %s"
|
|
|
|
(propertize "Faces:" 'face 'font-lock-comment-face)
|
|
|
|
(if faces
|
|
|
|
(cl-loop for face in faces
|
|
|
|
if (listp face)
|
|
|
|
concat (format "'%s " face)
|
|
|
|
else
|
|
|
|
concat (concat (propertize (symbol-name face) 'face face) " "))
|
|
|
|
"n/a ")
|
|
|
|
(propertize "Overlays:" 'face 'font-lock-comment-face)
|
|
|
|
(if overlays
|
|
|
|
(cl-loop for ov in overlays
|
|
|
|
concat (concat (propertize (symbol-name ov) 'face ov) " "))
|
|
|
|
"n/a")))
|
|
|
|
(t
|
|
|
|
(and (or faces overlays)
|
|
|
|
(list faces overlays))))))
|