Skip to content

Instantly share code, notes, and snippets.

View Drainful's full-sized avatar
🖥️
Enjoying computers

Adrian Fullmer Drainful

🖥️
Enjoying computers
View GitHub Profile
@Drainful
Drainful / envrc-hack.el
Created June 12, 2020 04:36
envrc hack for asynchronous direnv call
;; -*- lexical-binding: t; -*-
(with-eval-after-load 'envrc
(defun envrc--export-async (env-dir result-fn)
(unless (file-exists-p (expand-file-name ".envrc" env-dir))
(error "%s is not a directory with a .envrc" env-dir))
(message "Running direnv in %s..." env-dir)
(unwind-protect
(let ((default-directory env-dir)
(stdout (generate-new-buffer (concat " *direnv output at " env-dir "*")))
(stderr (generate-new-buffer (concat "*envrc at " env-dir "*"))))
@Drainful
Drainful / emacs-next-integration.el
Last active November 30, 2019 05:40
Code for sending common lisp sexps to Next
(require 'slime)
(defvar next-browser-connection nil)
(defun get-next-browser-connection ()
(if (and next-browser-connection
(find next-browser-connection slime-net-processes))
next-browser-connection
(aif (ignore-errors
(slime-net-connect "localhost"
@Drainful
Drainful / scaled-scroll.lisp
Created November 22, 2019 01:12
Versions of the Next scroll to top/bottom functions which function regardless of current zoom.
(define-parenscript %scroll-to-top--scaled
((scale (next:current-zoom-ratio (next:current-buffer))))
(ps:chain window (scroll-by 0 (* (ps:lisp scale)
(- (ps:chain document body scroll-height))))))
(define-parenscript %scroll-to-bottom--scaled
((scale (next:current-zoom-ratio (next:current-buffer))))
(ps:chain window (scroll-by 0 (* (ps:lisp scale)
(ps:chain document body scroll-height)))))
@Drainful
Drainful / emacs-hook.el
Last active April 15, 2020 12:52
Example shell.nix setting environment variables through emacsHook
;; direnv (and lorri) are necessary for this to be useful
(use-package direnv
:config
(direnv-mode)
;; This advice evaluates the contents of the emacsHook environment
;; variable when direnv updates. Note that this runs every time
;; direnv-update-directory-environment is called whether or not
;; there was a change.
(defun run-emacs-hook ()
(when (getenv "emacsHook")