From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Angel de Vicente Newsgroups: gmane.emacs.help Subject: Re: Emacs interface to Recoll other than Helm? Date: Wed, 08 Nov 2017 12:40:37 +0000 Message-ID: <87d14tx7sq.fsf@iac.es> References: <87375qf6my.fsf@iac.es> <87po8uyr8f.fsf@iac.es> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1510144901 8222 195.159.176.226 (8 Nov 2017 12:41:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 8 Nov 2017 12:41:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 08 13:41:37 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCPfk-0001rE-Np for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 13:41:36 +0100 Original-Received: from localhost ([::1]:59255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCPfq-0005lw-Ee for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 07:41:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCPfM-0005ln-FN for help-gnu-emacs@gnu.org; Wed, 08 Nov 2017 07:41:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCPfG-0005Mb-Kh for help-gnu-emacs@gnu.org; Wed, 08 Nov 2017 07:41:12 -0500 Original-Received: from [195.159.176.226] (port=46518 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCPfG-0005Lu-Dt for help-gnu-emacs@gnu.org; Wed, 08 Nov 2017 07:41:06 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eCPf3-0000K1-0r for help-gnu-emacs@gnu.org; Wed, 08 Nov 2017 13:40:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Q0wmlhrHTvy5uJtNAUho2mhpwBg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114809 Archived-At: Hi, Angel de Vicente 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/