Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / org-avy-refile-as-child.el
Last active April 24, 2017 01:23
org-avy-refile-as-child: Refile Org heading as child of heading selected with Avy
(defun ap/org-avy-refile-as-child ()
"Refile current heading as first child of heading selected with `avy.'"
;; Inspired by `org-teleport': http://kitchingroup.cheme.cmu.edu/blog/2016/03/18/Org-teleport-headlines/
(interactive)
(let* ((org-reverse-note-order t)
(pos (save-excursion
(avy-with avy-goto-line (avy--generic-jump (rx bol "*") nil avy-style))
(point)))
(filename (buffer-file-name (or (buffer-base-buffer (current-buffer))
(current-buffer))))
;;; Neat convenience function for working with Elisp's EIEIO objects
(defmacro oref* (object &rest slots)
"Like `oref', but each slot in SLOTS is applied in sequence.
For example,
\(oref* obj :inner :property)
is equivalent to
@Fuco1
Fuco1 / README.md
Last active November 9, 2017 12:04
org-graph

Relations

Relations are maintained through the outline hierarchy and special properties on the entries so we can model arbitrary graphs instead of only DAGs. This means you can define parents or children completely outside the hierarchy or even in different files.

Relations are kept in sync bidirectionally so please only use the API to maintain them otherwise things might get lost. Because the relations are bidirectional the graph traversal and querying is extremly fast.

Parents

Parents are defined by the GRAPH_PARENTS property as list of IDs and implicitly through the org outline hierarchy: all headlines above this one are this entry's parents.

@alphapapa
alphapapa / replace-words-randomly.el
Created July 24, 2017 22:40
Emacs: Replace all words in buffer with random words of the same length
;; This function replaces all words in a buffer with words of the same length,
;; chosen at random from /usr/share/dict/words. Words are replaced consistently,
;; so e.g. "A" is always replaced with "Z". The mapping changes when Emacs is
;; restarted or when the cache buffer is killed. If all unique words of a certain
;; length are exhausted, random strings are used.
(defun ap/replace-words-randomly (&optional buffer)
"Replace all words in BUFFER or current buffer with randomly selected words from the dictionary.
Every time a new word is found, it is mapped to a replacement
word, so every instance of word A will be replaced with word Z."
@alphapapa
alphapapa / dash-dollar.el
Created September 7, 2017 08:23
Emacs Lisp: -$ macro
(defmacro -$ (&rest body)
(cl-labels ((collect-vars
(&rest forms)
(cl-loop for form in forms
append (cl-loop for atom in form
if (and (symbolp atom)
(string-match (rx bos "$")
(symbol-name atom)))
collect atom
else if (consp form)
@alphapapa
alphapapa / helm-swish.el
Created December 1, 2017 08:47
Like helm-swoop, but faster (bare-bones featurewise, so not a replacement)
;;; Code:
;;;; Requirements
(require 'helm)
;;;; Commands
;;;###autoload
(defun helm-swish ()
@felipeochoa
felipeochoa / pp-debug.el
Last active November 19, 2021 19:59
Pretty print emacs debug frames
;;; pp-debug.el --- Pretty-printing debugger -*- lexical-binding: t -*-
;; Copyright (C) 2018 Felipe Ochoa
;; Author: Felipe Ochoa
;; Created: 5 Dec 2017
;; License: GPLv3
;;; Commentary:
;;; Pretty-print debugger frames.
@alphapapa
alphapapa / ap-helm-find-files.el
Created May 31, 2018 04:03
Custom Helm find-files command
(defun ap/helm-find-files ()
(interactive)
(helm :sources '(ap/helm-source-ivy-views
ap/helm-source-current-file-other-buffers
helm-source-buffers-list
ap/helm-source-files-in-current-dir
helm-source-org-recent-headings
helm-source-bookmarks
ap/helm-source-recentf
ap/helm-source-bindir
@alphapapa
alphapapa / emacs-raise-or-run
Last active February 11, 2020 18:06
emacs-raise-or-run and org-git-add-commit
#!/bin/bash
# ** Vars
# *** Emacs version
if type emacs26 &>/dev/null
then
emacs="emacs26"
emacsclient="emacsclient26"
emacsWindowClass="Emacs"
@alphapapa
alphapapa / elfeed-config.el
Created September 13, 2018 10:41
Elfeed config
;;; elfeed configuration
(use-package elfeed
;;;; Keymaps
:general
(:keymaps '(shr-map)
"a" 'pocket-reader-shr-add-link)
(:keymaps '(elfeed-show-mode-map elfeed-search-mode-map)