+ enable lexical-scope everywhere (lexical-binding = t): ~5-10% faster startup; ~5-20% general boost + reduce consing, function calls & garbage collection by preferring cl-loop & dolist over lambda closures (for mapc[ar], add-hook, and various cl-lib filter/map/reduce functions) -- where possible + prefer functions with dedicated opcodes, like assq (see byte-defop's in bytecomp.el for more) + prefer pcase & cond (faster) over cl-case + general refactor for code readability + ensure naming & style conventions are adhered to + appease byte-compiler by marking unused variables with underscore + defer minor mode activation to after-init, emacs-startup or window-setup hooks; a customization opportunity for users + ensures custom functionality won't interfere with startup.
37 lines
1.6 KiB
EmacsLisp
37 lines
1.6 KiB
EmacsLisp
;;; core/autoload/help.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###autoload
|
|
(defun doom/describe-setting (setting)
|
|
"Open the documentation of SETTING (a keyword defined with `def-setting!')."
|
|
(interactive
|
|
;; TODO try to read setting from whole line
|
|
(let ((keyword (thing-at-point 'symbol t)))
|
|
(list (completing-read
|
|
(format "Describe setting%s: "
|
|
(if (equal (substring keyword 0 1) ":")
|
|
(format " (default %s)" keyword)
|
|
""))
|
|
doom-settings
|
|
nil t nil nil keyword))))
|
|
(let ((fn (intern-soft (format "doom-setting--setter%s" setting))))
|
|
(unless fn
|
|
(error "'%s' is not a valid DOOM setting" setting))
|
|
(describe-function fn)))
|
|
|
|
;;;###autoload
|
|
(defun doom/describe-module (module)
|
|
"Open the documentation of MODULE (a string that represents the category and
|
|
submodule in the format, e.g. ':feature evil')."
|
|
(interactive
|
|
;; TODO try to read module from whole line
|
|
(list (completing-read "Describe module: "
|
|
(mapcar (lambda (x) (format "%s %s" (car x) (cdr x)))
|
|
(reverse (hash-table-keys doom-modules)))
|
|
nil t)))
|
|
(destructuring-bind (category submodule) (mapcar #'intern (split-string module " "))
|
|
(unless (member (cons category submodule) (doom--module-pairs))
|
|
(error "'%s' isn't a valid module" module))
|
|
(let ((doc-path (expand-file-name "README.org" (doom-module-path category submodule))))
|
|
(unless (file-exists-p doc-path)
|
|
(error "There is no documentation for this module"))
|
|
(find-file doc-path))))
|