Adjusting helm-do-grep for org mode browsing

63 views
Skip to first unread message

Samuel Schaumburg

unread,
Feb 9, 2014, 9:21:52 AM2/9/14
to emacs...@googlegroups.com
Hello

I would like to adjust helm grep to work as a note browsing tool for
org mode notes. Unfortunately my lisp is just to poor to do this on my
own, so maybe someone can provide help here

Here are my thoughts on how it should work:

Calling helm-do-grep recursively does all I need for browsing and
searching functionality. It does however prompt the user, to enter all
the information for doing a grep-session which is unnecessary in this
case, as I would like to set a fixed directory and search pattern.


The function I have in mind would look like this roughly:

(setq path_to_org_dir "~/org")
(setq patter "*.org")
(defun my-helm-do-grep-recursive (path_to_org_dir pattern)



All that is now left to enter interactively, is the search string I
actually want to look up in all my notes.

I already managed to write the following wrapper function to call grep
recursively right away so there is no more need for the prefix arg
when calling helm-do-grep

(defun my-helm-do-grep-recursive (path_to_org_dir pattern)
  (interactive)
  (let ((current-prefix-arg t))
  (helm-do-grep))
  )

So far so good.

But as the current implementation of helm-do-grep does not take any
arguments I do not know how to go on from here. I want to provide the
two variables I have set but I do not see a way to do so, without
rewriting the entire helm-do-grep function.

Probably I would have to identify the parts that ask for user input of
the directory and the file type and just replace these parts with the
two arguments I want to provide while leaving everything else as it
is.

But as I said my lisp is not yet good enough to mess around with the code like that.

I would guess this is easy for someone who knows what hes doing, but
of course I might be mistaken here.

So if you have time and this is not to difficult I would be happy, if
you could help me out her.

Thx in advance
Samuel

Thierry Volpiatto

unread,
Feb 9, 2014, 12:21:48 PM2/9/14
to Samuel Schaumburg, emacs...@googlegroups.com
Samuel Schaumburg <schaum...@gmail.com> writes:

> So if you have time and this is not to difficult I would be happy, if
> you could help me out her.

(let ((files (helm-walk-directory "~/org"
:path 'full
:directories nil
:match ".*\\.org$"
:skip-subdirs t)))
(helm-do-grep-1 files))


or (probably faster if your org directory have a huge number of files)


(let ((default-directory "/home/thierry/org/"))
;; I you use ack-grep, this will not work and you will
;; be prompted for "types".
;; So if interactively you are using ack-grep
;; just let-bound helm-grep-default-recurse-command here
(helm-do-grep-1 (list default-directory) t nil '("*.org")))


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

Samuel Schaumburg

unread,
Feb 9, 2014, 1:16:15 PM2/9/14
to emacs...@googlegroups.com, Samuel Schaumburg
Thanks a lot. This is perfect. One day I will understand what these colons do.

Right now I can finally get rid of the stupid deft-extension and do this with helm. 

Cheers 
Samuel
Reply all
Reply to author
Forward
0 new messages