about summary refs log tree commit diff
path: root/emacs/.emacs.d/wpc/prelude.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-31T16·05+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-31T16·08+0100
commitff8277625f43c1354b63333090f72c277c1f43f8 (patch)
tree901594d4fee2031477ae7821f5bc9ef40474232a /emacs/.emacs.d/wpc/prelude.el
parent5d3bb0b7eadc9efc423eb7ef8857fa6df256d254 (diff)
Lint prelude.el
This was a doozey because I use it everywhere. Is there a better way to globally
rename things? Aye aye aye... computers, man!
Diffstat (limited to 'emacs/.emacs.d/wpc/prelude.el')
-rw-r--r--emacs/.emacs.d/wpc/prelude.el83
1 files changed, 39 insertions, 44 deletions
diff --git a/emacs/.emacs.d/wpc/prelude.el b/emacs/.emacs.d/wpc/prelude.el
index ee7bcbbf2707..f045d15e232b 100644
--- a/emacs/.emacs.d/wpc/prelude.el
+++ b/emacs/.emacs.d/wpc/prelude.el
@@ -1,5 +1,9 @@
 ;;; prelude.el --- My attempt at augmenting Elisp stdlib -*- lexical-binding: t -*-
+
 ;; Author: William Carroll <wpcarro@gmail.com>
+;; Version: 0.0.1
+;; Package-Requires: ((emacs "24.3"))
+;; Homepage: https://user.git.corp.google.com/wpcarro/briefcase
 
 ;;; Commentary:
 ;; Some of these ideas are scattered across other modules like `fs',
@@ -13,38 +17,29 @@
 ;;; Code:
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Third-party libraries
+;; Dependencies
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 's)
 (require 'dash)
+(require 's)
 (require 'f)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Libraries
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; TODO: Maybe don't globally import everything here.  Disable these and attepmt
-;; to reload Emacs to assess damage.
-(require 'string)
-(require 'list)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Utilities
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun prelude/to-string (x)
+(defun prelude-to-string (x)
   "Convert X to a string."
   (format "%s" x))
 
-(defun prelude/inspect (&rest args)
-  "Message `ARGS' where ARGS are any type."
+(defun prelude-inspect (&rest args)
+  "Message ARGS where ARGS are any type."
   (->> args
-       (list/map #'prelude/to-string)
-       (apply #'string/concat)
+       (-map #'prelude-to-string)
+       (apply #'s-concat)
        message))
 
-(defmacro prelude/call-process-to-string (cmd &rest args)
+(defmacro prelude-call-process-to-string (cmd &rest args)
   "Return the string output of CMD called with ARGS."
   `(with-temp-buffer
      (call-process ,cmd nil (current-buffer) nil ,@args)
@@ -55,28 +50,28 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;; TODO: Should I `throw' instead of `error' here?
-(defmacro prelude/assert (x)
+(defmacro prelude-assert (x)
   "Errors unless X is t.
 These are strict assertions and purposely do not rely on truthiness."
-  (let ((as-string (prelude/to-string x)))
+  (let ((as-string (prelude-to-string x)))
     `(unless (equal t ,x)
-       (error (string/concat "Assertion failed: " ,as-string)))))
+       (error (s-concat "Assertion failed: " ,as-string)))))
 
-(defmacro prelude/refute (x)
+(defmacro prelude-refute (x)
   "Errors unless X is nil."
-  (let ((as-string (prelude/to-string x)))
+  (let ((as-string (prelude-to-string x)))
     `(unless (equal nil ,x)
-       (error (string/concat "Refutation failed: " ,as-string)))))
+       (error (s-concat "Refutation failed: " ,as-string)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Adapter functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun prelude/identity (x)
+(defun prelude-identity (x)
   "Return X unchanged."
   x)
 
-(defun prelude/const (x)
+(defun prelude-const (x)
   "Return a variadic lambda that will return X."
   (lambda (&rest _) x))
 
@@ -86,54 +81,54 @@ These are strict assertions and purposely do not rely on truthiness."
 
 ;; TODO: Consider packaging these into a linum-color.el package.
 ;; TODO: Generate the color used here from the theme.
-(defvar linum/safe? nil
-  "Flag indicating whether or not it is safe to work with `linum-mode'.")
+(defvar prelude--linum-safe? nil
+  "Flag indicating whether it is safe to work with function `linum-mode'.")
 
-(defvar linum/mru-color nil
+(defvar prelude--linum-mru-color nil
   "Stores the color most recently attempted to be applied.")
 
 (add-hook 'linum-mode-hook
           (lambda ()
-            (setq linum/safe? t)
-            (when (maybe-some? linum/mru-color)
-              (set-face-foreground 'linum linum/mru-color))))
+            (setq prelude--linum-safe? t)
+            (when (maybe-some? prelude--linum-mru-color)
+              (set-face-foreground 'linum prelude--linum-mru-color))))
 
-(defun prelude/set-line-number-color (color)
+(defun prelude-set-line-number-color (color)
   "Safely set linum color to `COLOR'.
 
 If this is called before Emacs initializes, the color will be stored in
-`linum/mru-color' and applied once initialization completes.
+`prelude--linum-mru-color' and applied once initialization completes.
 
 Why is this safe?
 If `(set-face-foreground 'linum)' is called before initialization completes,
 Emacs will silently fail.  Without this function, it is easy to introduce
 difficult to troubleshoot bugs in your init files."
-  (if linum/safe?
+  (if prelude--linum-safe?
       (set-face-foreground 'linum color)
-    (setq linum/mru-color color)))
+    (setq prelude--linum-mru-color color)))
 
-(defun prelude/prompt (prompt)
+(defun prelude-prompt (prompt)
   "Read input from user with PROMPT."
   (read-string prompt))
 
-(cl-defun prelude/start-process (&key name command)
+(cl-defun prelude-start-process (&key name command)
   "Pass command string, COMMAND, and the function name, NAME.
 This is a wrapper around `start-process' that has an API that resembles
 `shell-command'."
   ;; TODO: Fix the bug with tokenizing here, since it will split any whitespace
   ;; character, even though it shouldn't in the case of quoted string in shell.
   ;; e.g. - "xmodmap -e 'one two three'" => '("xmodmap" "-e" "'one two three'")
-  (prelude/refute (string/contains? "'" command))
-  (let* ((tokens (string/split " " command))
-         (program-name (list/head tokens))
-         (program-args (list/tail tokens)))
+  (prelude-refute (s-contains? "'" command))
+  (let* ((tokens (s-split " " command))
+         (program-name (nth 0 tokens))
+         (program-args (cdr tokens)))
     (apply #'start-process
-           `(,(string/format "*%s<%s>*" program-name name)
+           `(,(format "*%s<%s>*" program-name name)
              ,nil
              ,program-name
              ,@program-args))))
 
-(defun prelude/executable-exists? (name)
+(defun prelude-executable-exists? (name)
   "Return t if CLI tool NAME exists according to `exec-path'."
   (let ((file (locate-file name exec-path)))
     (require 'maybe)
@@ -141,7 +136,7 @@ This is a wrapper around `start-process' that has an API that resembles
         (f-exists? file)
       nil)))
 
-(defmacro prelude/time (x)
+(defmacro prelude-time (x)
   "Print the time it takes to evaluate X."
   `(benchmark 1 ',x))