Lint string, macros.el

More of the same type of linting... basically preferring `namespace-` instead of
`namespace/`.
This commit is contained in:
William Carroll 2020-08-31 23:28:47 +01:00
parent 158f810981
commit a638e15c0d
36 changed files with 176 additions and 204 deletions

View file

@ -2,4 +2,4 @@
# name: redux-action # name: redux-action
# key: rax # key: rax
# -- # --
export const ${1:$$(string/lower->caps yas-text)} = '`(downcase (buffer-dirname))`/${1:$(string/caps->kebab yas-text)}' export const ${1:$$(string-lower->caps yas-text)} = '`(downcase (buffer-dirname))`/${1:$(string-caps->kebab yas-text)}'

View file

@ -2,4 +2,4 @@
# name: typed-redux-action # name: typed-redux-action
# key: trax # key: trax
# -- # --
export const ${1:$$(string/lower->caps yas-text)}: '`(downcase (buffer-dirname))`/${1:$(string/caps->kebab yas-text)}' = '`(downcase (buffer-dirname))`/${1:$(string/caps->kebab yas-text)}' export const ${1:$$(string-lower->caps yas-text)}: '`(downcase (buffer-dirname))`/${1:$(string-caps->kebab yas-text)}' = '`(downcase (buffer-dirname))`/${1:$(string-caps->kebab yas-text)}'

View file

@ -233,7 +233,7 @@ In this case, the last writer wins, which is B."
;; - update-all ;; - update-all
;; Scratch-pad ;; Scratch-pad
(macros/comment (macros-comment
(progn (progn
(setq person '((first-name . "William") (setq person '((first-name . "William")
(first-name . "William") (first-name . "William")

View file

@ -45,7 +45,7 @@
(alist/has-key? x (bag-xs xs))) (alist/has-key? x (bag-xs xs)))
;; TODO: Tabling this for now since working with structs seems to be ;; TODO: Tabling this for now since working with structs seems to be
;; disappointingly difficult. Where is `struct/update'? ;; disappointingly difficult. Where is `struct-update'?
;; (defun bag/add (x xs) ;; (defun bag/add (x xs)
;; "Add X to XS.") ;; "Add X to XS.")

View file

@ -85,7 +85,7 @@ Otherwise, open with `counsel-find-file'."
(general-define-key (general-define-key
:prefix "<SPC>" :prefix "<SPC>"
:states '(normal) :states '(normal)
(string/concat "j" (bookmark-kbd b)) (string-concat "j" (bookmark-kbd b))
;; TODO: Consider `cl-labels' so `which-key' minibuffer is more ;; TODO: Consider `cl-labels' so `which-key' minibuffer is more
;; helpful. ;; helpful.
(lambda () (interactive) (bookmark/open b))))))) (lambda () (interactive) (bookmark/open b)))))))

View file

@ -121,7 +121,7 @@ Return a reference to that buffer."
(if (> (ts-diff (ts-now) last-called) (if (> (ts-diff (ts-now) last-called)
buffer/source-code-timeout) buffer/source-code-timeout)
(progn (progn
(struct/set! source-code-cycle (struct-set! source-code-cycle
cycle cycle
(cycle/from-list (buffer/source-code-buffers)) (cycle/from-list (buffer/source-code-buffers))
buffer/source-code-cycle-state) buffer/source-code-cycle-state)
@ -129,7 +129,7 @@ Return a reference to that buffer."
buffer/source-code-cycle-state))) buffer/source-code-cycle-state)))
(funcall cycle-fn cycle) (funcall cycle-fn cycle)
(switch-to-buffer (cycle/current cycle))) (switch-to-buffer (cycle/current cycle)))
(struct/set! source-code-cycle (struct-set! source-code-cycle
last-called last-called
(ts-now) (ts-now)
buffer/source-code-cycle-state)) buffer/source-code-cycle-state))

View file

@ -83,7 +83,7 @@
('gigabyte (tuple/from bytes/gb "GB")) ('gigabyte (tuple/from bytes/gb "GB"))
('terabyte (tuple/from bytes/tb "TB")) ('terabyte (tuple/from bytes/tb "TB"))
('petabyte (tuple/from bytes/pb "PB"))))) ('petabyte (tuple/from bytes/pb "PB")))))
(string/format "%d%s" (string-format "%d%s"
(round x (tuple/first base-and-unit)) (round x (tuple/first base-and-unit))
(tuple/second base-and-unit)))) (tuple/second base-and-unit))))

View file

@ -44,7 +44,7 @@
(defun cache/touch (x xs) (defun cache/touch (x xs)
"Ensure value X in cache, XS, is front of the list. "Ensure value X in cache, XS, is front of the list.
If X isn't in XS (using `equal'), insert it at the front." If X isn't in XS (using `equal'), insert it at the front."
(struct/update (struct-update
cache cache
xs xs
(>> (list/reject (lambda (y) (equal x y))) (>> (list/reject (lambda (y) (equal x y)))

View file

@ -72,7 +72,7 @@ Cycle prev otherwise."
(cycle/next colorscheme/whitelist) (cycle/next colorscheme/whitelist)
(cycle/prev colorscheme/whitelist)))) (cycle/prev colorscheme/whitelist))))
(colorscheme/set theme) (colorscheme/set theme)
(message (s-concat "Active theme: " (symbol/to-string theme))))) (message (s-concat "Active theme: " (symbol-to-string theme)))))
(defun colorscheme/next () (defun colorscheme/next ()
"Disable the currently active theme and load the next theme." "Disable the currently active theme and load the next theme."

View file

@ -94,16 +94,16 @@ underlying struct."
"Return the next value in `XS' and update `current-index'." "Return the next value in `XS' and update `current-index'."
(let* ((current-index (cycle-current-index xs)) (let* ((current-index (cycle-current-index xs))
(next-index (next-index-> 0 (cycle/count xs) current-index))) (next-index (next-index-> 0 (cycle/count xs) current-index)))
(struct/set! cycle previous-index current-index xs) (struct-set! cycle previous-index current-index xs)
(struct/set! cycle current-index next-index xs) (struct-set! cycle current-index next-index xs)
(nth next-index (cycle-xs xs)))) (nth next-index (cycle-xs xs))))
(defun cycle/prev (xs) (defun cycle/prev (xs)
"Return the previous value in `XS' and update `current-index'." "Return the previous value in `XS' and update `current-index'."
(let* ((current-index (cycle-current-index xs)) (let* ((current-index (cycle-current-index xs))
(next-index (next-index<- 0 (cycle/count xs) current-index))) (next-index (next-index<- 0 (cycle/count xs) current-index)))
(struct/set! cycle previous-index current-index xs) (struct-set! cycle previous-index current-index xs)
(struct/set! cycle current-index next-index xs) (struct-set! cycle current-index next-index xs)
(nth next-index (cycle-xs xs)))) (nth next-index (cycle-xs xs))))
(defun cycle/current (cycle) (defun cycle/current (cycle)
@ -118,8 +118,8 @@ underlying struct."
"Jump to the I index of XS." "Jump to the I index of XS."
(let ((current-index (cycle-current-index xs)) (let ((current-index (cycle-current-index xs))
(next-index (math/mod i (cycle/count xs)))) (next-index (math/mod i (cycle/count xs))))
(struct/set! cycle previous-index current-index xs) (struct-set! cycle previous-index current-index xs)
(struct/set! cycle current-index next-index xs)) (struct-set! cycle current-index next-index xs))
xs) xs)
(defun cycle/focus (p cycle) (defun cycle/focus (p cycle)
@ -155,19 +155,19 @@ ITEM is the first item in XS that t for `equal'."
If there is no currently focused item, add X to the beginning of XS." If there is no currently focused item, add X to the beginning of XS."
(if (cycle/empty? xs) (if (cycle/empty? xs)
(progn (progn
(struct/set! cycle xs (list x) xs) (struct-set! cycle xs (list x) xs)
(struct/set! cycle current-index 0 xs) (struct-set! cycle current-index 0 xs)
(struct/set! cycle previous-index nil xs)) (struct-set! cycle previous-index nil xs))
(let ((curr-i (cycle-current-index xs)) (let ((curr-i (cycle-current-index xs))
(prev-i (cycle-previous-index xs))) (prev-i (cycle-previous-index xs)))
(if curr-i (if curr-i
(progn (progn
(struct/set! cycle xs (-insert-at curr-i x (cycle-xs xs)) xs) (struct-set! cycle xs (-insert-at curr-i x (cycle-xs xs)) xs)
(when (>= prev-i curr-i) (struct/set! cycle previous-index (1+ prev-i) xs)) (when (>= prev-i curr-i) (struct-set! cycle previous-index (1+ prev-i) xs))
(when curr-i (struct/set! cycle current-index (1+ curr-i) xs))) (when curr-i (struct-set! cycle current-index (1+ curr-i) xs)))
(progn (progn
(struct/set! cycle xs (cons x (cycle-xs xs)) xs) (struct-set! cycle xs (cons x (cycle-xs xs)) xs)
(when prev-i (struct/set! cycle previous-index (1+ prev-i) xs)))) (when prev-i (struct-set! cycle previous-index (1+ prev-i) xs))))
xs))) xs)))
(defun cycle/remove (x xs) (defun cycle/remove (x xs)
@ -181,13 +181,13 @@ If X is the currently focused value, after it's deleted, current-index will be
(let ((curr-i (cycle-current-index xs)) (let ((curr-i (cycle-current-index xs))
(prev-i (cycle-previous-index xs)) (prev-i (cycle-previous-index xs))
(rm-i (-elem-index x (cycle-xs xs)))) (rm-i (-elem-index x (cycle-xs xs))))
(struct/set! cycle xs (-remove-at rm-i (cycle-xs xs)) xs) (struct-set! cycle xs (-remove-at rm-i (cycle-xs xs)) xs)
(when prev-i (when prev-i
(when (> prev-i rm-i) (struct/set! cycle previous-index (1- prev-i) xs)) (when (> prev-i rm-i) (struct-set! cycle previous-index (1- prev-i) xs))
(when (= prev-i rm-i) (struct/set! cycle previous-index nil xs))) (when (= prev-i rm-i) (struct-set! cycle previous-index nil xs)))
(when curr-i (when curr-i
(when (> curr-i rm-i) (struct/set! cycle current-index (1- curr-i) xs)) (when (> curr-i rm-i) (struct-set! cycle current-index (1- curr-i) xs))
(when (= curr-i rm-i) (struct/set! cycle current-index nil xs))) (when (= curr-i rm-i) (struct-set! cycle current-index nil xs)))
xs)) xs))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -48,7 +48,7 @@ The car models the enabled state of my laptop display; the cdr models the
(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"
display/4k-monitor display/4k-monitor
display/laptop-monitor))) display/laptop-monitor)))
@ -58,7 +58,7 @@ The car models the enabled state of my laptop display; the cdr models the
(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)))
(defun display/enable-laptop () (defun display/enable-laptop ()
@ -68,7 +68,7 @@ Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
(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)))
(defun display/disable-laptop () (defun display/disable-laptop ()
@ -78,7 +78,7 @@ Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
(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)))
(defun display/cycle-display-states () (defun display/cycle-display-states ()

View file

@ -87,7 +87,7 @@
(defun fonts/set (font &optional size) (defun fonts/set (font &optional size)
"Change the font to `FONT' with option integer, SIZE, in pixels." "Change the font to `FONT' with option integer, SIZE, in pixels."
(if (maybe-some? size) (if (maybe-some? size)
(set-frame-font (string/format "%s %s" font size) nil t) (set-frame-font (string-format "%s %s" font size) nil t)
(set-frame-font font nil t))) (set-frame-font font nil t)))
(defun fonts/whitelist-set (font) (defun fonts/whitelist-set (font)
@ -107,7 +107,7 @@ The size of the font is determined by `fonts/size'."
"Message the currently enabled font." "Message the currently enabled font."
(interactive) (interactive)
(message (message
(string/format "[fonts] Current font: \"%s\"" (string-format "[fonts] Current font: \"%s\""
(fonts/current)))) (fonts/current))))
(defun fonts/current () (defun fonts/current ()

View file

@ -111,7 +111,7 @@
(defun wpc/evil-replace-under-point () (defun wpc/evil-replace-under-point ()
"Faster than typing %s//thing/g." "Faster than typing %s//thing/g."
(interactive) (interactive)
(let ((term (s-replace "/" "\\/" (symbol/to-string (symbol-at-point))))) (let ((term (s-replace "/" "\\/" (symbol-to-string (symbol-at-point)))))
(save-excursion (save-excursion
(evil-ex (concat "%s/\\b" term "\\b/"))))) (evil-ex (concat "%s/\\b" term "\\b/")))))

View file

@ -87,7 +87,7 @@
(defun irc/message (x) (defun irc/message (x)
"Print message X in a structured way." "Print message X in a structured way."
(message (string/format "[irc.el] %s" x))) (message (string-format "[irc.el] %s" x)))
;; TODO: Integrate Google setup with Freenode setup. ;; TODO: Integrate Google setup with Freenode setup.
@ -136,7 +136,7 @@
(erc-join-channel (erc-join-channel
(cycle/next cycle)) (cycle/next cycle))
(irc/message (irc/message
(string/format "Current IRC channel: %s" (cycle/current cycle)))))) (string-format "Current IRC channel: %s" (cycle/current cycle))))))
(defun irc/prev-channel () (defun irc/prev-channel ()
"Join the previous channel for the active server." "Join the previous channel for the active server."
@ -146,10 +146,10 @@
(erc-join-channel (erc-join-channel
(cycle/prev cycle)) (cycle/prev cycle))
(irc/message (irc/message
(string/format "Current IRC channel: %s" (cycle/current cycle)))))) (string-format "Current IRC channel: %s" (cycle/current cycle))))))
(add-hook 'erc-mode-hook (disable auto-fill-mode)) (add-hook 'erc-mode-hook (macros-disable auto-fill-mode))
(add-hook 'erc-mode-hook (disable company-mode)) (add-hook 'erc-mode-hook (macros-disable company-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keybindings ;; Keybindings

View file

@ -50,7 +50,7 @@ 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)
x)) x))
@ -69,14 +69,14 @@ Values for F include:
(interactive) (interactive)
(message "[kbd] Awaiting keypress...") (message "[kbd] Awaiting keypress...")
(let ((key (read-key))) (let ((key (read-key)))
(clipboard/copy (string/format "%s" key)) (clipboard/copy (string-format "%s" key))
(message (string/format "[kbd] \"%s\" copied!" key)))) (message (string-format "[kbd] \"%s\" copied!" key))))
(defun kbd/print-keycode () (defun kbd/print-keycode ()
"Prints the pressed keybinding." "Prints the pressed keybinding."
(interactive) (interactive)
(message "[kbd] Awaiting keypress...") (message "[kbd] Awaiting keypress...")
(message (string/format "[kbd] keycode: %s" (read-key)))) (message (string-format "[kbd] keycode: %s" (read-key))))
(provide 'kbd) (provide 'kbd)
;;; kbd.el ends here ;;; kbd.el ends here

View file

@ -45,7 +45,7 @@
(defun keyboard/message (x) (defun keyboard/message (x)
"Message X in a structured way." "Message X in a structured way."
(message (string/format "[keyboard.el] %s" x))) (message (string-format "[keyboard.el] %s" x)))
(cl-defun keyboard/set-key-repeat (&key (cl-defun keyboard/set-key-repeat (&key
(rate keyboard/repeat-rate) (rate keyboard/repeat-rate)
@ -53,7 +53,7 @@
"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)))
;; NOTE: Settings like this are machine-dependent. For instance I only need to ;; NOTE: Settings like this are machine-dependent. For instance I only need to
;; do this on my laptop and other devices where I don't have access to my split ;; do this on my laptop and other devices where I don't have access to my split
@ -78,7 +78,7 @@
(setq keyboard/repeat-rate (number/inc keyboard/repeat-rate)) (setq keyboard/repeat-rate (number/inc keyboard/repeat-rate))
(keyboard/set-key-repeat :rate keyboard/repeat-rate) (keyboard/set-key-repeat :rate keyboard/repeat-rate)
(keyboard/message (keyboard/message
(string/format "Rate: %s" keyboard/repeat-rate))) (string-format "Rate: %s" keyboard/repeat-rate)))
(defun keyboard/dec-repeat-rate () (defun keyboard/dec-repeat-rate ()
"Decrement `keyboard/repeat-rate'." "Decrement `keyboard/repeat-rate'."
@ -86,7 +86,7 @@
(setq keyboard/repeat-rate (number/dec keyboard/repeat-rate)) (setq keyboard/repeat-rate (number/dec keyboard/repeat-rate))
(keyboard/set-key-repeat :rate keyboard/repeat-rate) (keyboard/set-key-repeat :rate keyboard/repeat-rate)
(keyboard/message (keyboard/message
(string/format "Rate: %s" keyboard/repeat-rate))) (string-format "Rate: %s" keyboard/repeat-rate)))
(defun keyboard/inc-repeat-delay () (defun keyboard/inc-repeat-delay ()
"Increment `keyboard/repeat-delay'." "Increment `keyboard/repeat-delay'."
@ -94,7 +94,7 @@
(setq keyboard/repeat-delay (number/inc keyboard/repeat-delay)) (setq keyboard/repeat-delay (number/inc keyboard/repeat-delay))
(keyboard/set-key-repeat :delay keyboard/repeat-delay) (keyboard/set-key-repeat :delay keyboard/repeat-delay)
(keyboard/message (keyboard/message
(string/format "Delay: %s" keyboard/repeat-delay))) (string-format "Delay: %s" keyboard/repeat-delay)))
(defun keyboard/dec-repeat-delay () (defun keyboard/dec-repeat-delay ()
"Decrement `keyboard/repeat-delay'." "Decrement `keyboard/repeat-delay'."
@ -102,13 +102,13 @@
(setq keyboard/repeat-delay (number/dec keyboard/repeat-delay)) (setq keyboard/repeat-delay (number/dec keyboard/repeat-delay))
(keyboard/set-key-repeat :delay keyboard/repeat-delay) (keyboard/set-key-repeat :delay keyboard/repeat-delay)
(keyboard/message (keyboard/message
(string/format "Delay: %s" keyboard/repeat-delay))) (string-format "Delay: %s" keyboard/repeat-delay)))
(defun keyboard/print-key-repeat () (defun keyboard/print-key-repeat ()
"Print the currently set values for key repeat." "Print the currently set values for key repeat."
(interactive) (interactive)
(keyboard/message (keyboard/message
(string/format "Rate: %s. Delay: %s" (string-format "Rate: %s. Delay: %s"
keyboard/repeat-rate keyboard/repeat-rate
keyboard/repeat-delay))) keyboard/repeat-delay)))

View file

@ -79,7 +79,7 @@
"" ""
(list/reduce (list/first xs) (list/reduce (list/first xs)
(lambda (x acc) (lambda (x acc)
(string/concat acc joint x)) (string-concat acc joint x))
(list/tail xs)))) (list/tail xs))))
(defun list/length (xs) (defun list/length (xs)

View file

@ -1,5 +1,9 @@
;;; macros.el --- Helpful variables for making my ELisp life more enjoyable -*- lexical-binding: t -*- ;;; macros.el --- Helpful variables for making my ELisp life more enjoyable -*- lexical-binding: t -*-
;; Authpr: William Carroll <wpcarro@gmail.com>
;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "24"))
;;; Commentary: ;;; Commentary:
;; This file contains helpful variables that I use in my ELisp development. ;; This file contains helpful variables that I use in my ELisp development.
@ -9,51 +13,44 @@
;;; Code: ;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'f) (require 'f)
(require 'string) (require 'string)
(require 'symbol) (require 'symbol)
;; TODO: Support `xi' lambda shorthand macro. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro enable (mode) (defmacro macros-enable (mode)
"Helper for enabling `MODE'. "Helper for enabling `MODE'.
Useful in `add-hook' calls. Some modes, like `linum-mode' need to be called as Useful in `add-hook' calls. Some modes, like `linum-mode' need to be called as
`(linum-mode 1)', so `(add-hook mode #'linum-mode)' won't work." `(linum-mode 1)', so `(add-hook mode #'linum-mode)' won't work."
`#'(lambda nil (,mode 1))) `#'(lambda nil (,mode 1)))
(defmacro disable (mode) (defmacro macros-disable (mode)
"Helper for disabling `MODE'. "Helper for disabling `MODE'.
Useful in `add-hook' calls." Useful in `add-hook' calls."
`#'(lambda nil (,mode -1))) `#'(lambda nil (,mode -1)))
(defmacro add-hooks (modes callback) (defmacro macros-add-hook-before-save (mode f)
"Add multiple `MODES' for the `CALLBACK'.
Usage: (add-hooks '(one-mode-hook 'two-mode-hook) #'fn)"
`(dolist (mode ,modes)
(add-hook mode ,callback)))
(defmacro add-hook-before-save (mode f)
"Register a hook, `F', for a mode, `MODE' more conveniently. "Register a hook, `F', for a mode, `MODE' more conveniently.
Usage: (add-hook-before-save 'reason-mode-hook #'refmt-before-save)" Usage: (add-hook-before-save 'reason-mode-hook #'refmt-before-save)"
`(add-hook ,mode `(add-hook ,mode
(lambda () (lambda ()
(add-hook 'before-save-hook ,f)))) (add-hook 'before-save-hook ,f))))
;; TODO: Debug.
(defmacro macros/ilambda (&rest body)
"Surrounds `BODY' with an interactive lambda function."
`(lambda ()
(interactive)
,@body))
;; TODO: Privatize? ;; TODO: Privatize?
(defun namespace () (defun macros--namespace ()
"Return the namespace for a function based on the filename." "Return the namespace for a function based on the filename."
(->> (buffer-file-name) (->> (buffer-file-name)
f-filename f-filename
f-base)) f-base))
(defmacro macros/comment (&rest _) (defmacro macros-comment (&rest _)
"Empty comment s-expresion where `BODY' is ignored." "Empty comment s-expresion where `BODY' is ignored."
`nil) `nil)
@ -64,31 +61,10 @@ Usage: (add-hook-before-save 'reason-mode-hook #'refmt-before-save)"
`(lambda (,sym) `(lambda (,sym)
(->> ,sym ,@forms)))) (->> ,sym ,@forms))))
;; TOOD: Support this. (defmacro macros-support-file-extension (ext mode)
(cl-defmacro macros/test
(&key function
test
args
expect
equality)
(let* ((namespace (namespace))
(test-name (string/->symbol
(s-concat namespace
"/"
"test"
"/"
(s-chop-prefix
(s-concat namespace "/")
(symbol/to-string function))))))
`(ert-deftest ,test-name ()
,test
(should (,equality (apply ,function ,args)
,expect)))))
(defmacro macros/support-file-extension (ext mode)
"Register MODE to automatically load with files ending with EXT extension. "Register MODE to automatically load with files ending with EXT extension.
Usage: (macros/support-file-extension \"pb\" protobuf-mode)" Usage: (macros-support-file-extension \"pb\" protobuf-mode)"
(let ((extension (string/format "\\.%s\\'" ext))) (let ((extension (string-format "\\.%s\\'" ext)))
`(add-to-list 'auto-mode-alist '(,extension . ,mode)))) `(add-to-list 'auto-mode-alist '(,extension . ,mode))))
(provide 'macros) (provide 'macros)

View file

@ -30,7 +30,7 @@
(defun pulse-audio--message (x) (defun pulse-audio--message (x)
"Output X to *Messages*." "Output X to *Messages*."
(message (string/format "[pulse-audio.el] %s" x))) (message (string-format "[pulse-audio.el] %s" x)))
(defun pulse-audio-toggle-mute () (defun pulse-audio-toggle-mute ()
"Mute the default sink." "Mute the default sink."
@ -53,7 +53,7 @@
(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))
(pulse-audio--message "Volume decreased.")) (pulse-audio--message "Volume decreased."))
@ -62,7 +62,7 @@
(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))
(pulse-audio--message "Volume increased.")) (pulse-audio--message "Volume increased."))

View file

@ -37,7 +37,7 @@ The newest bindings eclipse the oldest."
(defun scope/push-new (xs) (defun scope/push-new (xs)
"Push a new, empty scope onto XS." "Push a new, empty scope onto XS."
(struct/update scope (struct-update scope
scopes scopes
(>> (stack/push (alist/new))) (>> (stack/push (alist/new)))
xs)) xs))
@ -65,7 +65,7 @@ The newest bindings eclipse the oldest."
(defun scope/set (k v xs) (defun scope/set (k v xs)
"Set value, V, at key, K, in XS for the current scope." "Set value, V, at key, K, in XS for the current scope."
(struct/update scope (struct-update scope
scopes scopes
(>> (stack/map-top (>> (alist/set k v)))) (>> (stack/map-top (>> (alist/set k v))))
xs)) xs))

View file

@ -30,7 +30,7 @@
(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."))
(defun screen-brightness/decrease () (defun screen-brightness/decrease ()
@ -38,7 +38,7 @@
(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."))
(provide 'screen-brightness) (provide 'screen-brightness)

View file

@ -34,7 +34,7 @@ See scrot's man page for more information.")
This currently only works for PNG files because that's what I'm outputting" This currently only works for PNG files because that's what I'm outputting"
(call-process "xclip" nil nil nil (call-process "xclip" nil nil nil
"-selection" "clipboard" "-t" "image/png" path) "-selection" "clipboard" "-t" "image/png" path)
(message (string/format "[scrot.el] Image copied to clipboard!"))) (message (string-format "[scrot.el] Image copied to clipboard!")))
(defmacro scrot/call (&rest args) (defmacro scrot/call (&rest args)
"Call scrot with ARGS." "Call scrot with ARGS."

View file

@ -45,7 +45,7 @@
(defun set/add (x xs) (defun set/add (x xs)
"Add X to set XS." "Add X to set XS."
(struct/update set (struct-update set
xs xs
(lambda (table) (lambda (table)
(let ((table-copy (ht-copy table))) (let ((table-copy (ht-copy table)))

View file

@ -1,5 +1,9 @@
;;; ssh.el --- When working remotely -*- lexical-binding: t -*- ;;; ssh.el --- When working remotely -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "24"))
;;; Commentary: ;;; Commentary:
;; Configuration to make remote work easier. ;; Configuration to make remote work easier.

View file

@ -1,5 +1,9 @@
;;; stack.el --- Working with stacks in Elisp -*- lexical-binding: t -*- ;;; stack.el --- Working with stacks in Elisp -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "25.1"))
;;; Commentary: ;;; Commentary:
;; A stack is a LIFO queue. ;; A stack is a LIFO queue.
@ -46,7 +50,7 @@
(defun stack/push (x xs) (defun stack/push (x xs)
"Push `X' on `XS'." "Push `X' on `XS'."
(struct/update stack (struct-update stack
xs xs
(>> (list/cons x)) (>> (list/cons x))
xs)) xs))
@ -57,7 +61,7 @@
"Return the stack, `XS', without the top element. "Return the stack, `XS', without the top element.
Since I cannot figure out a nice way of return tuples in Elisp, if you want to Since I cannot figure out a nice way of return tuples in Elisp, if you want to
look at the first element, use `stack/peek' before running `stack/pop'." look at the first element, use `stack/peek' before running `stack/pop'."
(struct/update stack (struct-update stack
xs xs
(>> list/tail) (>> list/tail)
xs)) xs))

View file

@ -1,5 +1,9 @@
;; string.el --- Library for working with strings -*- lexical-binding: t -*- ;; string.el --- Library for working with strings -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "24"))
;;; Commentary: ;;; Commentary:
;; Library for working with string. ;; Library for working with string.
@ -19,56 +23,53 @@
;; Library ;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst string/test? t (defun string-contains? (c x)
"When t, run the tests.")
(defun string/contains? (c x)
"Return t if X is in C." "Return t if X is in C."
(s-contains? c x)) (s-contains? c x))
(defun string/hookify (x) (defun string-hookify (x)
"Append \"-hook\" to X." "Append \"-hook\" to X."
(s-append "-hook" x)) (s-append "-hook" x))
(defun string/split (y x) (defun string-split (y x)
"Map string X into a list of strings that were separated by Y." "Map string X into a list of strings that were separated by Y."
(s-split y x)) (s-split y x))
(defun string/ensure-hookified (x) (defun string-ensure-hookified (x)
"Ensure that X has \"-hook\" appended to it." "Ensure that X has \"-hook\" appended to it."
(if (s-ends-with? "-hook" x) (if (s-ends-with? "-hook" x)
x x
(string/hookify x))) (string-hookify x)))
(defun string/format (x &rest args) (defun string-format (x &rest args)
"Format template string X with ARGS." "Format template string X with ARGS."
(apply #'format (cons x args))) (apply #'format (cons x args)))
(defun string/concat (&rest strings) (defun string-concat (&rest strings)
"Joins `STRINGS' into onto string." "Joins `STRINGS' into onto string."
(apply #'s-concat strings)) (apply #'s-concat strings))
(defun string/->symbol (string) (defun string-->symbol (string)
"Maps `STRING' to a symbol." "Maps `STRING' to a symbol."
(intern string)) (intern string))
(defun string/<-symbol (symbol) (defun string-<-symbol (symbol)
"Maps `SYMBOL' into a string." "Maps `SYMBOL' into a string."
(symbol-name symbol)) (symbol-name symbol))
(defun string/prepend (prefix x) (defun string-prepend (prefix x)
"Prepend `PREFIX' onto `X'." "Prepend `PREFIX' onto `X'."
(s-concat prefix x)) (s-concat prefix x))
(defun string/append (postfix x) (defun string-append (postfix x)
"Appen `POSTFIX' onto `X'." "Appen `POSTFIX' onto `X'."
(s-concat x postfix)) (s-concat x postfix))
(defun string/surround (s x) (defun string-surround (s x)
"Surrounds `X' one each side with `S'." "Surrounds `X' one each side with `S'."
(->> x (->> x
(string/prepend s) (string-prepend s)
(string/append s))) (string-append s)))
;; TODO: Define a macro for defining a function and a test. ;; TODO: Define a macro for defining a function and a test.
@ -76,25 +77,25 @@
;; Casing ;; Casing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun string/caps->kebab (x) (defun string-caps->kebab (x)
"Change the casing of `X' from CAP_CASE to kebab-case." "Change the casing of `X' from CAP_CASE to kebab-case."
(->> x (->> x
s-downcase s-downcase
(s-replace "_" "-"))) (s-replace "_" "-")))
(defun string/kebab->caps (x) (defun string-kebab->caps (x)
"Change the casing of X from CAP_CASE to kebab-case." "Change the casing of X from CAP_CASE to kebab-case."
(->> x (->> x
s-upcase s-upcase
(s-replace "-" "_"))) (s-replace "-" "_")))
(defun string/lower->caps (x) (defun string-lower->caps (x)
"Change the casing of X from lowercase to CAPS_CASE." "Change the casing of X from lowercase to CAPS_CASE."
(->> x (->> x
s-upcase s-upcase
(s-replace " " "_"))) (s-replace " " "_")))
(defun string/lower->kebab (x) (defun string-lower->kebab (x)
"Change the casing of `X' from lowercase to kebab-case." "Change the casing of `X' from lowercase to kebab-case."
(s-replace " " "-" x)) (s-replace " " "-" x))
@ -102,27 +103,9 @@
;; Predicates ;; Predicates
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun string/instance? (x) (defun string-instance? (x)
"Return t if X is a string." "Return t if X is a string."
(stringp x)) (stringp x))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (when string/test?
;; (prelude-assert
;; (string=
;; (string/surround "-*-" "surround")
;; "-*-surround-*-"))
;; (prelude-assert
;; (string=
;; (string/caps->kebab "CAPS_CASE_STRING")
;; "caps-case-string"))
;; (prelude-assert
;; (string=
;; (string/kebab->caps "kebab-case-string")
;; "KEBAB_CASE_STRING")))
(provide 'string) (provide 'string)
;;; string.el ends here ;;; string.el ends here

View file

@ -1,5 +1,9 @@
;;; struct.el --- Helpers for working with structs -*- lexical-binding: t -*- ;;; struct.el --- Helpers for working with structs -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "24.3"))
;;; Commentary: ;;; Commentary:
;; Provides new macros for working with structs. Also provides adapter ;; Provides new macros for working with structs. Also provides adapter
@ -10,12 +14,6 @@
;;; Code: ;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Wish list
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - TODO: Replace `symbol-name' and `intern' calls with isomorphism.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies ;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -27,44 +25,44 @@
;; Library ;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar struct/enable-tests? t (defvar struct--enable-tests? t
"When t, run the test suite defined herein.") "When t, run the test suite defined herein.")
(defmacro struct/update (type field f xs) (defmacro struct-update (type field f xs)
"Apply F to FIELD in XS, which is a struct of TYPE. "Apply F to FIELD in XS, which is a struct of TYPE.
This is immutable." This is immutable."
(let ((copier (->> type (let ((copier (->> type
symbol-name symbol-name
(string/prepend "copy-") (string-prepend "copy-")
intern)) intern))
(accessor (->> field (accessor (->> field
symbol-name symbol-name
(string/prepend (string/concat (symbol-name type) "-")) (string-prepend (string-concat (symbol-name type) "-"))
intern))) intern)))
`(let ((copy (,copier ,xs))) `(let ((copy (,copier ,xs)))
(setf (,accessor copy) (funcall ,f (,accessor copy))) (setf (,accessor copy) (funcall ,f (,accessor copy)))
copy))) copy)))
(defmacro struct/set (type field x xs) (defmacro struct-set (type field x xs)
"Immutably set FIELD in XS (struct TYPE) to X." "Immutably set FIELD in XS (struct TYPE) to X."
(let ((copier (->> type (let ((copier (->> type
symbol-name symbol-name
(string/prepend "copy-") (string-prepend "copy-")
intern)) intern))
(accessor (->> field (accessor (->> field
symbol-name symbol-name
(string/prepend (string/concat (symbol-name type) "-")) (string-prepend (string-concat (symbol-name type) "-"))
intern))) intern)))
`(let ((copy (,copier ,xs))) `(let ((copy (,copier ,xs)))
(setf (,accessor copy) ,x) (setf (,accessor copy) ,x)
copy))) copy)))
(defmacro struct/set! (type field x xs) (defmacro struct-set! (type field x xs)
"Set FIELD in XS (struct TYPE) to X mutably. "Set FIELD in XS (struct TYPE) to X mutably.
This is an adapter interface to `setf'." This is an adapter interface to `setf'."
(let ((accessor (->> field (let ((accessor (->> field
symbol-name symbol-name
(string/prepend (string/concat (symbol-name type) "-")) (string-prepend (string-concat (symbol-name type) "-"))
intern))) intern)))
`(progn `(progn
(setf (,accessor ,xs) ,x) (setf (,accessor ,xs) ,x)
@ -74,14 +72,14 @@ This is an adapter interface to `setf'."
;; Tests ;; Tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when struct/enable-tests? (when struct--enable-tests?
(cl-defstruct dummy name age) (cl-defstruct dummy name age)
(defvar test-dummy (make-dummy :name "Roofus" :age 19)) (defvar struct--test-dummy (make-dummy :name "Roofus" :age 19))
(struct/set! dummy name "Doofus" test-dummy) (struct-set! dummy name "Doofus" struct--test-dummy)
(prelude-assert (string= "Doofus" (dummy-name test-dummy))) (prelude-assert (string= "Doofus" (dummy-name struct--test-dummy)))
(let ((result (struct/set dummy name "Shoofus" test-dummy))) (let ((result (struct-set dummy name "Shoofus" struct--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 struct--test-dummy)))
(prelude-assert (string= "Shoofus" (dummy-name result))))) (prelude-assert (string= "Shoofus" (dummy-name result)))))
(provide 'struct) (provide 'struct)

View file

@ -1,17 +1,27 @@
;; symbol.el --- Library for working with symbols. -*- lexical-binding: t -*- ;; symbol.el --- Library for working with symbols. -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "24"))
;;; Commentary: ;;; Commentary:
;; Library for working with symbols. ;; Library for working with symbols.
;;; Code: ;;; Code:
;; TODO: Why is ivy mode map everywhere? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'string) (require 'string)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Symbols ;; Symbols
(defun symbol/as-string (callback x) (defun symbol-as-string (callback x)
"Treat the symbol, X, as a string while applying CALLBACK to it. "Treat the symbol, X, as a string while applying CALLBACK to it.
Coerce back to a symbol on the way out." Coerce back to a symbol on the way out."
(->> x (->> x
@ -19,23 +29,19 @@ Coerce back to a symbol on the way out."
callback callback
#'intern)) #'intern))
(defun symbol/to-string (x) (defun symbol-to-string (x)
"Map `X' into a string." "Map `X' into a string."
(string/<-symbol x)) (string-<-symbol x))
(defun symbol/hookify (x) (defun symbol-hookify (x)
"Append \"-hook\" to X when X is a symbol." "Append \"-hook\" to X when X is a symbol."
(symbol/as-string #'string/hookify x)) (symbol-as-string #'string-hookify x))
(defun symbol/ensure-hookified (x) (defun symbol-ensure-hookified (x)
"Ensure that X has \"-hook\" appended to it when X is a symbol." "Ensure that X has \"-hook\" appended to it when X is a symbol."
(symbol/as-string #'string/ensure-hookified x)) (symbol-as-string #'string-ensure-hookified x))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun symbol-instance? (x)
;; Predicates
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun symbol/instance? (x)
"Return t if X is a symbol." "Return t if X is a symbol."
(symbolp x)) (symbolp x))

View file

@ -2,8 +2,8 @@
;; Author: William Carroll <wpcarro@gmail.com> ;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1 ;; Version: 0.0.1
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;; Package-Requires: ((emacs "25.1")) ;; Package-Requires: ((emacs "25.1"))
;; Homepage: https://user.git.corp.google.com/wpcarro/briefcase
;;; Commentary: ;;; Commentary:

View file

@ -88,7 +88,7 @@
(defun window-manager--alert (x) (defun window-manager--alert (x)
"Message X with a structured format." "Message X with a structured format."
(alert (string/concat "[exwm] " x))) (alert (string-concat "[exwm] " x)))
;; Use Emacs as my primary window manager. ;; Use Emacs as my primary window manager.
(use-package exwm (use-package exwm
@ -274,10 +274,10 @@ Ivy is used to capture the user's input."
(interactive) (interactive)
(let* ((name->cmd `(("Lock" . ,window-manager--xsecurelock) (let* ((name->cmd `(("Lock" . ,window-manager--xsecurelock)
("Logout" . "sudo systemctl stop lightdm") ("Logout" . "sudo systemctl stop lightdm")
("Suspend" . ,(string/concat ("Suspend" . ,(string-concat
window-manager--xsecurelock window-manager--xsecurelock
" && systemctl suspend")) " && systemctl suspend"))
("Hibernate" . ,(string/concat ("Hibernate" . ,(string-concat
window-manager--xsecurelock window-manager--xsecurelock
" && systemctl hibernate")) " && systemctl hibernate"))
("Reboot" . "systemctl reboot") ("Reboot" . "systemctl reboot")
@ -313,7 +313,7 @@ Currently using super- as the prefix for switching workspaces."
(window-manager--named-workspace-label workspace) (window-manager--named-workspace-label workspace)
window-manager--named-workspaces)) window-manager--named-workspaces))
(window-manager--alert (window-manager--alert
(string/format "Switched to: %s" (string-format "Switched to: %s"
(window-manager--named-workspace-label workspace)))) (window-manager--named-workspace-label workspace))))
(defun window-manager--switch (label) (defun window-manager--switch (label)

View file

@ -30,7 +30,7 @@
nil))) nil)))
;; TODO: Find a way to incorporate these into function documentation. ;; TODO: Find a way to incorporate these into function documentation.
(macros/comment (macros-comment
(window-find "*scratch*")) (window-find "*scratch*"))
(defun window-delete (window) (defun window-delete (window)

View file

@ -11,9 +11,15 @@
;;; Code: ;;; Code:
;; TODO: Ensure sorting in dired is by type. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Rename wpc-dired.el to file-management.el (require 'macros)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(progn (progn
(require 'dired) (require 'dired)
@ -32,7 +38,7 @@
"f" #'project-find-file "f" #'project-find-file
"-" (lambda () (interactive) (find-alternate-file ".."))) "-" (lambda () (interactive) (find-alternate-file "..")))
(general-add-hook 'dired-mode-hook (general-add-hook 'dired-mode-hook
(list (enable dired-hide-details-mode) (list (macros-enable dired-hide-details-mode)
#'auto-revert-mode))) #'auto-revert-mode)))
(progn (progn

View file

@ -15,6 +15,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'prelude) (require 'prelude)
(require 'macros)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration ;; Configuration
@ -40,7 +41,7 @@
(add-hook 'go-mode-hook (lambda () (add-hook 'go-mode-hook (lambda ()
(set (make-local-variable 'compile-command) (set (make-local-variable 'compile-command)
"go build -v"))) "go build -v")))
(add-hook-before-save 'go-mode-hook #'gofmt-before-save)) (macros-add-hook-before-save 'go-mode-hook #'gofmt-before-save))
(provide 'wpc-golang) (provide 'wpc-golang)
;;; wpc-golang.el ends here ;;; wpc-golang.el ends here

View file

@ -15,6 +15,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'f) (require 'f)
(require 'macros)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration ;; Configuration
@ -24,15 +25,15 @@
:config :config
(evil-set-initial-state 'org-mode 'normal) (evil-set-initial-state 'org-mode 'normal)
(general-add-hook 'org-mode-hook (general-add-hook 'org-mode-hook
(list (disable linum-mode) (list (macros-disable linum-mode)
(disable company-mode))) (macros-disable company-mode)))
(setq org-startup-folded nil) (setq org-startup-folded nil)
(setq org-todo-keywords '((sequence "TODO" "BLOCKED" "DONE"))) (setq org-todo-keywords '((sequence "TODO" "BLOCKED" "DONE")))
(general-unbind 'normal org-mode-map "M-h" "M-j" "M-k" "M-l")) (general-unbind 'normal org-mode-map "M-h" "M-j" "M-k" "M-l"))
(use-package org-bullets (use-package org-bullets
:config :config
(general-add-hook 'org-mode-hook (enable org-bullets-mode))) (general-add-hook 'org-mode-hook (macros-enable org-bullets-mode)))
(provide 'wpc-org) (provide 'wpc-org)
;;; wpc-org.el ends here ;;; wpc-org.el ends here

View file

@ -14,7 +14,7 @@
;; TODO: Notice that the .pl extension conflicts with Perl files. This may ;; TODO: Notice that the .pl extension conflicts with Perl files. This may
;; become a problem should I start working with Perl. ;; become a problem should I start working with Perl.
(macros/support-file-extension "pl" prolog-mode) (macros-support-file-extension "pl" prolog-mode)
(provide 'wpc-prolog) (provide 'wpc-prolog)
;;; wpc-prolog.el ends here ;;; wpc-prolog.el ends here

View file

@ -69,13 +69,6 @@
;; disable toolbar ;; disable toolbar
(tool-bar-mode -1) (tool-bar-mode -1)
;; TODO: Re-enable `linum-mode' when I figure out why the theming is so ugly.
;; enable line numbers
;; (general-add-hook '(prog-mode-hook
;; text-mode-hook
;; conf-mode-hook)
;; (enable linum-mode))
;; set default buffer for Emacs ;; set default buffer for Emacs
(setq initial-buffer-choice constants/current-project) (setq initial-buffer-choice constants/current-project)