Skip to content

Instantly share code, notes, and snippets.

@grimradical
Created July 1, 2013 19:10
Show Gist options
  • Select an option

  • Save grimradical/5903644 to your computer and use it in GitHub Desktop.

Select an option

Save grimradical/5903644 to your computer and use it in GitHub Desktop.
;; Quicksilver for emacs...sort of
(ido-mode t)
(require 'helm-git)
(if (eq system-type 'darwin)
;; Set the helm "locate" command to use spotlight, which is so much better
(setq helm-c-locate-command "mdfind -name %s"))
;; Monkey-patched version of helm-c-source-git-files. The stock one doesn't
;; have good enough error handling (it'll fail when invoked on a directory
;; that isn't a git repo). Basically, I just wrap a few calls with
;; ignore-errors
(setq helm-c-source-git-files
`((name . "Git files list")
(init . (lambda ()
(helm-init-candidates-in-buffer
"*helm git*" (ignore-errors (helm-c-git-files)))))
(candidates-in-buffer)
(keymap . ,helm-generic-files-map)
(help-message . helm-generic-file-help-message)
(mode-line . helm-generic-file-mode-line-string)
(match helm-c-match-on-basename)
(type . file)
(action . (lambda (candidate)
(ignore-errors
(helm-git-find-file candidate))))))
;; Custom buffer switching display.
;;
;; * first list the set of available buffers
;; * next, any files in the current git repo
;; * next, any files in the current directory
;; * next, any recent files
;;
;; This allows me to hit C-x b, then start typing in letters to filter the
;; resulting list. I rarely need to manually locate a file now.
(defun helm-my-buffers ()
(interactive)
(helm-other-buffer '(helm-c-source-buffers-list
helm-c-source-git-files
helm-c-source-files-in-current-dir
helm-c-source-recentf)
"*helm-my-buffers*"))
;; Bind the above to the standard buffer-switch keystroke
(global-set-key (kbd "C-x b") 'helm-my-buffers)
;; Shortcut for directly looking for files that are part of the current git
;; repo
(global-set-key (kbd "C-x C-g") 'helm-git-find-files)
;; Shortcut for directly looking for files via Spotlight/locate
(global-set-key (kbd "C-x C-l") 'helm-locate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment