Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@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.

;;; 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 / 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 / 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 / Firefox-Gtk2-build-1.patch
Last active January 26, 2022 03:05
Patch Firefox 49.0.2 to build with Gtk2
This 1) adjusts the Mozilla mozconfig.gtk file according
to the comments in it, and 2) removes a directory from
the debian/firefox.install.in file that comes up empty
when building with Gtk2, which then causes the package
build to fail due to trying to include files from an
empty directory (don't ask me why the gtk2 directory
is empty when built with Gtk2).
---
build/unix/mozconfig.gtk | 25 +------------------------
debian/firefox.install.in | 1 -
@wzhd
wzhd / .gitignore
Last active December 20, 2016 09:17 — forked from xiaoganghan/mynote.xml
Parsing Evernote export file (.enex) using Python
*.enex
#!/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
@wasamasa
wasamasa / filter-buffer.el
Last active October 10, 2017 19:45
Emacs buffer filtering
(defun my-filter-current-buffer (program &rest args)
(let* ((stdout-buffer (generate-new-buffer " stdout"))
(ret (apply 'call-process-region (point-min) (point-max) program
nil (list stdout-buffer) nil args)))
(when (zerop ret)
(let ((output (with-current-buffer stdout-buffer
(buffer-string))))
(erase-buffer)
(insert output)))
(kill-buffer stdout-buffer)))
@alphapapa
alphapapa / helm-org-tag-completion.el
Last active December 21, 2022 15:45
Complete multiple org-mode tags with helm
;;;;;; Fix Helm org tag completion
;; From Anders Johansson <https://groups.google.com/d/msg/emacs-helm/tA6cn6TUdRY/G1S3TIdzBwAJ>
;; This works great! He posted it on 3 Mar 2016, on a thread that was
;; started in Oct 2013. He also posted this message on 2 Apr 2014,
;; maybe an earlier attempt at a solution:
;; <http://article.gmane.org/gmane.emacs.orgmode/84495> I've just
;; tidied it up a bit and adjusted the prompt.
(add-to-list 'helm-completing-read-handlers-alist '(org-capture . aj/org-completing-read-tags))
@alphapapa
alphapapa / org-agenda-subtree-or-region.el
Last active March 21, 2016 10:46
Emacs: Display org-agenda for current subtree or region
(defun org-agenda-subtree-or-region (prefix)
"Display an agenda view for the current subtree or region.
With prefix, display only TODO-keyword items."
(interactive "p")
(let (header)
(if (use-region-p)
(progn
(setq header "Region")
(put 'org-agenda-files 'org-restrict (list (buffer-file-name (current-buffer))))
(setq org-agenda-restrict (current-buffer))