Skip to content

Instantly share code, notes, and snippets.

@herbertjones
herbertjones / with-new-window StumpWM macro.lisp
Last active August 23, 2018 02:04
with-new-window StumpWM macro
;; Non-macro macro helper
(defun run-and-act-on-new-window (cmd props timeout function)
"Run a command, setup a handler to apply a function to the new window once it's open."
(let* (focus-window-handler
timeout-handler
(timer (run-with-timer timeout nil
#'(lambda ()
;; Remove hooks after period of time should something go wrong.
(when focus-window-handler
(remove-hook *focus-window-hook* focus-window-handler))
@herbertjones
herbertjones / bash-notes.org
Created February 1, 2019 04:45
Bash notes

Language Features

Variables and newlines

# Normal assignment doesn't work.
lines=$(printf "abc\n123\n\n"); echo -n "$lines" | wc -l
# 1  -- WRONG
empty=$(printf ""); echo -n "$empty" | wc -l
# 0  -- WRONG

# Problem is that variable assignment strips all newlines when assigning the
@herbertjones
herbertjones / org-roam-multi-dir.el
Last active February 20, 2020 15:44
Org-Roam multiple directories workaround hack
(defvar org-roam-directories nil
"Paths to org-roam files. List where CAR is name and CDR is path.")
;; Example:
;; (setq org-roam-directories '(("Home roam" . "~/Documents/home-roam")
;; ("Work roam" . "~/Documents/work-roam")))
;; Set first directory
(setq org-roam-directory (cdar org-roam-directories))
@herbertjones
herbertjones / org-roam-search.el
Last active March 8, 2020 23:52
Org-roam search for backlinks
;;; -*- lexical-binding: t -*-
(defun org-roam-search ()
"Search for backlinks for a given article in a new buffer."
(interactive)
(let* ((source-org-roam-directory org-roam-directory)
(completions (org-roam--get-title-path-completions))
(title (completing-read "File: " completions))
(file-path (cdr (assoc title completions)))
(buf-name (format "*org-roam-search-%s*" title))