- ;; kudos to http://oremacs.com/2015/07/27/counsel-recoll/ author
- ;; I only change recoll command line
- (require 'counsel)
- (defun counsel-recoll-function (string &rest _unused)
- "Issue recallq for STRING."
- (if (< (length string) 3)
- (counsel-more-chars 3)
- (counsel--async-command
- (format "recoll -t -q '%s' | sed 's,\\[,,g;s,\\],,g' | awk '{ print $2 }' " string))
- nil))
- (defun counsel-recoll (&optional initial-input)
- "Search for a string in the recoll database.
- You'll be given a list of files that match.
- Selecting a file will launch `swiper' for that file.
- INITIAL-INPUT can be given as the initial minibuffer input."
- (interactive)
- (ivy-read "recoll: " 'counsel-recoll-function
- :initial-input initial-input
- :dynamic-collection t
- :history 'counsel-git-grep-history
- :action (lambda (x)
- (when (string-match "file://\\(.*\\)\\'" x)
- (let ((file-name (match-string 1 x)))
- (find-file file-name)
- (unless (string-match "pdf$" x)
- (swiper ivy-text)))))))
- (global-set-key (kbd "s-g") 'counsel-recoll)