I recently found ghq which can search specific repositories in terminal
and it was very convenience program for me, so I combined the ghq and
helm-for-files function to access any by one command in Emacs. Take a
look if you are interested!
what is ghq?
The ghq is a package that manage many repositories and treat them as
same list and it also manage repositories that specified in
.gitconfig. For example you can specify like this in .gitconfig:
[ghq]
root = ~/.ghq
root = ~/.gvm/pkgsets/go1.3rc1/global/src/
root = ~/work/
In this configuration, you can show directory from above set
repositories by ghq list command:
ghq list --full-path
Moreover, ghq is made of golang which has cross compile environment,
so if you build this program for Windows. You can use this on Windows
too.
If you wasn't emacs user, don't worry I know another usage of ghq.
See following link: https://github.com/peco/peco/wiki/Sample-Usage
You can search repositories in terminal by using peco.(I'm using this
way too)
what is helm(-for-files)?
It's known for convenient program in Emacs world to find out files
and There are many helm extensions too.
The helm-for-files function is it find out files from current
directory, recentf, current buffers and file cache and it can use many
candidates to search file and this function also add another source by
implementing it.(like I did)
Prerequisite
You need ghq, helm.el and helm-ghq.el.
To install ghq, type below command:
go get github.com/motemen/ghq
To install helm.el and helm-ghq, type M-x package-list-packages
command and then select those packages by i and x key.
I used helm-ghq package to get ghq's helm candidates and you can only
use helm with ghq candidates by this package.
If you can't install from melpa, try below code. It adds melpa
repository to search path.
(add-to-list 'package-archives '("melpa" .
"http://melpa.milkbox.net/packages/"))
Configuration
Put below codes to your .emacs or emacs's configuration file like
init.el after you installed ghq, helm.el and helm-ghq.
(require 'helm-files)
;; This is an optional advice, but if you feel helm-for-files is slow,
;; do this configuration.
(defadvice helm-for-files
(around helm-for-files-no-highlight activate)
"No highlight when using helm-for-files."
(let ((helm-mp-highlight-delay nil))
ad-do-it))
(defvar helm-source-my-ghq
`((name . "GHQ")
(init . (lambda () (require 'helm-ghq)))
(candidates . helm-ghq--list-candidates)
(match . helm-files-match-only-basename)
(filtered-candidate-transformer
. (lambda (candidates _source)
(cl-loop for i in candidates
if helm-ff-transformer-show-only-basename
collect (cons (helm-basename i) i)
else collect i)))
(keymap . ,helm-generic-files-map)
(help-message . helm-generic-file-help-message)
(mode-line . helm-generic-file-mode-line-string)
(action . ,(cdr (helm-get-actions-from-type
helm-source-locate))))
"Source for ghq.")
(defconst helm-for-files-preferred-list
'(helm-source-my-ghq
helm-source-buffers-list
helm-source-recentf
helm-source-file-cache
helm-source-files-in-current-dir
;; Comment out below sources which I don't use normally
;; helm-source-bookmarks
;; helm-source-locate
))
execute command
You can execute new helm-for-files command after load above
configuration.
You can call by M-x helm-for-files or keybind directly.
No comments:
Post a Comment