Skip to content

Instantly share code, notes, and snippets.

@npcardoso
Created August 26, 2014 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npcardoso/58aa9206552c5a3baa43 to your computer and use it in GitHub Desktop.
Save npcardoso/58aa9206552c5a3baa43 to your computer and use it in GitHub Desktop.
discover.el + projectile integration
(defun projectile-get-binding (function)
(let (bindings)
(setq bindings (make-hash-table :test 'equal))
(puthash 'projectile-switch-to-buffer-other-window "4 b" bindings)
(puthash 'projectile-display-buffer "4 C-o" bindings)
(puthash 'projectile-find-dir-other-window "4 d" bindings)
(puthash 'projectile-find-file-other-window "4 f" bindings)
(puthash 'projectile-find-implementation-or-test-other-window "4 t" bindings)
(puthash 'projectile-run-shell-command-in-root "!" bindings)
(puthash 'projectile-run-async-shell-command-in-root "&" bindings)
(puthash 'projectile-switch-to-buffer "b" bindings)
(puthash 'projectile-compile-project "c" bindings)
(puthash 'projectile-find-dir "d" bindings)
(puthash 'projectile-dired "D" bindings)
(puthash 'projectile-recentf "e" bindings)
(puthash 'projectile-find-file "f" bindings)
(puthash 'projectile-find-file-in-known-projects "F" bindings)
(puthash 'projectile-invalidate-cache "i" bindings)
(puthash 'projectile-ibuffer "I" bindings)
(puthash 'projectile-find-tag "j" bindings)
(puthash 'projectile-kill-buffers "k" bindings)
(puthash 'projectile-find-file-in-directory "l" bindings)
(puthash 'projectile-commander "m" bindings)
(puthash 'projectile-multi-occur "o" bindings)
(puthash 'projectile-switch-project "p" bindings)
(puthash 'projectile-test-project "P" bindings)
(puthash 'projectile-replace "r" bindings)
(puthash 'projectile-regenerate-tags "R" bindings)
(puthash 'projectile-ack "s a" bindings)
(puthash 'projectile-grep "s g" bindings)
(puthash 'projectile-ag "s s" bindings)
(puthash 'projectile-save-project-buffers "S" bindings)
(puthash 'projectile-toggle-between-implementation-and-test "t" bindings)
(puthash 'projectile-find-test-file "T" bindings)
(puthash 'projectile-vc "v" bindings)
(puthash 'projectile-cache-current-file "z" bindings)
(puthash 'projectile-project-buffers-other-buffer "ESC" bindings)
(gethash function bindings)))
(defun projectile-context-menu-item (function desc)
(list (projectile-get-binding function) desc function))
(eval-after-load 'discover
'(discover-add-context-menu
:context-menu `(projectile
(description "Projectile")
,(list 'actions
(list "Project"
(projectile-context-menu-item 'projectile-switch-project "Project")
(projectile-context-menu-item 'projectile-vc "Version Control"))
(list "File"
(projectile-context-menu-item 'projectile-find-file "Find")
(projectile-context-menu-item 'projectile-find-dir-other-window "Find other window")
(projectile-context-menu-item 'projectile-find-file-in-directory "Find in directory")
(projectile-context-menu-item 'projectile-find-file-in-known-projects "Find in known projects")
(projectile-context-menu-item 'projectile-find-test-file "Test File")
(projectile-context-menu-item 'projectile-toggle-between-implementation-and-test "Implementation <-> Test")
(projectile-context-menu-item 'projectile-find-implementation-or-test-other-window "Implementation/Test other window")
(projectile-context-menu-item 'projectile-recentf "Recentf")
(projectile-context-menu-item 'projectile-find-dir "Directory"))
(list "Buffers"
(projectile-context-menu-item 'projectile-switch-to-buffer "Find")
(projectile-context-menu-item 'projectile-switch-to-buffer-other-window "Find other window")
(projectile-context-menu-item 'projectile-ibuffer "IBuffer")
(projectile-context-menu-item 'projectile-display-buffer "Display")
(projectile-context-menu-item 'projectile-kill-buffers "Kill all")
(projectile-context-menu-item 'projectile-save-project-buffers "Save all")
(projectile-context-menu-item 'projectile-project-buffers-other-buffer "Buffers other buffer"))
(list "Search/Replace"
(projectile-context-menu-item 'projectile-replace "Replace")
(projectile-context-menu-item 'projectile-multi-occur "Multi-occur")
(projectile-context-menu-item 'projectile-ack "Acks")
(projectile-context-menu-item 'projectile-grep "Grep")
(projectile-context-menu-item 'projectile-ag "Ag"))
(list "Shell"
(projectile-context-menu-item 'projectile-run-shell-command-in-root "Run shell command in root")
(projectile-context-menu-item 'projectile-run-async-shell-command-in-root "Run async shell command in root")
(projectile-context-menu-item 'projectile-commander "Commander")
(projectile-context-menu-item 'projectile-dired "Dired"))
(list "Compiling/Testing"
(projectile-context-menu-item 'projectile-compile-project "Compile")
(projectile-context-menu-item 'projectile-test-project "Test"))
(list "Tags"
(projectile-context-menu-item 'projectile-find-tag "Tag")
(projectile-context-menu-item 'projectile-regenerate-tags "Regenerate"))
(list "Cache"
(projectile-context-menu-item 'projectile-invalidate-cache "Invalidate")
(projectile-context-menu-item 'projectile-cache-current-file "Cache current file"))
))
:mode nil
:mode-hook nil
:bind "C-c C-p")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment