Skip to content

Instantly share code, notes, and snippets.

View alexispurslane's full-sized avatar

Alexis Purslane alexispurslane

View GitHub Profile
@alexispurslane
alexispurslane / sort-by-tags.el
Created February 6, 2025 20:53
sort org mode headings by tags
(defun org-sort-by-tags ()
(interactive)
(org-sort-entries nil ?f
(lambda () (org-get-tags (point)))
(lambda (a b)
(let ((a (if (listp (cdr a))
a
(buffer-substring (car a) (cdr a))))
(b (if (listp (cdr b))
b
@alexispurslane
alexispurslane / sitemap.el
Created February 6, 2025 20:51
Advanced org-mode sitemap
(defun user/home-page-sitemap (title list)
"Create a sitemap that allows the user to add a custom preamble, and has not just the top level file structure of your org mode project, but also the top level headings of the top level files, in case you use top level files as categories in a note ontology as I do."
(concat
"
#+begin_export html
<div>
<style scoped>li { padding-top: 0px; }</style>
#+end_export
"
(org-with-file-buffer (concat quake-org-home-directory "blog/sitemap-preamble.org")
@alexispurslane
alexispurslane / org-rss-from-sitemap.el
Last active December 22, 2024 23:01
Generate a full-content RSS feed from an org-mode sitemap, so you can org-publish your blog properly
;;; org-rss-from-sitemap.el --- Generate a full-content RSS feed from an org-publish sitemap -*- lexical-binding: t -*-
;; Author: Alexis Purslane <alexispurlsane@pm.me>
;; This file is not part of GNU Emacs.
;; Copyright (c) by Alexis Purslane 2024.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@alexispurslane
alexispurslane / init.el
Last active June 6, 2024 16:49
Kira's init
(setq gc-cons-threshold-original gc-cons-threshold)
(setq gc-cons-threshold most-positive-fixnum)
(run-with-timer 5 0 (lambda ()
(setq gc-cons-threshold gc-cons-threshold-original)
(message "Restored GC cons threshold")))
;;; ======Prelude======
(require 'cl-lib)
(require 'rx)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
@alexispurslane
alexispurslane / devil-layer.el
Created June 1, 2024 15:23
The basic starter leader-key configuration, for people that want Doom Emacs/Spacemacs like leader keys and don't know where to start. Should only use built-in vanilla Emacs commands!
;;;; Spacemacs/Doom-like evil mode leader key keybindings layer
(defun optional/devil-layer ()
"Define Spacemacs/Doom-style leader keys. This is
high-maintinence, as you won't be able to use any of the
keybindings that come with any Emacs commands or modes by
default, you'll have to bind your own keybindings for all of
them. However, this is the most ergonomic and logical from a
first-principles point of view."
(with-eval-after-load "general"
;;;;;; Create the mode-specific leader key mapping function
@alexispurslane
alexispurslane / org-static-blog-layer.el
Last active June 1, 2024 13:51
Use org mode and emacs to directly generate your blog, no external programs needed!
(defun optional/blog-layer ()
"Blog writing is one of the most common writing tasks there
is. With the existing `task/writing-layer' you should have all
you need to write blog entries, but in case you want to fully
generate and manage your entire blog from inside Emacs, then this
layer is for you.
Loads:
- `async`: so you can run the blog build in the background.
- `org-static-blog': A beautifully simple SSG for org."
@alexispurslane
alexispurslane / eshell-layer.el
Last active June 7, 2024 22:03
Switching from modern, blingful shells like Fish or Nushell to Eshell, and want an eshell config that will feel excellent, modern, and versitile? This is for you.
(defun user/eshell-layer ()
"Make eshell feel like a hyper-modern, advanced, featureful
shell, like Fish or Nushell. Also make eshell output read-only
to avoid confusion.
Loads:
- `eshell-prompt-extras': three beautiful, useful modern prompt
themes, and better tools for building your own.
- `esh-autosuggest': automatically suggest (in grayed out text)
commands from your history based on your current command, which
@alexispurslane
alexispurslane / gnus-proton-mail-layer.el
Last active November 25, 2024 07:32
A complete and fully-working (including STARTTLS encryption and HTML emails) setup to use Proton Mail Bridge with emacs
(defun user/mail-layer ()
"Set GNUS up with asynchronous mail sending, and Proton Mail support,
and a relatively modern layout!
Loads:
- `async': for asynchronous mail"
(use-package async
:demand t
:config
(load "smtpmail-async.el")
@alexispurslane
alexispurslane / tramp-distrobox-layer.el
Last active June 1, 2024 13:47
Want to use Emacs's TRAMP to transparently enter containers you're using as distroboxes/devcontainers? Here's how.
(defun user/tramp-layer ()
"Enable TRAMP to use distrobox to transparently enter containers."
(use-package tramp
:commands (eshell shell term ansi-term)
:custom
(tramp-histfile-override "/dev/null")
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path) ; make sure TRAMP/any shell you use checks the path variable of the container as well as its own
(message "Loading tramp...")
;; TRAMP 2.7.1 will have distrobox built in, so this won't be necessary for much longer!
@alexispurslane
alexispurslane / project-tramp.md
Last active May 27, 2024 02:11
If you're trying to add a project using `project.el` that git deems of "dubious" ownership, `project.el` will crash. Here's a nice fix.

As the tagline says, if you're trying to use Emacs's built-n project-management package, project.el, to add a git version-controlled project that git deems untrustworthy and then do a project-find-{files,dir} on it, it will currently crash, because the output of the git ls-files outputs a bunch of errors to stderr and nothing to stdout, and it doesn't expect to have an empty list of files and directories. To resolve this, I've created a nice snipped of code that will detect, when you add a project, whether git deems it unsafe (git ls-files returns code 128 to mean that) and ask you whether you want to add it to your list of safe directories:

(advice-add 'project-remember-project
                :before (lambda (pr &optional something)
                            (when (and (eq 'Git (cadr pr))
                                       (let ((default-directory (caddr pr)))
                                           (= (shell-command "git ls-files") 128)))
                                (when (y-or-n-