From: Angel de Vicente <angelv@iac.es>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs interface to Recoll other than Helm?
Date: Wed, 08 Nov 2017 12:40:37 +0000 [thread overview]
Message-ID: <87d14tx7sq.fsf@iac.es> (raw)
In-Reply-To: 87po8uyr8f.fsf@iac.es
Hi,
Angel de Vicente <angelv@iac.es> writes:
> What I would like is something more like what you get in the Recoll GUI
> (or, for example, when you do a multi-occur search), where you get a
> buffer with the files matching, together with some context and an easy
> way to open a particular file at the point where the match was
> found. Something like:
> http://picpaste.com/counsel-recoll-mo-uQUXHGey.png
OK, so I rolled up my sleeves and made a hack that works just fine
(though for the moment it is very crude and most options are
hard-coded).
In case somebody else wants to try, I just defined the following
function in my .emacs (I have ivy/swiper/counsel, ag and recoll
installed):
,----
| (defun ag-recoll (string directory)
| "Search using ag based on the findings of recoll. Search will be done in a given DIRECTORY,
| and the STRING will be interpreted as concatenated by ANDs for recoll and with ORs for ag.
|
| The idea is that when I search, for example, for 'openacc mpi', recoll will give me all the
| files that have those two words somewhere in the file, and ag will find lines that match
| any of the terms.
|
| For the moment this is very crude, and most options to recoll and ag are hard-coded in the
| ag-recoll.sh script, most notably that ag will look for a maximum of 10 matches in each file
| to avoid huge lists with common searches."
|
| (interactive (list (ag/read-from-minibuffer "Search string")
| (read-directory-name "Directory: ")))
| (setq command-string (format "%s %s %s" "/home/angelv/localhacks/ag-recoll.sh" directory string))
| (setq regexp nil)
| (compilation-start
| command-string
| #'ag-mode
| `(lambda (mode-name) ,(ag/buffer-name string directory regexp))))
`----
which uses the ag-recoll.sh script:
,----
| #!/bin/bash
| dir=$1; shift
| ors=$(printf '%s|' ${@})
| recoll -t -b $@ dir:$dir | sed -e "s/file:\/\///" | xargs -d '\n' ag --max-count 10 --group --line-number --column --color --color-match 30\;43 --color-path 1\;32 --smart-case ${ors%|}
`----
So, as an example, when I call ag-recoll with STRING 'openacc pgi' and
DIRECTORY /home/angelv/Learning, the result is like this:
http://picpaste.com/pics/ag-recoll-CdCrnsru.1510144253.png
where each line is a hyperlink to the corresponding match in the file,
you can use the common grep-mode commands to open a file, go to the next
match C-x `, etc.
I will be using this from now on, and if I find it useful I will try to
make it more flexible (being able to pass arguments to recoll and ag,
etc. [I'm a total noob with Emacs Lisp, so any suggestions on how to
improve the code are very welcome].
Cheers,
--
Ángel de Vicente
http://angel-de-vicente.blogspot.com/
next prev parent reply other threads:[~2017-11-08 12:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 15:30 Emacs interface to Recoll other than Helm? Angel de Vicente
2017-11-07 15:37 ` Kaushal Modi
2017-11-07 16:17 ` Angel de Vicente
2017-11-07 17:09 ` Angel de Vicente
2017-11-07 20:19 ` Bob Proulx
2017-11-07 21:17 ` Angel de Vicente
2017-11-07 16:43 ` Angel de Vicente
2017-11-08 12:40 ` Angel de Vicente [this message]
2017-11-07 15:51 ` Joost Kremers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d14tx7sq.fsf@iac.es \
--to=angelv@iac.es \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).