The pdfgrep
function that you call from lisp is not the pdfgrep
program that you invoke from the command line, so you have to format the arguments as the function expects. Try:
(defun myPdfSearch (s)
(interactive "sSearch string: ")
(pdfgrep (format "pdfgrep -H -n -i -r -e \"%s\" /home/pdf/*.pdf" s)))
)
This is the equivalent of the command line invocation
pdfgrep -H -n -i -r -e "<string>" /home/pdf/*.pdf
It's a good idea to use -e
to signal that the next argument is the expression to search for and to quote that expression to protect spaces and metacharacters from tripping up the shell invocation.
AFAICT, pdfgrep
requires files as arguments, not directories, so you have to use the glob pattern to pick up all the PDF files in the specified directory.
I also had to load the pdfgrep
library and evaluate (pdfgrep-mode)
before I could use the above.