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-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))
@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-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 / ap-comment-dwiw.el
Last active April 2, 2016 22:05
Yet another comment-do-what-I-want function
(defun ap/comment-dwiw (prefix)
"Add/remove comments from code.
With prefix, uncomment region or remove commented lines.
More specifically:
With active region:
* With prefix: Uncomment region.
* Without prefix: Comment/uncomment region.
@alphapapa
alphapapa / diskchecker.pl
Created April 18, 2016 04:11 — forked from bradfitz/diskchecker.pl
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
@alphapapa
alphapapa / filter-buffer.el
Created April 22, 2016 09:44 — forked from wasamasa/filter-buffer.el
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 / .gitignore
Created September 11, 2016 07:52 — forked from wzhd/.gitignore
Parsing Evernote export file (.enex) using Python
*.enex
@alphapapa
alphapapa / init.el
Created September 21, 2016 22:18
Fira code symbols in emacs. You need to grab the Fira Code Symbol font for this to work. https://github.com/tonsky/FiraCode/files/412440/FiraCode-Regular-Symbol.zip
;;; Fira code
;; This works when using emacs --daemon + emacsclient
(add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")))
;; This works when using emacs without server/client
(set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")
;; I haven't found one statement that makes both of the above situations work, so I use both for now
(defconst fira-code-font-lock-keywords-alist
(mapcar (lambda (regex-char-pair)
@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 / 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 -