helm remap ACTION and set the base for helm-locate

2,557 views
Skip to first unread message

Sam Halliday

unread,
Apr 25, 2014, 6:24:22 AM4/25/14
to emacs...@googlegroups.com
Hi all,

I've just discovered helm and I'm very impressed.

There are a few tweaks I'd like to make, to accommodate my typical use cases, and I was hoping you could help.

My primary requirement is to be able to search for filenames (and within files), preferably limited to the folder containing the project that I'm currently working on.

However, I'm getting a lot of noise from binary files and other projects.

1. can helm-locate be set up to respect .gitignore files? If not, how can I tell helm-locate how to ignore files and directories matching a pattern?
2. can I temporarily set the base directory for helm-locate? When I'm working on a project, I only want to search that project. If I could pass a base directory to helm-locate, I could perhaps write a wrapper that adds this functionality (e.g. ask on first use, pass through, and a function allowing it to be updated)
3. is there a M-x command to do an rgrep? The documentation makes me go in through helm-find-file and then use the ACTION to select Grep with Prefix. I'd like a single command (again with a base directory that I can set) that I can invoke to start search inside files. Again, respecting .gitignore would be great.
4. I would like to rebind a different key to ACTION and get completion with TAB (e.g. same thing as what currently happens when I press the right arrow key). How can I do this?

Best regards,
Sam 

Le Wang

unread,
Apr 25, 2014, 6:46:40 AM4/25/14
to emacs...@googlegroups.com

1,2,3 helm-cmd-t and helm-ls-git both will work.  I maintain the former.

4 can be done although I don't know if it's recommended.

--
You received this message because you are subscribed to the Google Groups "emacs-helm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emacs-helm+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Halliday

unread,
Apr 25, 2014, 9:21:02 AM4/25/14
to emacs...@googlegroups.com
Le Wang, that's really great! helm-ls-git does exactly what I need for points 1 and 2 :-)

However I don't see how to use it in rgrep mode... am I missing something?

Le Wang

unread,
Apr 25, 2014, 9:31:00 AM4/25/14
to emacs...@googlegroups.com
`helm-ls-git` interfaces directly with `git grep`, so there is no need
to use for rgrep. It's one of the available actions on git controlled
files.
--
Le

Sam Halliday

unread,
Apr 25, 2014, 10:03:27 AM4/25/14
to emacs...@googlegroups.com

Ok that's good news. Which command is that?

You received this message because you are subscribed to a topic in the Google Groups "emacs-helm" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emacs-helm/zaBbg2tFAuM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emacs-helm+...@googlegroups.com.

Le Wang

unread,
Apr 25, 2014, 10:22:51 AM4/25/14
to emacs...@googlegroups.com
I'm not very familiar with helm-ls-git, but it's not a separate
command, but an action available through `helm-ls-git-ls` -- press
<tab> to select it.

Le Wang

unread,
Apr 25, 2014, 10:28:54 AM4/25/14
to emacs...@googlegroups.com
Okay, I just loaded it up and have more details:

1. helm-ls-git-ls
2. navigate to git controlled file
3. <tab>
4. "git grep"
5. <C-u> <C-u> enter

That's the gist to grep through the whole repository. There are
various things you can do to narrow down to a subset though.
--
Le

Thierry Volpiatto

unread,
Apr 25, 2014, 11:30:14 AM4/25/14
to emacs...@googlegroups.com

Sam Halliday <sam.ha...@gmail.com> writes:

> 1. can helm-locate be set up to respect .gitignore files? If not, how
> can I tell helm-locate how to ignore files and directories matching a
> pattern?

Customize `helm-boring-file-regexp-list'.

> 2. can I temporarily set the base directory for helm-locate?

Yes, from helm-find-files, use `C-u C-x C-f'.
See `C-c ?'.

> 3. is there a M-x command to do an rgrep? The documentation makes me
> go in through helm-find-file and then use the ACTION to select Grep
> with Prefix. I'd like a single command (again with a base directory
> that I can set) that I can invoke to start search inside files. Again,
> respecting .gitignore would be great.

Your friend is `C-c ?' which is the embeded help of most helm commands
(some that have not a specific help are actually using `C-h m', see
mode-line).

To answer you question, yes, from helm-find-files, use `C-s' on a file,
a set of file or a wildcard (e.g "*.el"), use `C-u C-s' for recursive
grep.

You can resume any helm grep session like any other helm session, see
`helm-resume', and you can also save your helm grep sessions with C-x
C-s.

You can use ack-grep as backend, see the documentation of relevant vars.

etc... etc...

> 4. I would like to rebind a different key to ACTION and get completion
> with TAB (e.g. same thing as what currently happens when I press the
> right arrow key). How can I do this?

Most sources in helm (at least the more important ones) have a keymap,
you can bind keys to these keymaps like you usually do in emacs.

Note that you have no TAB completion in helm ;-)

My configuration file for helm is here if that helps:

https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/init-helm-thierry.el

--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

Sam Halliday

unread,
Apr 25, 2014, 12:37:00 PM4/25/14
to emacs...@googlegroups.com

Thanks again... But doesn't this only work for one file? I want to do a git on the whole project, while respecting .gitignore

Le Wang

unread,
Apr 25, 2014, 2:27:16 PM4/25/14
to emacs...@googlegroups.com
C-u C-u prefix changes the behaviour to grep entire repository.

Try helm-cmd-t. That workflow might be more to your liking.

Sam Halliday

unread,
Apr 26, 2014, 9:53:13 AM4/26/14
to emacs...@googlegroups.com
Thanks all!

I found that 'magit-find-file-completing-read and 'git-grep combined
with the helm live search works exceptionally well!

I'd still like to be able to use TAB to have the same effect as the
right arrow, and have some other key combination to bring up the
action list.

I am trained to use TAB for completion in this fashion and it is a
strain to think otherwise. Say I'd looking to edit a file under my
.emacs.d folder, I would like to type ".emTAB.d/hTAB" which TAB
expands the buffer contents out to the minimally redundant value.

Thierry Volpiatto

unread,
Apr 27, 2014, 2:22:44 AM4/27/14
to emacs...@googlegroups.com

Sam Halliday <sam.ha...@gmail.com> writes:

> I am trained to use TAB for completion in this fashion and it is a
> strain to think otherwise. Say I'd looking to edit a file under my
> .emacs.d folder, I would like to type ".emTAB.d/hTAB" which TAB
> expands the buffer contents out to the minimally redundant value.

TAB completion is unuseful in helm.

Samuel Halliday

unread,
Apr 27, 2014, 5:02:12 AM4/27/14
to emacs...@googlegroups.com
Well from what I can see, there is no TAB completion, just arrow completion. I would rather use the TAB key instead of the right arrow key.
Reply all
Reply to author
Forward
0 new messages