refactor(lib): provide doom-libs as subfeatures
This allows us to load them via doom-require. Why not use normal features? Because Doom's libraries are designed to be loaded as part of Doom, and will openly rely on Doom state if needed; this is a contract I want to enforce by ensuring their only entry points are through `doom-require` or autoloading. I will add them to the rest of the libraries later. Site-node: this also adds Commentary+Code to the comment headings, as I want a space to use that space to describe the library, when I get around to it.
This commit is contained in:
parent
a179b8d262
commit
b121c5e1c6
8 changed files with 57 additions and 20 deletions
|
@ -65,21 +65,23 @@
|
||||||
;; Load just the... bear necessities~
|
;; Load just the... bear necessities~
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'map)
|
(require 'map)
|
||||||
;; Load these eagerly, since autoloads may not have been generated/loaded yet
|
|
||||||
(load! "lib/process")
|
|
||||||
(load! "lib/system")
|
|
||||||
(load! "lib/git")
|
|
||||||
(load! "lib/plist")
|
|
||||||
(load! "lib/files")
|
|
||||||
(load! "lib/debug")
|
|
||||||
(load! "lib/print")
|
|
||||||
;; (load! "lib/autoloads")
|
|
||||||
|
|
||||||
;; Use our own home-grown debugger so we can capture backtraces, make them more
|
;; Use our own home-grown debugger so we can capture backtraces, make them
|
||||||
;; presentable, and write them to a file. Cleaner backtraces are better UX than
|
;; more presentable, and write them to a file. Cleaner backtraces are better
|
||||||
;; the giant wall of text the default debugger throws up.
|
;; UX than the giant wall of text the default debugger throws up.
|
||||||
|
(doom-require 'doom-lib 'debug)
|
||||||
(setq debugger #'doom-debugger)
|
(setq debugger #'doom-debugger)
|
||||||
|
|
||||||
|
;; Then load the rest of Doom's libs eagerly, since autoloads may not be
|
||||||
|
;; generated/loaded yet.
|
||||||
|
(doom-require 'doom-lib 'process)
|
||||||
|
(doom-require 'doom-lib 'system)
|
||||||
|
(doom-require 'doom-lib 'git)
|
||||||
|
(doom-require 'doom-lib 'plist)
|
||||||
|
(doom-require 'doom-lib 'files)
|
||||||
|
(doom-require 'doom-lib 'print)
|
||||||
|
;; (doom-require 'doom-lib 'autoloads)
|
||||||
|
|
||||||
;; Ensure straight and core packages are ready to go for CLI commands.
|
;; Ensure straight and core packages are ready to go for CLI commands.
|
||||||
;; (require 'doom-profiles)
|
;; (require 'doom-profiles)
|
||||||
(require 'doom-modules)
|
(require 'doom-modules)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;;; lisp/lib/debug.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/debug.el -*- lexical-binding: t; -*-
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Doom's debug mode
|
;;; Doom's debug mode
|
||||||
|
@ -414,3 +416,6 @@ copies it to your clipboard, ready to be pasted into bug reports!"
|
||||||
(profiler-report)
|
(profiler-report)
|
||||||
(profiler-stop))
|
(profiler-stop))
|
||||||
(setq doom--profiler (not doom--profiler)))
|
(setq doom--profiler (not doom--profiler)))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(debug))
|
||||||
|
;;; debug.el ends here
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;;; lisp/lib/files.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/files.el -*- lexical-binding: t; -*-
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
(defun doom-files--build-checks (spec &optional directory)
|
(defun doom-files--build-checks (spec &optional directory)
|
||||||
"Converts a simple nested series of or/and forms into a series of
|
"Converts a simple nested series of or/and forms into a series of
|
||||||
|
@ -507,3 +509,6 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
|
||||||
(setq recentf-list (delete file recentf-list))
|
(setq recentf-list (delete file recentf-list))
|
||||||
(recentf-save-list)
|
(recentf-save-list)
|
||||||
(message "Removed %S from `recentf-list'" (abbreviate-file-name file)))
|
(message "Removed %S from `recentf-list'" (abbreviate-file-name file)))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(files))
|
||||||
|
;;; files.el ends here
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;;; lisp/lib/git.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/git.el -*- lexical-binding: t; -*-
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-git-toplevel (&rest segments)
|
(defun doom-git-toplevel (&rest segments)
|
||||||
|
@ -9,3 +11,6 @@
|
||||||
(apply #'file-name-concat output segments)
|
(apply #'file-name-concat output segments)
|
||||||
;; TODO throw stderr as error
|
;; TODO throw stderr as error
|
||||||
(user-error "Not in a git repo: %s" default-directory))))
|
(user-error "Not in a git repo: %s" default-directory))))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(git))
|
||||||
|
;;; git.el ends here
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;;; lisp/lib/plist.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/plist.el -*- lexical-binding: t; -*-
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Macros
|
;;; Macros
|
||||||
|
@ -59,3 +61,6 @@
|
||||||
(push (cadr plist) keys)
|
(push (cadr plist) keys)
|
||||||
(setq plist (cddr plist)))
|
(setq plist (cddr plist)))
|
||||||
keys))
|
keys))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(plist))
|
||||||
|
;;; plist.el ends here
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
;;; lisp/lib/print.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/print.el -*- lexical-binding: t; -*-
|
||||||
;;; Commentary
|
;;; Commentary
|
||||||
;;;
|
;;
|
||||||
;;; This is Doom's output library, for controlling what does and doesn't get
|
;; This is Doom's output library, for controlling what does and doesn't get
|
||||||
;;; logged, and provides a simple DSL for formatting output. It's mainly to
|
;; logged, and provides a simple DSL for formatting output. It's mainly to
|
||||||
;;; serve the noninteractive use-case, as `message' is more than good enough in
|
;; serve the noninteractive use-case, as `message' is more than good enough in
|
||||||
;;; interactive sessions, but `print!' and `doom-log' are safe to use as a
|
;; interactive sessions, but `print!' and `doom-log' are safe to use as a
|
||||||
;;; drop-in replacement.
|
;; drop-in replacement.
|
||||||
;;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
(eval-when-compile (require 'doom)) ; be silent, o'byte-compiler
|
||||||
(require 'ansi-color)
|
(require 'ansi-color)
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Variables
|
||||||
|
|
||||||
(defvar doom-print-ansi-alist
|
(defvar doom-print-ansi-alist
|
||||||
'(;; fx
|
'(;; fx
|
||||||
(bold 1 :weight bold)
|
(bold 1 :weight bold)
|
||||||
|
@ -438,3 +442,6 @@ transformative logic."
|
||||||
(doom-print--apply (cdr forms) t)
|
(doom-print--apply (cdr forms) t)
|
||||||
nil))
|
nil))
|
||||||
(forms)))
|
(forms)))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(print))
|
||||||
|
;;; print.el ends here
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;;; lisp/lib/process.el -*- lexical-binding: t; -*-
|
;;; lisp/lib/process.el -*- lexical-binding: t; -*-
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-call-process (command &rest args)
|
(defun doom-call-process (command &rest args)
|
||||||
|
@ -40,3 +42,6 @@ Warning: freezes indefinitely on any stdin prompt."
|
||||||
(sit-for 0.1))
|
(sit-for 0.1))
|
||||||
(process-exit-status process))
|
(process-exit-status process))
|
||||||
(string-trim (buffer-string)))))
|
(string-trim (buffer-string)))))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(process))
|
||||||
|
;;; process.el ends here
|
||||||
|
|
|
@ -106,3 +106,6 @@ Tries to be portable. Returns 1 if cannot be determined."
|
||||||
(user-error "Failed to look up number of processors, because:\n\n%s"
|
(user-error "Failed to look up number of processors, because:\n\n%s"
|
||||||
(cdr cpus)))))
|
(cdr cpus)))))
|
||||||
1)))))
|
1)))))
|
||||||
|
|
||||||
|
(provide 'doom-lib '(system))
|
||||||
|
;;; system.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue