Skip to content

Instantly share code, notes, and snippets.

(require 'slime)
(require 'dash)
(require 'trident-mode)
(defvar trident-target-process nil
"The process that expansions will be sent to.")
(defun trident-list-process-buffers ()
"Return a list of all buffers with an associated process."
(-filter #'get-buffer-process (buffer-list)))
@johnmastro
johnmastro / List.vim
Last active August 29, 2015 14:17 — forked from romainl/list.md
" This is an updated, more powerful, version of the function discussed here:
" http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/
" that shows ]I, [I, ]D, [D, :ilist and :dlist results in the quickfix window, even spanning multiple files.
function! List(command, selection, start_at_cursor, ...)
" derive the commands used below from the first argument
let excmd = a:command . "list"
let normcmd = toupper(a:command)
if a:selection
@johnmastro
johnmastro / cycle-case.el
Created May 23, 2015 01:34
cycle-case.el
(require 'pcase)
;; Based on Xah Lee's: http://ergoemacs.org/emacs/modernization_upcase-word.html
(defun cycle-case (beg end)
"Cycle the word case of the active region or word at point."
(interactive
(pcase-let ((`(,beg . ,end) (if (use-region-p)
(cons (region-beginning) (region-end))
(bounds-of-thing-at-point 'word))))
@johnmastro
johnmastro / add-mc-cmds.el
Created May 23, 2015 01:54
add-mc-cmds.el
;; Just doodling on the topic of somewhat automatically initializing
;; `mc/cmds-to-run-for-all'.
;;
;; I always find the prompts a bit distracting when working on a new computer
;; but the file `multiple-cursors' maintains, .mc-lists.el, doesn't seem very
;; well-suited to version control.
(require 'pcase)
(defvar mc-paredit&sp-cmds-to-run-for-all-regexp
@johnmastro
johnmastro / projectile-tags-cygwin-kludge.el
Created August 12, 2015 01:59
Kludge for projectile-regenerate-tags on Windows+Cygwin
(defun maybe-cygwinize-drive-letter (file)
"Return FILE in a Cygwin-friendly format.
For example, given \"c:/foo/bar\" return \"/foo/bar\", or given
\"e:/foo/bar\" return \"/e/foo/bar\"."
(cond ((string-match "\\`[Cc]:/" file)
(replace-match "/" t t file))
((string-match "\\`\\([A-Za-z]\\):/" file)
(replace-match (concat "/" (match-string 1 file) "/")
t t file))
(t file)))
@johnmastro
johnmastro / ibuffer-magit-repo-dir.el
Last active September 12, 2015 23:04
Show Magit repo directory in ibuffer
;; Turns out it's not necessary to define a new ibuffer column type. Both
;; `list-buffers' and `ibuffer' respect `list-buffers-directory', so just do
;; something like this:
(add-hook 'magit-mode-hook
(lambda ()
(let ((dir (abbreviate-file-name default-directory)))
(setq list-buffers-directory dir))))
@johnmastro
johnmastro / octopress.el
Created February 16, 2013 20:11
Some code I've been playing around with to automate the process of of creating a new Octopress page or post, with appropriate metadata, from an Emacs buffer's content.
;; -*- lexical-binding: t -*-
;; Some code I've been playing around with to automate the process of of
;; creating a new Octopress page or post, with appropriate metadata, from a
;; buffer's content.
;; The `octopress-rake`, `octopress-extract-filename`, and `octopress-new`
;; functions are derived from the octopress-emacs code here:
;; github.com/gfreezy/octopress-emacs
;; This is just an example related to the discussion in this Emacs.SE question:
;; https://emacs.stackexchange.com/questions/20732/how-do-i-enable-indentation-in-an-inferior-scheme/
(defun newline-indent-comint-send-input ()
(interactive)
(newline-and-indent)
(comint-send-input))
(with-eval-after-load 'cmuscheme
(define-key inferior-scheme-mode-map (kbd "RET") #'newline-indent-comint-send-input))
@johnmastro
johnmastro / perl6-mode-imenu-chunk-bad.el
Created July 29, 2016 17:13
Example in a discussion on help-gnu-emacs
;;; perl6-imenu.el --- Imenu support Perl 6 -*- lexical-binding: t; -*-
;;; fragment
;; Imenu functions and variables are defined here.
;; a new definition of the Variables entry regex:
(defconst perl6-vars
(concat
"^\\s-*" ; leading ws allowed
"\\(?:my\\|our\\)\\s-+" ; scope of var, followed by mandatory ws
"\\(" ; start capture group 1 for the var name
@johnmastro
johnmastro / slime-ac-example.el
Created February 24, 2016 21:50
Example of setup with SLIME and auto-complete
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(defvar my-packages '(slime auto-complete ac-slime)
"List of packages to install automatically.")
(let ((need (delq nil (mapcar (lambda (pkg)