Skip to content

Instantly share code, notes, and snippets.

@herbertjones
herbertjones / gist:c4fca060e531fdfd5828
Last active August 29, 2015 14:15
Playing with a spacemacs-like scrolling micro state
;; Old syntax
(evil-leader/set-key
"," 'hfj/scroll-page-down
"." 'hfj/scroll-page-up
)
(defun hfj/scroll-page-overlay-map ()
"Set a temporary overlay map to easily scroll through a file."
(set-temporary-overlay-map
@herbertjones
herbertjones / gist:2cfb738e81a6f15c6983
Created February 21, 2015 20:30
Playing with a spacemacs-like scrolling micro state and new syntax
;; New syntax
(spacemacs|define-micro-state scroll
:doc "[,] page down [.] page up "
:bindings
("," evil-scroll-page-down)
("." evil-scroll-page-up))
(evil-leader/set-key
"," '(lambda (x)
@herbertjones
herbertjones / gist:378d3c7bc258d7f5bf1e
Created February 21, 2015 20:31
Playing with a spacemacs-like scrolling micro state and new syntax
(spacemacs|define-micro-state scroll
:doc "[,] page down [.] page up "
:bindings
("," evil-scroll-page-down)
("." evil-scroll-page-up))
(evil-leader/set-key
"," '(lambda (x)
(interactive "p")
(evil-scroll-page-down x)
@herbertjones
herbertjones / gist:4ceaac254bd620c28e51
Created February 21, 2015 22:07
Git timemachine micro state
(evil-leader/set-key
"gt" nil
"gt" 'spacemacs/time-machine-micro-state)
(spacemacs|define-micro-state time-machine
:doc "[q] quit [p] previous [n] next [c] current"
:on-enter (git-timemachine)
:on-exit (git-timemachine-quit)
:persistent t
:bindings
@herbertjones
herbertjones / gist:94e3e1dd271831d5ea61
Created February 24, 2015 12:44
Navagation mode idea
(evil-leader/set-key
"jn" 'spacemacs/navagation-micro-state)
(defun spacemacs//navagation-mode-ms-full-doc ()
"Full documentation for helm navigation micro-state."
"
[?] display this help
[)] [0] forwards sentence
[)] [9] backwards sentence
[}] [{] forwards/backwards paragraph
@herbertjones
herbertjones / gist:6fb319c8a257658f93cb
Created February 27, 2015 16:30
open file at cursor
;; Stolen from http://xahlee.blogspot.com/2013/05/emacs-open-file-path-under-cursor-fast.html
(defun hfj/open-file-at-cursor ()
"Open the file path under cursor.
If there is text selection, uses the text selection for path.
If the path is starts with “http://”, open the URL in browser.
Input path can be {relative, full path, URL}.
This command is similar to `find-file-at-point' but without prompting for confirmation.
"
(interactive)
(let ( (path (thing-at-point 'filename)))
@herbertjones
herbertjones / config.el
Created February 27, 2015 16:36
Instructions for a personal snippets layer
;; Place this in layer directory and create a "snippets" directory
;; in the same layer directory as this file to have a personal
;; layer snippets repository
;; My snippets directory
(setq hfj-snippets/snippet-dir
(concat (file-name-directory load-file-name) "snippets"))
(setq yas-snippet-dirs
(list hfj-snippets/snippet-dir))
Loading /home/herbert/.emacs.d/contrib/git/config.el (source)...done
Loading /home/herbert/.emacs.d/spacemacs/packages.el (source)...done
Loading /home/herbert/spacemacs/my-layers/hfj-c++/packages.el (source)...done
Loading /home/herbert/spacemacs/my-layers/hfj-pastebins/packages.el (source)...done
Loading /home/herbert/.emacs.d/contrib/ace-window/packages.el (source)...done
Loading /home/herbert/.emacs.d/contrib/git/packages.el (source)...done
Loading /home/herbert/.emacs.d/contrib/perspectives/packages.el (source)...done
Loading /home/herbert/.emacs.d/spacemacs/extensions.el (source)...done
Loading /home/herbert/spacemacs/my-layers/hfj-c++/extensions.el (source)...done
Loading /home/herbert/spacemacs/my-layers/hfj-pastebins/extensions.el (source)...done
@herbertjones
herbertjones / .spacemacs
Created March 2, 2015 05:49
.spacemacs
;; -*- mode: dotspacemacs -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '("/home/herbert/spacemacs/my-layers/")
@herbertjones
herbertjones / toggle-touchpad.sh
Created August 26, 2017 15:19
Toggle touchpad on laptop
#!/bin/bash
stderr() { cat <<< "$@" 1>&2; }
toggle_xinput_device()
{
declare -r -a device_filters=("$@")
if [[ ${#device_filters[*]} -eq 0 ]]; then
stderr "No filters provided."