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!
This commit is contained in:
William Carroll 2020-08-31 17:05:31 +01:00
parent 5d3bb0b7ea
commit ff8277625f
29 changed files with 163 additions and 164 deletions

View file

@ -257,13 +257,13 @@ In this case, the last writer wins, which is B."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when alist/enable-tests? (when alist/enable-tests?
(prelude/assert (prelude-assert
(equal '((2 . one) (equal '((2 . one)
(3 . two)) (3 . two))
(alist/map-keys #'1+ (alist/map-keys #'1+
'((1 . one) '((1 . one)
(2 . two))))) (2 . two)))))
(prelude/assert (prelude-assert
(equal '((one . 2) (equal '((one . 2)
(two . 3)) (two . 3))
(alist/map-values #'1+ (alist/map-values #'1+

View file

@ -163,7 +163,7 @@ This function ignores Emacs-generated buffers, i.e. the ones that look like
(interactive) (interactive)
(let* ((xs (buffer/source-code-buffers)) (let* ((xs (buffer/source-code-buffers))
(candidate (list/get 1 xs))) (candidate (list/get 1 xs)))
(prelude/assert (maybe-some? candidate)) (prelude-assert (maybe-some? candidate))
(switch-to-buffer candidate))) (switch-to-buffer candidate)))
(when buffer/install-kbds? (when buffer/install-kbds?
@ -183,7 +183,7 @@ This function ignores Emacs-generated buffers, i.e. the ones that look like
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when buffer/enable-tests? (when buffer/enable-tests?
(prelude/assert (prelude-assert
(list/all? #'buffer/emacs-generated? (list/all? #'buffer/emacs-generated?
'("*scratch*" '("*scratch*"
"*Messages*" "*Messages*"

View file

@ -64,7 +64,7 @@
(defun bytes/classify (x) (defun bytes/classify (x)
"Return unit that closest fits byte count, X." "Return unit that closest fits byte count, X."
(prelude/assert (number/whole? x)) (prelude-assert (number/whole? x))
(cond (cond
((and (>= x 0) (< x bytes/kb)) 'byte) ((and (>= x 0) (< x bytes/kb)) 'byte)
((and (>= x bytes/kb) (< x bytes/mb)) 'kilobyte) ((and (>= x bytes/kb) (< x bytes/mb)) 'kilobyte)
@ -92,17 +92,17 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(progn (progn
(prelude/assert (prelude-assert
(equal "1000B" (bytes/to-string 1000))) (equal "1000B" (bytes/to-string 1000)))
(prelude/assert (prelude-assert
(equal "2KB" (bytes/to-string (* 2 bytes/kb)))) (equal "2KB" (bytes/to-string (* 2 bytes/kb))))
(prelude/assert (prelude-assert
(equal "17MB" (bytes/to-string (* 17 bytes/mb)))) (equal "17MB" (bytes/to-string (* 17 bytes/mb))))
(prelude/assert (prelude-assert
(equal "419GB" (bytes/to-string (* 419 bytes/gb)))) (equal "419GB" (bytes/to-string (* 419 bytes/gb))))
(prelude/assert (prelude-assert
(equal "999TB" (bytes/to-string (* 999 bytes/tb)))) (equal "999TB" (bytes/to-string (* 999 bytes/tb))))
(prelude/assert (prelude-assert
(equal "2PB" (bytes/to-string (* 2 bytes/pb))))) (equal "2PB" (bytes/to-string (* 2 bytes/pb)))))
(provide 'bytes) (provide 'bytes)

View file

@ -60,18 +60,18 @@ If X isn't in XS (using `equal'), insert it at the front."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; contains?/2 ;; contains?/2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(prelude/refute (prelude-refute
(cache/contains? "turkey" cache)) (cache/contains? "turkey" cache))
(prelude/assert (prelude-assert
(cache/contains? "chicken" cache)) (cache/contains? "chicken" cache))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; touch/2 ;; touch/2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(prelude/assert (prelude-assert
(equal (equal
(cache/touch "nugget" cache) (cache/touch "nugget" cache)
(cache/from-list '("nugget" "chicken")))) (cache/from-list '("nugget" "chicken"))))
(prelude/assert (prelude-assert
(equal (equal
(cache/touch "spicy" cache) (cache/touch "spicy" cache)
(cache/from-list '("spicy" "chicken" "nugget")))))) (cache/from-list '("spicy" "chicken" "nugget"))))))

View file

@ -50,7 +50,7 @@
"Call `load-theme' with `THEME', ensuring that the line numbers are bright. "Call `load-theme' with `THEME', ensuring that the line numbers are bright.
There is no hook that I'm aware of to handle this more elegantly." There is no hook that I'm aware of to handle this more elegantly."
(load-theme theme t) (load-theme theme t)
(prelude/set-line-number-color "#da5468")) (prelude-set-line-number-color "#da5468"))
(defun colorscheme/whitelist-set (colorscheme) (defun colorscheme/whitelist-set (colorscheme)
"Focus the COLORSCHEME in the `colorscheme/whitelist' cycle." "Focus the COLORSCHEME in the `colorscheme/whitelist' cycle."

View file

@ -14,7 +14,7 @@
(require 'f) (require 'f)
(require 'maybe) (require 'maybe)
(prelude/assert (f-exists? (getenv "BRIEFCASE"))) (prelude-assert (f-exists? (getenv "BRIEFCASE")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration ;; Configuration

View file

@ -196,23 +196,23 @@ If X is the currently focused value, after it's deleted, current-index will be
(when cycle/enable-tests? (when cycle/enable-tests?
(let ((xs (cycle/new 1 2 3))) (let ((xs (cycle/new 1 2 3)))
(prelude/assert (maybe-nil? (cycle/previous-focus xs))) (prelude-assert (maybe-nil? (cycle/previous-focus xs)))
(prelude/assert (= 1 (cycle/current xs))) (prelude-assert (= 1 (cycle/current xs)))
(prelude/assert (= 2 (cycle/next xs))) (prelude-assert (= 2 (cycle/next xs)))
(prelude/assert (= 1 (cycle/previous-focus xs))) (prelude-assert (= 1 (cycle/previous-focus xs)))
(prelude/assert (= 1 (->> xs (cycle/jump 0) cycle/current))) (prelude-assert (= 1 (->> xs (cycle/jump 0) cycle/current)))
(prelude/assert (= 2 (->> xs (cycle/jump 1) cycle/current))) (prelude-assert (= 2 (->> xs (cycle/jump 1) cycle/current)))
(prelude/assert (= 3 (->> xs (cycle/jump 2) cycle/current))) (prelude-assert (= 3 (->> xs (cycle/jump 2) cycle/current)))
(prelude/assert (= 2 (cycle/previous-focus xs))) (prelude-assert (= 2 (cycle/previous-focus xs)))
(prelude/assert (= 2 (cycle/focus-previous! xs))) (prelude-assert (= 2 (cycle/focus-previous! xs)))
(prelude/assert (equal '(1 4 2 3) (cycle-xs (cycle/append 4 xs)))) (prelude-assert (equal '(1 4 2 3) (cycle-xs (cycle/append 4 xs))))
(prelude/assert (equal '(1 2 3) (cycle-xs (cycle/remove 4 xs)))) (prelude-assert (equal '(1 2 3) (cycle-xs (cycle/remove 4 xs))))
(progn (progn
(cycle/focus-item 3 xs) (cycle/focus-item 3 xs)
(cycle/focus-item 2 xs) (cycle/focus-item 2 xs)
(cycle/remove 1 xs) (cycle/remove 1 xs)
(prelude/assert (= 2 (cycle/current xs))) (prelude-assert (= 2 (cycle/current xs)))
(prelude/assert (= 3 (cycle/previous-focus xs)))))) (prelude-assert (= 3 (cycle/previous-focus xs))))))
(provide 'cycle) (provide 'cycle)
;;; cycle.el ends here ;;; cycle.el ends here

View file

@ -46,7 +46,7 @@ The car models the enabled state of my laptop display; the cdr models the
(defun display/enable-4k () (defun display/enable-4k ()
"Attempt to connect to my 4K monitor." "Attempt to connect to my 4K monitor."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "display/enable-4k" :name "display/enable-4k"
:command (string/format :command (string/format
"xrandr --output %s --above %s --primary --auto --size 3840x2160 --rate 30.00 --dpi 144" "xrandr --output %s --above %s --primary --auto --size 3840x2160 --rate 30.00 --dpi 144"
@ -56,7 +56,7 @@ The car models the enabled state of my laptop display; the cdr models the
(defun display/disable-4k () (defun display/disable-4k ()
"Disconnect from the 4K monitor." "Disconnect from the 4K monitor."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "display/disable-4k" :name "display/disable-4k"
:command (string/format "xrandr --output %s --off" :command (string/format "xrandr --output %s --off"
display/4k-monitor))) display/4k-monitor)))
@ -66,7 +66,7 @@ The car models the enabled state of my laptop display; the cdr models the
Sometimes this is useful when I'm sharing my screen in a Google Hangout and I Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
only want to present one of my monitors." only want to present one of my monitors."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "display/disable-laptop" :name "display/disable-laptop"
:command (string/format "xrandr --output %s --auto" :command (string/format "xrandr --output %s --auto"
display/laptop-monitor))) display/laptop-monitor)))
@ -76,7 +76,7 @@ Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
Sometimes this is useful when I'm sharing my screen in a Google Hangout and I Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
only want to present one of my monitors." only want to present one of my monitors."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "display/disable-laptop" :name "display/disable-laptop"
:command (string/format "xrandr --output %s --off" :command (string/format "xrandr --output %s --off"
display/laptop-monitor))) display/laptop-monitor)))

View file

@ -38,11 +38,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(progn (progn
(prelude/assert (prelude-assert
(equal '(fname . "Bob") (dotted/new 'fname "Bob"))) (equal '(fname . "Bob") (dotted/new 'fname "Bob")))
(prelude/assert (prelude-assert
(dotted/instance? '(one . two))) (dotted/instance? '(one . two)))
(prelude/refute (prelude-refute
(dotted/instance? '(1 2 3)))) (dotted/instance? '(1 2 3))))
(provide 'dotted) (provide 'dotted)

View file

@ -68,7 +68,7 @@
mail-envelope-from 'header) mail-envelope-from 'header)
;; Assert that no two saved searches share share a KBD ;; Assert that no two saved searches share share a KBD
(prelude/assert (prelude-assert
(list/xs-distinct-by? (lambda (x) (plist-get x :key)) notmuch-saved-searches)) (list/xs-distinct-by? (lambda (x) (plist-get x :key)) notmuch-saved-searches))
(provide 'email) (provide 'email)

View file

@ -93,7 +93,7 @@
(defun fonts/whitelist-set (font) (defun fonts/whitelist-set (font)
"Focuses the FONT in the `fonts/whitelist' cycle. "Focuses the FONT in the `fonts/whitelist' cycle.
The size of the font is determined by `fonts/size'." The size of the font is determined by `fonts/size'."
(prelude/assert (cycle/contains? font fonts/whitelist)) (prelude-assert (cycle/contains? font fonts/whitelist))
(cycle/focus (lambda (x) (equal x font)) fonts/whitelist) (cycle/focus (lambda (x) (equal x font)) fonts/whitelist)
(fonts/set (fonts/current) fonts/size)) (fonts/set (fonts/current) fonts/size))

View file

@ -64,11 +64,11 @@ The user must pass in a valid Neighbors Table since asserting on the shape of
;; TODO: Model each of the mapping functions into an isomorphism. ;; TODO: Model each of the mapping functions into an isomorphism.
(defun graph/edges->neighbors (xs) (defun graph/edges->neighbors (xs)
"Map Edge List, XS, into a Neighbors Table." "Map Edge List, XS, into a Neighbors Table."
(prelude/assert (graph/instance? xs))) (prelude-assert (graph/instance? xs)))
(defun graph/neighbors->edges (xs) (defun graph/neighbors->edges (xs)
"Map Neighbors Table, XS, into an Edge List." "Map Neighbors Table, XS, into an Edge List."
(prelude/assert (graph/instance? xs))) (prelude-assert (graph/instance? xs)))
;; Below are three different models of the same unweighted, directed graph. ;; Below are three different models of the same unweighted, directed graph.

View file

@ -45,7 +45,7 @@
;; TODO: Assert that no two servers have a channel with the same name. We need ;; TODO: Assert that no two servers have a channel with the same name. We need
;; this because that's the assumption that underpins the `irc/channel->server' ;; this because that's the assumption that underpins the `irc/channel->server'
;; function. This will probably be an O(n^2) operation. ;; function. This will probably be an O(n^2) operation.
(prelude/assert (prelude-assert
(set/distinct? (set/from-list (set/distinct? (set/from-list
(cycle/to-list (cycle/to-list
(alist/get "irc.freenode.net" (alist/get "irc.freenode.net"
@ -59,7 +59,7 @@
"Resolve an IRC server from a given CHANNEL." "Resolve an IRC server from a given CHANNEL."
(let ((result (alist/find (lambda (k v) (cycle/contains? channel v)) (let ((result (alist/find (lambda (k v) (cycle/contains? channel v))
server->channels))) server->channels)))
(prelude/assert (maybe-some? result)) (prelude-assert (maybe-some? result))
result)) result))
(defun irc/channel->cycle (server->channels channel) (defun irc/channel->cycle (server->channels channel)
@ -166,7 +166,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when irc/enable-tests? (when irc/enable-tests?
(prelude/assert (prelude-assert
(equal (equal
(irc/channel->server `(("irc.dairy.com" . ,(cycle/new "#cheese" "#milk")) (irc/channel->server `(("irc.dairy.com" . ,(cycle/new "#cheese" "#milk"))
("irc.color.com" . ,(cycle/new "#red" "#blue"))) ("irc.color.com" . ,(cycle/new "#red" "#blue")))

View file

@ -33,7 +33,7 @@
"Mapping of functions to designated keybinding prefixes to stay organized.") "Mapping of functions to designated keybinding prefixes to stay organized.")
;; Assert that no keybindings are colliding. ;; Assert that no keybindings are colliding.
(prelude/assert (prelude-assert
(= (alist/count kbd/prefixes) (= (alist/count kbd/prefixes)
(->> kbd/prefixes (->> kbd/prefixes
alist/values alist/values
@ -49,7 +49,7 @@
Values for F include: Values for F include:
- workspace - workspace
- x11" - x11"
(prelude/assert (alist/has-key? f kbd/prefixes)) (prelude-assert (alist/has-key? f kbd/prefixes))
(string/format (string/format
"%s-%s" "%s-%s"
(alist/get f kbd/prefixes) (alist/get f kbd/prefixes)

View file

@ -51,7 +51,7 @@
(rate keyboard/repeat-rate) (rate keyboard/repeat-rate)
(delay keyboard/repeat-delay)) (delay keyboard/repeat-delay))
"Use xset to set the key-repeat RATE and DELAY." "Use xset to set the key-repeat RATE and DELAY."
(prelude/start-process (prelude-start-process
:name "keyboard/set-key-repeat" :name "keyboard/set-key-repeat"
:command (string/format "xset r rate %s %s" delay rate))) :command (string/format "xset r rate %s %s" delay rate)))
@ -65,7 +65,7 @@
(defun keyboard/swap-caps-lock-and-escape () (defun keyboard/swap-caps-lock-and-escape ()
"Swaps the caps lock and escape keys using xmodmap." "Swaps the caps lock and escape keys using xmodmap."
(interactive) (interactive)
;; TODO: Ensure these work once the tokenizing in prelude/start-process works ;; TODO: Ensure these work once the tokenizing in prelude-start-process works
;; as expected. ;; as expected.
(start-process "keyboard/swap-caps-lock-and-escape" nil "/usr/bin/xmodmap" "-e" (start-process "keyboard/swap-caps-lock-and-escape" nil "/usr/bin/xmodmap" "-e"
"remove Lock = Caps_Lock") "remove Lock = Caps_Lock")

View file

@ -49,7 +49,7 @@
;; Dependencies ;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Move `prelude/assert' elsewhere so that I can require it without ;; TODO: Move `prelude-assert' elsewhere so that I can require it without
;; introducing the circular dependency of list.el -> prelude.el -> list.el. ;; introducing the circular dependency of list.el -> prelude.el -> list.el.
;;(require 'prelude) ;;(require 'prelude)
(require 'dash) (require 'dash)
@ -137,7 +137,7 @@
;; (if (alist/has-key? k acc) ;; (if (alist/has-key? k acc)
;; (setf (alist-get k acc) (list v)) ;; (setf (alist-get k acc) (list v))
;; (setf (alist-get k acc) (list v)))))))) ;; (setf (alist-get k acc) (list v))))))))
;; (prelude/assert ;; (prelude-assert
;; (equal '(("John" . ("Cleese" "Malkovich")) ;; (equal '(("John" . ("Cleese" "Malkovich"))
;; ("Thomas" . ("Aquinas"))) ;; ("Thomas" . ("Aquinas")))
;; (list/index (lambda (x) (plist-get x :first-name)) ;; (list/index (lambda (x) (plist-get x :first-name))
@ -210,7 +210,7 @@ Be leery of using this with things like alists. Many data structures in Elisp
;; TODO: Add tests. ;; TODO: Add tests.
(defun list/dedupe-adjacent (xs) (defun list/dedupe-adjacent (xs)
"Return XS without adjacent duplicates." "Return XS without adjacent duplicates."
(prelude/assert (not (list/empty? xs))) (prelude-assert (not (list/empty? xs)))
(list/reduce (list (list/first xs)) (list/reduce (list (list/first xs))
(lambda (x acc) (lambda (x acc)
(if (equal x (list/first acc)) (if (equal x (list/first acc))
@ -223,16 +223,16 @@ Be leery of using this with things like alists. Many data structures in Elisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (when list/tests? ;; (when list/tests?
;; (prelude/assert ;; (prelude-assert
;; (= 0 ;; (= 0
;; (list/length '()))) ;; (list/length '())))
;; (prelude/assert ;; (prelude-assert
;; (= 5 ;; (= 5
;; (list/length '(1 2 3 4 5)))) ;; (list/length '(1 2 3 4 5))))
;; (prelude/assert ;; (prelude-assert
;; (= 16 ;; (= 16
;; (list/reduce 1 (lambda (x acc) (+ x acc)) '(1 2 3 4 5)))) ;; (list/reduce 1 (lambda (x acc) (+ x acc)) '(1 2 3 4 5))))
;; (prelude/assert ;; (prelude-assert
;; (equal '(2 4 6 8 10) ;; (equal '(2 4 6 8 10)
;; (list/map (lambda (x) (* x 2)) '(1 2 3 4 5))))) ;; (list/map (lambda (x) (* x 2)) '(1 2 3 4 5)))))

View file

@ -82,23 +82,23 @@
(when maybe--run-tests? (when maybe--run-tests?
;; nil? ;; nil?
(prelude/assert (maybe-nil? nil)) (prelude-assert (maybe-nil? nil))
(prelude/refute (maybe-nil? t)) (prelude-refute (maybe-nil? t))
;; some? ;; some?
(prelude/assert (maybe-some? 10)) (prelude-assert (maybe-some? 10))
(prelude/refute (maybe-some? nil)) (prelude-refute (maybe-some? nil))
;; nils? ;; nils?
(prelude/assert (maybe-nils? nil nil nil nil)) (prelude-assert (maybe-nils? nil nil nil nil))
(prelude/refute (maybe-nils? nil t nil t)) (prelude-refute (maybe-nils? nil t nil t))
;; somes? ;; somes?
(prelude/assert (maybe-somes? t 10 '(1 2 3) "some")) (prelude-assert (maybe-somes? t 10 '(1 2 3) "some"))
(prelude/refute (maybe-somes? t nil '(1 2 3) "some")) (prelude-refute (maybe-somes? t nil '(1 2 3) "some"))
;; default ;; default
(prelude/assert (prelude-assert
(and (= 0 (maybe-default 5 0)) (and (= 0 (maybe-default 5 0))
(= 5 (maybe-default 5 nil)))) (= 5 (maybe-default 5 nil))))
;; map ;; map
(prelude/assert (prelude-assert
(and (= 2 (maybe-map #'1+ 1)) (and (= 2 (maybe-map #'1+ 1))
(eq nil (maybe-map #'1+ nil))))) (eq nil (maybe-map #'1+ nil)))))

View file

@ -1,5 +1,9 @@
;;; number.el --- Functions for working with numbers -*- lexical-binding: t -*- ;;; number.el --- Functions for working with numbers -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; Package-Requires: ((emacs "24"))
;; Homepage: https://user.git.corp.google.com/wpcarro/briefcase
;;; Commentary: ;;; Commentary:
;; ;;
@ -124,29 +128,29 @@ While this function is undeniably trivial, I have unintentionally done (- 1 x)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when number/test? (when number/test?
(prelude/assert (prelude-assert
(number/positive? 10)) (number/positive? 10))
(prelude/assert (prelude-assert
(number/natural? 10)) (number/natural? 10))
(prelude/assert (prelude-assert
(number/whole? 10)) (number/whole? 10))
(prelude/assert (prelude-assert
(number/whole? 0)) (number/whole? 0))
(prelude/assert (prelude-assert
(number/integer? 10)) (number/integer? 10))
;; (prelude/assert ;; (prelude-assert
;; (= 120 (number/factorial 5))) ;; (= 120 (number/factorial 5)))
(prelude/assert (prelude-assert
(number/even? 6)) (number/even? 6))
(prelude/refute (prelude-refute
(number/odd? 6)) (number/odd? 6))
(prelude/refute (prelude-refute
(number/positive? -10)) (number/positive? -10))
(prelude/refute (prelude-refute
(number/natural? 10.0)) (number/natural? 10.0))
(prelude/refute (prelude-refute
(number/natural? -10)) (number/natural? -10))
(prelude/refute (prelude-refute
(number/natural? -10.0))) (number/natural? -10.0)))
(provide 'number) (provide 'number)

View file

@ -1,5 +1,9 @@
;;; prelude.el --- My attempt at augmenting Elisp stdlib -*- lexical-binding: t -*- ;;; prelude.el --- My attempt at augmenting Elisp stdlib -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; 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: ;;; Commentary:
;; Some of these ideas are scattered across other modules like `fs', ;; Some of these ideas are scattered across other modules like `fs',
@ -13,38 +17,29 @@
;;; Code: ;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Third-party libraries ;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 's)
(require 'dash) (require 'dash)
(require 's)
(require 'f) (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 ;; Utilities
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun prelude/to-string (x) (defun prelude-to-string (x)
"Convert X to a string." "Convert X to a string."
(format "%s" x)) (format "%s" x))
(defun prelude/inspect (&rest args) (defun prelude-inspect (&rest args)
"Message `ARGS' where ARGS are any type." "Message ARGS where ARGS are any type."
(->> args (->> args
(list/map #'prelude/to-string) (-map #'prelude-to-string)
(apply #'string/concat) (apply #'s-concat)
message)) 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." "Return the string output of CMD called with ARGS."
`(with-temp-buffer `(with-temp-buffer
(call-process ,cmd nil (current-buffer) nil ,@args) (call-process ,cmd nil (current-buffer) nil ,@args)
@ -55,28 +50,28 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Should I `throw' instead of `error' here? ;; TODO: Should I `throw' instead of `error' here?
(defmacro prelude/assert (x) (defmacro prelude-assert (x)
"Errors unless X is t. "Errors unless X is t.
These are strict assertions and purposely do not rely on truthiness." 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) `(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." "Errors unless X is nil."
(let ((as-string (prelude/to-string x))) (let ((as-string (prelude-to-string x)))
`(unless (equal nil ,x) `(unless (equal nil ,x)
(error (string/concat "Refutation failed: " ,as-string))))) (error (s-concat "Refutation failed: " ,as-string)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Adapter functions ;; Adapter functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun prelude/identity (x) (defun prelude-identity (x)
"Return X unchanged." "Return X unchanged."
x) x)
(defun prelude/const (x) (defun prelude-const (x)
"Return a variadic lambda that will return X." "Return a variadic lambda that will return X."
(lambda (&rest _) 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: Consider packaging these into a linum-color.el package.
;; TODO: Generate the color used here from the theme. ;; TODO: Generate the color used here from the theme.
(defvar linum/safe? nil (defvar prelude--linum-safe? nil
"Flag indicating whether or not it is safe to work with `linum-mode'.") "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.") "Stores the color most recently attempted to be applied.")
(add-hook 'linum-mode-hook (add-hook 'linum-mode-hook
(lambda () (lambda ()
(setq linum/safe? t) (setq prelude--linum-safe? t)
(when (maybe-some? linum/mru-color) (when (maybe-some? prelude--linum-mru-color)
(set-face-foreground 'linum 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'. "Safely set linum color to `COLOR'.
If this is called before Emacs initializes, the color will be stored in 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? Why is this safe?
If `(set-face-foreground 'linum)' is called before initialization completes, If `(set-face-foreground 'linum)' is called before initialization completes,
Emacs will silently fail. Without this function, it is easy to introduce Emacs will silently fail. Without this function, it is easy to introduce
difficult to troubleshoot bugs in your init files." difficult to troubleshoot bugs in your init files."
(if linum/safe? (if prelude--linum-safe?
(set-face-foreground 'linum color) (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 input from user with PROMPT."
(read-string 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. "Pass command string, COMMAND, and the function name, NAME.
This is a wrapper around `start-process' that has an API that resembles This is a wrapper around `start-process' that has an API that resembles
`shell-command'." `shell-command'."
;; TODO: Fix the bug with tokenizing here, since it will split any whitespace ;; 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. ;; 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'") ;; e.g. - "xmodmap -e 'one two three'" => '("xmodmap" "-e" "'one two three'")
(prelude/refute (string/contains? "'" command)) (prelude-refute (s-contains? "'" command))
(let* ((tokens (string/split " " command)) (let* ((tokens (s-split " " command))
(program-name (list/head tokens)) (program-name (nth 0 tokens))
(program-args (list/tail tokens))) (program-args (cdr tokens)))
(apply #'start-process (apply #'start-process
`(,(string/format "*%s<%s>*" program-name name) `(,(format "*%s<%s>*" program-name name)
,nil ,nil
,program-name ,program-name
,@program-args)))) ,@program-args))))
(defun prelude/executable-exists? (name) (defun prelude-executable-exists? (name)
"Return t if CLI tool NAME exists according to `exec-path'." "Return t if CLI tool NAME exists according to `exec-path'."
(let ((file (locate-file name exec-path))) (let ((file (locate-file name exec-path)))
(require 'maybe) (require 'maybe)
@ -141,7 +136,7 @@ This is a wrapper around `start-process' that has an API that resembles
(f-exists? file) (f-exists? file)
nil))) nil)))
(defmacro prelude/time (x) (defmacro prelude-time (x)
"Print the time it takes to evaluate X." "Print the time it takes to evaluate X."
`(benchmark 1 ',x)) `(benchmark 1 ',x))

View file

@ -35,7 +35,7 @@
(defun pulse-audio-toggle-mute () (defun pulse-audio-toggle-mute ()
"Mute the default sink." "Mute the default sink."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "pulse-audio-toggle-mute" :name "pulse-audio-toggle-mute"
:command "pactl set-sink-mute @DEFAULT_SINK@ toggle") :command "pactl set-sink-mute @DEFAULT_SINK@ toggle")
(pulse-audio--message "Mute toggled.")) (pulse-audio--message "Mute toggled."))
@ -43,7 +43,7 @@
(defun pulse-audio-toggle-microphone () (defun pulse-audio-toggle-microphone ()
"Mute the default sink." "Mute the default sink."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "pulse-audio-toggle-microphone" :name "pulse-audio-toggle-microphone"
:command "pactl set-source-mute @DEFAULT_SOURCE@ toggle") :command "pactl set-source-mute @DEFAULT_SOURCE@ toggle")
(pulse-audio--message "Microphone toggled.")) (pulse-audio--message "Microphone toggled."))
@ -51,7 +51,7 @@
(defun pulse-audio-decrease-volume () (defun pulse-audio-decrease-volume ()
"Low the volume output of the default sink." "Low the volume output of the default sink."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "pulse-audio-decrease-volume" :name "pulse-audio-decrease-volume"
:command (string/format "pactl set-sink-volume @DEFAULT_SINK@ -%s%%" :command (string/format "pactl set-sink-volume @DEFAULT_SINK@ -%s%%"
pulse-audio--step-size)) pulse-audio--step-size))
@ -60,7 +60,7 @@
(defun pulse-audio-increase-volume () (defun pulse-audio-increase-volume ()
"Raise the volume output of the default sink." "Raise the volume output of the default sink."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "pulse-audio-increase-volume" :name "pulse-audio-increase-volume"
:command (string/format "pactl set-sink-volume @DEFAULT_SINK@ +%s%%" :command (string/format "pactl set-sink-volume @DEFAULT_SINK@ +%s%%"
pulse-audio--step-size)) pulse-audio--step-size))

View file

@ -64,7 +64,7 @@
;; TODO: Support random-sample ;; TODO: Support random-sample
;; (defun random-sample (n xs) ;; (defun random-sample (n xs)
;; "Return a randomly sample of list XS of size N." ;; "Return a randomly sample of list XS of size N."
;; (prelude/assert (and (>= n 0) (< n (list/length xs)))) ;; (prelude-assert (and (>= n 0) (< n (list/length xs))))
;; (cl-labels ((do-sample ;; (cl-labels ((do-sample
;; (n xs y ys) ;; (n xs y ys)
;; (if (= n (set/count ys)) ;; (if (= n (set/count ys))

View file

@ -28,7 +28,7 @@
(defun screen-brightness/increase () (defun screen-brightness/increase ()
"Increase the screen brightness." "Increase the screen brightness."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "screen-brightness/increase" :name "screen-brightness/increase"
:command (string/format "xbacklight -inc %s" screen-brightness/step-size)) :command (string/format "xbacklight -inc %s" screen-brightness/step-size))
(message "[screen-brightness.el] Increased screen brightness.")) (message "[screen-brightness.el] Increased screen brightness."))
@ -36,7 +36,7 @@
(defun screen-brightness/decrease () (defun screen-brightness/decrease ()
"Decrease the screen brightness." "Decrease the screen brightness."
(interactive) (interactive)
(prelude/start-process (prelude-start-process
:name "screen-brightness/decrease" :name "screen-brightness/decrease"
:command (string/format "xbacklight -dec %s" screen-brightness/step-size)) :command (string/format "xbacklight -dec %s" screen-brightness/step-size))
(message "[screen-brightness.el] Decreased screen brightness.")) (message "[screen-brightness.el] Decreased screen brightness."))

View file

@ -113,59 +113,59 @@
(when set/enable-testing? (when set/enable-testing?
;; set/distinct? ;; set/distinct?
(prelude/assert (prelude-assert
(set/distinct? (set/new 'one 'two 'three) (set/distinct? (set/new 'one 'two 'three)
(set/new 'a 'b 'c))) (set/new 'a 'b 'c)))
(prelude/refute (prelude-refute
(set/distinct? (set/new 1 2 3) (set/distinct? (set/new 1 2 3)
(set/new 3 4 5))) (set/new 3 4 5)))
(prelude/refute (prelude-refute
(set/distinct? (set/new 1 2 3) (set/distinct? (set/new 1 2 3)
(set/new 1 2 3))) (set/new 1 2 3)))
;; set/equal? ;; set/equal?
(prelude/refute (prelude-refute
(set/equal? (set/new 'a 'b 'c) (set/equal? (set/new 'a 'b 'c)
(set/new 'x 'y 'z))) (set/new 'x 'y 'z)))
(prelude/refute (prelude-refute
(set/equal? (set/new 'a 'b 'c) (set/equal? (set/new 'a 'b 'c)
(set/new 'a 'b))) (set/new 'a 'b)))
(prelude/assert (prelude-assert
(set/equal? (set/new 'a 'b 'c) (set/equal? (set/new 'a 'b 'c)
(set/new 'a 'b 'c))) (set/new 'a 'b 'c)))
;; set/intersection ;; set/intersection
(prelude/assert (prelude-assert
(set/equal? (set/new 2 3) (set/equal? (set/new 2 3)
(set/intersection (set/new 1 2 3) (set/intersection (set/new 1 2 3)
(set/new 2 3 4)))) (set/new 2 3 4))))
;; set/{from,to}-list ;; set/{from,to}-list
(prelude/assert (equal '(1 2 3) (prelude-assert (equal '(1 2 3)
(->> '(1 1 2 2 3 3) (->> '(1 1 2 2 3 3)
set/from-list set/from-list
set/to-list))) set/to-list)))
(let ((primary-colors (set/new "red" "green" "blue"))) (let ((primary-colors (set/new "red" "green" "blue")))
;; set/subset? ;; set/subset?
(prelude/refute (prelude-refute
(set/subset? (set/new "black" "grey") (set/subset? (set/new "black" "grey")
primary-colors)) primary-colors))
(prelude/assert (prelude-assert
(set/subset? (set/new "red") (set/subset? (set/new "red")
primary-colors)) primary-colors))
;; set/superset? ;; set/superset?
(prelude/refute (prelude-refute
(set/superset? primary-colors (set/superset? primary-colors
(set/new "black" "grey"))) (set/new "black" "grey")))
(prelude/assert (prelude-assert
(set/superset? primary-colors (set/superset? primary-colors
(set/new "red" "green" "blue"))) (set/new "red" "green" "blue")))
(prelude/assert (prelude-assert
(set/superset? primary-colors (set/superset? primary-colors
(set/new "red" "blue")))) (set/new "red" "blue"))))
;; set/empty? ;; set/empty?
(prelude/assert (set/empty? (set/new))) (prelude-assert (set/empty? (set/new)))
(prelude/refute (set/empty? (set/new 1 2 3))) (prelude-refute (set/empty? (set/new 1 2 3)))
;; set/count ;; set/count
(prelude/assert (= 0 (set/count (set/new)))) (prelude-assert (= 0 (set/count (set/new))))
(prelude/assert (= 2 (set/count (set/new 1 1 2 2))))) (prelude-assert (= 2 (set/count (set/new 1 1 2 2)))))
(provide 'set) (provide 'set)
;;; set.el ends here ;;; set.el ends here

View file

@ -111,15 +111,15 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (when string/test? ;; (when string/test?
;; (prelude/assert ;; (prelude-assert
;; (string= ;; (string=
;; (string/surround "-*-" "surround") ;; (string/surround "-*-" "surround")
;; "-*-surround-*-")) ;; "-*-surround-*-"))
;; (prelude/assert ;; (prelude-assert
;; (string= ;; (string=
;; (string/caps->kebab "CAPS_CASE_STRING") ;; (string/caps->kebab "CAPS_CASE_STRING")
;; "caps-case-string")) ;; "caps-case-string"))
;; (prelude/assert ;; (prelude-assert
;; (string= ;; (string=
;; (string/kebab->caps "kebab-case-string") ;; (string/kebab->caps "kebab-case-string")
;; "KEBAB_CASE_STRING"))) ;; "KEBAB_CASE_STRING")))

View file

@ -78,11 +78,11 @@ This is an adapter interface to `setf'."
(cl-defstruct dummy name age) (cl-defstruct dummy name age)
(defvar test-dummy (make-dummy :name "Roofus" :age 19)) (defvar test-dummy (make-dummy :name "Roofus" :age 19))
(struct/set! dummy name "Doofus" test-dummy) (struct/set! dummy name "Doofus" test-dummy)
(prelude/assert (string= "Doofus" (dummy-name test-dummy))) (prelude-assert (string= "Doofus" (dummy-name test-dummy)))
(let ((result (struct/set dummy name "Shoofus" test-dummy))) (let ((result (struct/set dummy name "Shoofus" test-dummy)))
;; Test the immutability of `struct/set' ;; Test the immutability of `struct/set'
(prelude/assert (string= "Doofus" (dummy-name test-dummy))) (prelude-assert (string= "Doofus" (dummy-name test-dummy)))
(prelude/assert (string= "Shoofus" (dummy-name result))))) (prelude-assert (string= "Shoofus" (dummy-name result)))))
(provide 'struct) (provide 'struct)
;;; struct.el ends here ;;; struct.el ends here

View file

@ -184,13 +184,13 @@ A tree is balanced if none of the differences between any two depths of two leaf
(list (tree-node 9) (list (tree-node 9)
(tree-node 10))))))) (tree-node 10)))))))
;; instance? ;; instance?
(prelude/assert (tree-instance? tree-a)) (prelude-assert (tree-instance? tree-a))
(prelude/assert (tree-instance? tree-b)) (prelude-assert (tree-instance? tree-b))
(prelude/refute (tree-instance? '(1 2 3))) (prelude-refute (tree-instance? '(1 2 3)))
(prelude/refute (tree-instance? "oak")) (prelude-refute (tree-instance? "oak"))
;; balanced? ;; balanced?
(prelude/assert (tree-balanced? 1 tree-a)) (prelude-assert (tree-balanced? 1 tree-a))
(prelude/refute (tree-balanced? 1 tree-b)) (prelude-refute (tree-balanced? 1 tree-b))
(message "Tests pass!"))) (message "Tests pass!")))
(provide 'tree) (provide 'tree)

View file

@ -69,12 +69,12 @@ This function mutates XS."
(when vector-enable-tests? (when vector-enable-tests?
(let ((xs [1 2 3]) (let ((xs [1 2 3])
(ys [1 2 3])) (ys [1 2 3]))
(prelude/assert (= 1 (vector-get 0 ys))) (prelude-assert (= 1 (vector-get 0 ys)))
(vector-set 0 4 ys) (vector-set 0 4 ys)
(prelude/assert (= 1 (vector-get 0 ys))) (prelude-assert (= 1 (vector-get 0 ys)))
(prelude/assert (= 1 (vector-get 0 xs))) (prelude-assert (= 1 (vector-get 0 xs)))
(vector-set! 0 4 xs) (vector-set! 0 4 xs)
(prelude/assert (= 4 (vector-get 0 xs))))) (prelude-assert (= 4 (vector-get 0 xs)))))
;; TODO: Decide between "remove" and "delete" as the appropriate verbs. ;; TODO: Decide between "remove" and "delete" as the appropriate verbs.
;; TODO: Implement this. ;; TODO: Implement this.

View file

@ -43,7 +43,7 @@
(defmacro vterm-mgt--assert-vterm-buffer () (defmacro vterm-mgt--assert-vterm-buffer ()
"Error when the `current-buffer' is not a vterm buffer." "Error when the `current-buffer' is not a vterm buffer."
'(prelude/assert (vterm-mgt--instance? (current-buffer)))) '(prelude-assert (vterm-mgt--instance? (current-buffer))))
(defun vterm-mgt-next () (defun vterm-mgt-next ()
"Replace the current buffer with the next item in `vterm-mgt--instances'. "Replace the current buffer with the next item in `vterm-mgt--instances'.

View file

@ -80,7 +80,7 @@
"List of `window-manager--named-workspace' structs.") "List of `window-manager--named-workspace' structs.")
;; Assert that no two workspaces share KBDs. ;; Assert that no two workspaces share KBDs.
(prelude/assert (= (list/length window-manager--named-workspaces) (prelude-assert (= (list/length window-manager--named-workspaces)
(->> window-manager--named-workspaces (->> window-manager--named-workspaces
(list/map #'window-manager--named-workspace-kbd) (list/map #'window-manager--named-workspace-kbd)
set/from-list set/from-list
@ -188,7 +188,7 @@
cycle/from-list) cycle/from-list)
"Cycle of the my EXWM workspaces.") "Cycle of the my EXWM workspaces.")
(prelude/assert (prelude-assert
(= exwm-workspace-number (= exwm-workspace-number
(list/length window-manager--named-workspaces))) (list/length window-manager--named-workspaces)))