Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@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)))
@x4lldux
x4lldux / x4-smarter-beginning-of-line.el
Created May 25, 2013 14:13
Smarter beginning of the line
;; Smart beginning of the line
(defun x4-smarter-beginning-of-line ()
"Move point to beginning-of-line or first non-whitespace character or first non-whitespace after a comment sign."
(interactive "^")
(let (
(oldpos (point))
(indentpos (progn
(back-to-indentation)
(point)
)
@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.

@jordonbiondo
jordonbiondo / dll-fifo.el
Created December 30, 2015 15:17
A fifo queue in emacs lisp using a cyclic doubly linked list.
;; FIFO queue implementation using cyclic doubly linked lists
;;
;; This data structure is a bit overkill for a queue,
;; but it has many other uses
;; a doubly linked list cell look like (val . (prev-cell next-cell))
;;
;; a FIFO queue object looks like ('fifo . cyclic-doubly-linked-list)
;;
;; An empty FIFO queue would be: ('fifo . nil)
;;; Memoization benchmark -*- lexical-binding: t; -*-
;; Ref: https://github.com/skeeto/emacs-memoize
;; $ emacs -Q --batch -L path/to/memoize -f batch-byte-compile memoize-bench.el
;; $ emacs -Q --batch -L path/to/memoize -l memoize-bench.elc
;; Note: Benchmark requires at least 64-bit integers. Choose one of:
;; * Emacs >= 27
;; * Emacs <= 26 on 64-bit host
@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 / org-tree-view.el
Last active October 1, 2019 13:02
Show Org outline tree in a side buffer
;; NOTE: This has been superseded by `org-sidebar-tree': https://github.com/alphapapa/org-sidebar#org-sidebar-tree-command
(defun ap/open-tree-view ()
"Open a clone of the current buffer to the left, resize it to
30 columns, and bind <mouse-1> to jump to the same position in
the base buffer."
;; http://emacs.stackexchange.com/questions/9530/how-can-i-get-an-org-mode-outline-in-a-2nd-buffer-as-a-dynamic-table-of-contents
;; TODO: Make this use navi-mode, which handles most of this already
(interactive)
(let ((new-buffer-name (concat "<tree>" (buffer-name))))
@alphapapa
alphapapa / hide-show-layers.scm
Created October 8, 2019 20:30
GIMP: Hide/Show all layers in current image
;; When editing an image with many layers (e.g. an animated GIF with
;; hundreds of frames), it's impossibly tedious to click hundreds and
;; hundreds of times on small little boxes to hide or show all layers.
;; Since GIMP seems to lack a button to hide/show all of them, and it
;; doesn't allow selection of multiple layers, this script provides
;; menu items to hide/show all layers at once.
;; Who knows if later versions of GIMP than I have provide a way to do
;; this, but this works, and maybe it will be helpful to someone.
@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 / magit.sh
Last active April 5, 2020 10:18
Run a standalone Magit editor!
# Please see the script's new home: https://github.com/alphapapa/magit.sh