diff options
-rw-r--r-- | users/wpcarro/common.nix | 15 | ||||
-rw-r--r-- | users/wpcarro/emacs/.emacs.d/wpc/fonts.el | 70 | ||||
-rw-r--r-- | users/wpcarro/emacs/.emacs.d/wpc/keybindings.el | 9 | ||||
-rw-r--r-- | users/wpcarro/emacs/.emacs.d/wpc/wpc-misc.el | 12 | ||||
-rw-r--r-- | users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el | 8 | ||||
-rw-r--r-- | users/wpcarro/emacs/default.nix | 31 |
6 files changed, 49 insertions, 96 deletions
diff --git a/users/wpcarro/common.nix b/users/wpcarro/common.nix index dcda9e10a4b0..4e960bee4ec5 100644 --- a/users/wpcarro/common.nix +++ b/users/wpcarro/common.nix @@ -44,7 +44,7 @@ in # machines. shell-utils = with pkgs; [ bat - dig + coreutils direnv diskus emacs @@ -55,13 +55,11 @@ in gnupg htop jq - mkpasswd nmap pass python3 rink ripgrep - sysz tldr tokei tree @@ -71,5 +69,14 @@ in # wpcarro.tools.simple_vim xclip zip - ]; + ] ++ + (if pkgs.stdenv.isLinux then [ + mkpasswd + sysz + # This depends on compiler-rt-libc-10.0.1, which is marked as broken on + # aarch64-darwin, but depot sets `allowBroken = true`, which means any + # build that depends on dig will fail on OSX (e.g. emacs). + # https://cs.tvl.fyi/github.com/NixOS/nixpkgs@e9b195248c6cd7961a453b10294aea9ab58e01b4/-/blob/pkgs/development/compilers/llvm/10/compiler-rt/default.nix?L122 + dig + ] else [ ]); } diff --git a/users/wpcarro/emacs/.emacs.d/wpc/fonts.el b/users/wpcarro/emacs/.emacs.d/wpc/fonts.el index 9490896ae7cc..3d79b71157fb 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/fonts.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/fonts.el @@ -35,84 +35,16 @@ (defconst fonts-size-step 10 "The amount (%) by which to increase or decrease a font.") -(defconst fonts-hacker-news-recommendations - '("APL385 Unicode" - "Go Mono" - "Sudo" - "Monoid" - "Input Mono Medium" ;; NOTE: Also "Input Mono Thin" is nice. - ) - "List of fonts optimized for programming I found in a HN article.") - -(defconst fonts-whitelist - (cycle-from-list - (list-concat - fonts-hacker-news-recommendations - '("JetBrainsMono" - "Mononoki Medium" - "Monospace" - "Operator Mono Light" - "Courier" - "Andale Mono" - "Source Code Pro" - "Terminus"))) - "This is a list of my preferred fonts.") - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TODO: fonts and fonts-whitelist make it difficult to name functions like -;; fonts-set as a generic Emacs function vs choosing a font from the whitelist. - -(cl-defun fonts-cycle (&key forward?) - "Cycle forwards when `FORWARD?' non-nil." - (let ((font (if forward? - (cycle-next! fonts-whitelist) - (cycle-prev! fonts-whitelist)))) - (message (s-concat "Active font: " font)) - (fonts-set font))) - -(defun fonts-next () - "Quickly cycle through preferred fonts." - (interactive) - (fonts-cycle :forward? t)) - -(defun fonts-prev () - "Quickly cycle through preferred fonts." - (interactive) - (fonts-cycle :forward? nil)) - (defun fonts-set (font &optional size) "Change the font to `FONT' with option integer, SIZE, in pixels." (if (maybe-some? size) (set-frame-font (string-format "%s %s" font size) nil t) (set-frame-font font nil t))) -(defun fonts-whitelist-set (font) - "Focuses the FONT in the `fonts-whitelist' cycle. -The size of the font is determined by `fonts-size'." - (prelude-assert (cycle-contains? font fonts-whitelist)) - (cycle-focus! (lambda (x) (equal x font)) fonts-whitelist) - (fonts-set (fonts-current) fonts-size)) - -(defun fonts-ivy-select () - "Select a font from an ivy prompt." - (interactive) - (fonts-whitelist-set - (ivy-read "Font: " (cycle-to-list fonts-whitelist)))) - -(defun fonts-print-current () - "Message the currently enabled font." - (interactive) - (message - (string-format "[fonts] Current font: \"%s\"" - (fonts-current)))) - -(defun fonts-current () - "Return the currently enabled font." - (cycle-current fonts-whitelist)) - (defun fonts-increase-size () "Increase font size." (interactive) @@ -130,7 +62,7 @@ The size of the font is determined by `fonts-size'." (defun fonts-reset-size () "Restore font size to its default value." (interactive) - (fonts-whitelist-set (fonts-current))) + (fonts-set (fonts-current) fonts-size)) (defun fonts-enable-ligatures () "Call this function to enable ligatures." diff --git a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el index 16b3d6c8f3e8..ebd6f2fe5615 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el @@ -36,7 +36,6 @@ (require 'bookmark) (require 'tvl) (require 'window-manager) -(require 'wpc-misc) ;; Note: The following lines must be sorted this way. (setq evil-want-integration t) @@ -210,7 +209,13 @@ (keybindings-exwm "<M-S-iso-lefttab>" #'window-manager-prev-workspace) (keybindings-exwm "C-S-f" #'window-manager-toggle-previous) (keybindings-exwm "C-M-\\" #'ivy-pass) -(keybindings-exwm "s-e" #'wpc-misc-copy-emoji) + +(defun keybindings-copy-emoji () + "Select an emoji from the completing-read menu." + (interactive) + (clipboard-copy (emojify-completing-read "Copy: "))) + +(keybindings-exwm "s-e" #'keybindings-copy-emoji) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Workspaces diff --git a/users/wpcarro/emacs/.emacs.d/wpc/wpc-misc.el b/users/wpcarro/emacs/.emacs.d/wpc/wpc-misc.el index cac16d26bdd1..604cfa502109 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/wpc-misc.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/wpc-misc.el @@ -180,12 +180,6 @@ ;; configure ibuffer (setq ibuffer-default-sorting-mode 'major-mode) -;; config Emacs to use $PATH values -(use-package exec-path-from-shell - :if (memq window-system '(mac ns)) - :config - (exec-path-from-shell-initialize)) - ;; Emacs autosave, backup, interlocking files (setq auto-save-default nil make-backup-files nil @@ -326,11 +320,7 @@ ;; Disable the default styles of: ;; - ascii :P (When this is enabled, the vim command, :x, renders as 😶) ;; - github :smile: - (setq emojify-emoji-styles '(unicode)) - (defun wpc-misc-copy-emoji () - "Select an emoji from the completing-read menu." - (interactive) - (clipboard-copy (emojify-completing-read "Copy: ")))) + (setq emojify-emoji-styles '(unicode))) ;; Always auto-close parantheses and other pairs (electric-pair-mode) diff --git a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el index b39a82ad9f63..ce2f8beb7284 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el @@ -164,8 +164,12 @@ (colorscheme-whitelist-set 'doom-peacock) (when window-system - (let ((font "Monospace")) - (fonts-whitelist-set font) + ;; On OSX, JetBrainsMono is installed as "JetBrains Mono", and I'm + ;; not sure how to change that. + (let ((font (if (memq window-system '(ns)) + "JetBrains Mono" + "JetBrainsMono"))) + (fonts-set font) ;; Some themes (e.g. doom-acario-*) change the font for comments. This ;; should prevent that. (set-face-attribute font-lock-comment-face nil diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix index 3ca65c292e2c..2fe879583d22 100644 --- a/users/wpcarro/emacs/default.nix +++ b/users/wpcarro/emacs/default.nix @@ -1,3 +1,9 @@ +# My Emacs distribution, which is supporting the following platforms: +# - Linux +# - Darwin +# +# USAGE: +# $ mg build //users/wpcarro/emacs:osx { depot, pkgs, lib, ... }: # TODO(wpcarro): See if it's possible to expose emacsclient on PATH, so that I @@ -26,9 +32,11 @@ let rust-analyzer rustc rustfmt + ] ++ + (if pkgs.stdenv.isLinux then [ scrot xorg.xset - ]) + ] else [ ])) ); emacsWithPackages = (emacsPackagesFor emacs28).emacsWithPackages; @@ -114,8 +122,6 @@ let request pcre2el helpful - # TODO(wpcarro): Determine if Nix solves this problem. - exec-path-from-shell yasnippet projectile deadgrep @@ -171,14 +177,25 @@ let "$@" ''; in -{ - inherit withEmacsPath; - +depot.nix.readTree.drvTargets { + # TODO(wpcarro): Support this with base.overrideAttrs or something similar. nixos = { load ? [ ] }: withEmacsPath { inherit load; emacsBin = "${wpcarrosEmacs}/bin/emacs"; }; + osx = writeShellScriptBin "wpcarros-emacs" '' + export PATH="${emacsBinPath}:$PATH" + export EMACSLOADPATH="${loadPath}" + exec ${wpcarrosEmacs}/bin/emacs \ + --debug-init \ + --no-init-file \ + --no-site-file \ + --no-site-lisp \ + --load ${./.emacs.d/init.el} \ + "$@" + ''; + # Script that asserts my Emacs can initialize without warnings or errors. check = runCommand "check-emacs" { } '' # Even though Buildkite defines this, I'd still like still be able to test @@ -194,6 +211,4 @@ in ${./.emacs.d/init.el} && \ touch $out ''; - - meta.ci.targets = [ "check" ]; } |