Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / emacsconf2013-sacha.org
Created March 9, 2017 15:21 — forked from sachac/emacsconf2013-sacha.org
Source code for my Emacs conference talk

Comments? sacha@sachachua.com

  • Emacs learning curve?

Meta information

Assumptions

  • Mix of Emacs geeks skewed towards people who’ve been using this for a while (after all, takes a certain commitment to come all the way to an Emacs conference!)

Outcomes

#!/usr/bin/env zsh
# -*- coding: UTF8 -*-
# Author: Guillaume Bouvier -- guillaume.bouvier@ens-cachan.org
# 2016-05-10 15:36:06 (UTC+0200)
format_duration()
{
diff=$1 # Duration in seconds
if test $diff -ge 86400; then
@alphapapa
alphapapa / better-org-return.el
Last active April 13, 2017 16:12
Better org-return
(defun ap/org-return (&optional ignore)
"Add new list item, heading or table row with RET.
A double return on an empty element deletes it. Use a prefix arg
to get regular RET. "
;; See https://gist.github.com/alphapapa/61c1015f7d1f0d446bc7fd652b7ec4fe and
;; http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/
(interactive "P")
(if ignore
(org-return)
(cond ((eq 'link (car (org-element-context)))
@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))))
@alphapapa
alphapapa / README.md
Created June 24, 2017 21:23 — forked from Fuco1/README.md
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 / upgrade-to-org-9.0.org
Created July 25, 2017 04:49
Checklist for upgrading to Org 9.0

UNDERWAY Upgrade org

  • State “UNDERWAY” from [2017-04-23 Sun 01:05]

Upgrade to Org 8.3

;;; 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
@alphapapa
alphapapa / elisp-cider-overlays.el
Created September 7, 2017 01:28
CIDER-like overlays for Emacs eval'ing
;;;;;; CIDER overlays
;; Very cool!
;; http://endlessparentheses.com/eval-result-overlays-in-emacs-lisp.html
;;;;;;; CIDER code
;; If I ever install CIDER, I can remove this part.
(defface cider-result-overlay-face
@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)