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-insert-structure-template-or-enclose-region.el
Last active May 11, 2016 20:25
Enclose a region in an org-mode block (e.g. #+BEGIN_SRC), or insert a structure template with completion
(defun org-read-structure-template ()
"Read org-mode structure template with completion. Returns template string."
(let* ((templates (map 'list 'second org-structure-template-alist))
(prefixes (map 'list (lambda (tp)
;; Get template and pre-whitespace prefix for completion
(reverse (s-match (rx (group
(1+ (not (any "\n" space))))
(1+ anything))
tp)))
templates))
@alphapapa
alphapapa / createshortcut.js
Created October 23, 2016 01:26 — forked from amzyang/createshortcut.js
create pentadactyl commandline options
// createshortcut.js -- ++pentadactyl
// @Author: eric.zou (frederick.zou@gmail.com)
// @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
// @Created: Tue 29 Nov 2011 01:24:05 PM CST
// @Last Change: Tue 29 Nov 2011 02:23:36 PM CST
// @Revision: 41
// @Description:
// @Usage:
// @TODO:
// @CHANGES:
@alphapapa
alphapapa / outline-mode-folding-python-elisp-shell.el
Created March 22, 2015 08:23
Emacs: outline-mode folding for Python, elisp, and shell
(defun my/python-mode-outline-hook ()
(setq outline-level 'my/python-outline-level)
(setq outline-regexp
(rx (or
;; Commented outline heading
(group
(* space) ; 0 or more spaces
(one-or-more (syntax comment-start))
(one-or-more space)
@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 / 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