This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; In an effort to fix the poor new template system, introducing my own fix: | |
(defun jsm/org-src-block () | |
"Better src block completion experience" | |
(interactive) | |
(org-insert-structure-template | |
(concat "src " (completing-read "Source type: " org-src-lang-modes)))) | |
(define-key org-mode-map (kbd "C-c s") 'jsm/org-src-block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jsm/projectile-counsel-ag () | |
"Run counsel-ag within projectile root while ignoring git submodule paths." | |
(interactive) | |
(let ((default-directory (projectile-project-root)) | |
(agignore-cmd "git config --file .gitmodules --get-regexp path | awk '{ print $2 }' > .agignore")) | |
(shell-command agignore-cmd nil nil) | |
(counsel-ag (thing-at-point 'symbol) (projectile-project-root)))) | |
(define-key projectile-command-map (kbd "s s") 'jsm/projectile-counsel-ag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
@contextmanager | |
def stderr_off(): | |
import sys | |
stderr_orig = sys.stderr | |
sys.stderr = open('/dev/null', 'w') | |
yield | |
sys.stderr = stderr_orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'use-package) | |
(defun use-package-normalize/:el-get (name-symbol keyword args) | |
(if (null args) | |
t | |
(use-package-only-one (symbol-name keyword) args | |
(lambda (label arg) | |
(if (symbolp arg) | |
arg | |
(use-package-error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Quickly split window and get to my projects File | |
(require 'key-chord) | |
(defvar my-projects-file "~/org/projects.org" | |
"My favorite projects file") | |
(defun switch-to-projects-other-window () | |
"Quickly open my favorite projects buffer in other window" | |
(interactive) | |
(let* ((project-filename (expand-file-name my-projects-file)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Make files that should be executable, executable | |
(defun jsm:make-buffer-file-executable-if-script-p () | |
"Limit the situations that I want scripts to be made executable" | |
(interactive) | |
(let ((parent-dir (file-name-base | |
(directory-file-name | |
(file-name-directory buffer-file-name))))) | |
(if (cond ((eq major-mode 'sh-mode) t) | |
((and (eq major-mode 'python-mode) | |
(string= parent-dir "scripts")) t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; README preview helper thanks to pandoc | |
;; ------------------------------ | |
(defun readme-preview () | |
"Preview the README rendered to html in a browser tab via pandoc" | |
(interactive) | |
(let* ((html-filename (format "%s.html" (file-name-base buffer-file-name))) | |
(input-format (cond | |
((derived-mode-p 'rst-mode) "rst") | |
((derived-mode-p 'markdown-mode) "markdown_github"))) | |
(cmd (format "pandoc -f %s -t html -o %s %s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import stat | |
import shutil | |
import tempfile | |
import logging as log | |
class UpdateFile(object): | |
"""Update a file atomically |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Allow isearch functionality with multiple-cursors | |
(require 'phi-search) | |
(setq phi-search-limit 10000) | |
(add-hook 'multiple-cursors-mode-enabled-hook | |
(lambda () | |
(interactive) | |
(global-set-key (kbd "C-s") 'phi-search) | |
(global-set-key (kbd "C-r") 'phi-search-backward))) | |
(add-hook 'multiple-cursors-mode-disabled-hook | |
(lambda () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Simulate GNU Screen within Emacs using ansi-term | |
;; ------------------------------ | |
(defun term-next () | |
"Go to the next terminal based on the buffer name. Will extract the | |
number from the buffer-name, add 1 and go to a buffer of that name if it | |
exists." | |
(interactive) | |
(let ((cur-buffer (buffer-name))) | |
(if (string-match "\\([0-9]+\\)" cur-buffer) | |
(let* ((n (match-string-no-properties 0 cur-buffer)) |
NewerOlder