;;; helm-dev.el --- dev cd - projectile/helm interface. -*- lexical-binding: t -*- | |
;; Version: 1.0.0 | |
;; Package-Requires: ((helm "1.5") (cl-lib "0.5") (emacs "24.1")) | |
;;; Code: | |
(require 'cl-lib) | |
(require 'helm) | |
(require 'helm-utils) | |
(require 'helm-adaptive) | |
(defgroup helm-dev nil | |
"dev related Applications and libraries for Helm." | |
:group 'helm) | |
(defcustom helm-dev-actions (helm-make-actions | |
"dev cd" | |
(lambda (candidate) | |
(helm-dev-cd candidate))) | |
"Actions for helm-dev." | |
:group 'helm-dev | |
:type '(alist :key-type string :value-type function)) | |
(defun helm-dev-build-project-list () | |
(split-string (shell-command-to-string "/opt/dev/bin/dev cd --list"))) | |
(defun helm-dev-string-chomp (string) | |
(let ((len (length string))) | |
(cond | |
((and (> len 0) (eql (aref string (- len 1)) ?\n)) | |
(substring string 0 (- len 1))) | |
(t string)))) | |
(defun helm-dev-activate-project (spec) | |
(let ((path (helm-dev-string-chomp (shell-command-to-string (concat "/opt/dev/bin/dev project-path " spec))))) | |
(message "activating dev project %s" path) | |
(projectile-add-known-project path) | |
(dired path))) | |
;;;###autoload | |
(defun helm-dev-cd () | |
"Preconfigured `helm' for dev cd." | |
(interactive) | |
(let ((candidates (helm-dev-build-project-list))) | |
(helm :sources (helm-build-sync-source "devcd" | |
:candidates candidates | |
:action (lambda (candidate) (helm-dev-activate-project candidate))) | |
:buffer "*helm-devcd*"))) | |
(provide 'helm-dev) | |
;; Local Variables: | |
;; byte-compile-warnings: (not cl-functions obsolete) | |
;; coding: utf-8 | |
;; indent-tabs-mode: nil | |
;; End: | |
;;; helm-dev.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment