Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence byte-compiler warnings #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions pdfgrep.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ Not including `pdfgrep-ignore-case'."
(cons (concat cmd " 2>/dev/null") (1+ (length cmd)))
cmd)))

(defun pdfgrep (command-args)
"Run pdfgrep with user-specified COMMAND-ARGS, collect output in a buffer.
You can use \\[next-error], or RET in the `pdfgrep-buffer-name'
buffer, to go to the lines where PDFGrep found matches. To kill
the PDFGrep job before it finishes, type \\[kill-compilation]."
(interactive (list (read-shell-command "Run pdfgrep (like this): "
(pdfgrep-default-command)
'pdfgrep-history)))
(unless pdfgrep-mode
(error "PDFGrep is not enabled, run `pdfgrep-mode' first."))
(unless (executable-find "pdfgrep")
(error "The 'pdfgrep' command not available on your system."))
(compilation-start command-args 'grep-mode
(lambda (_x) pdfgrep-buffer-name)))

(defun pdfgrep-current-page-and-match ()
"Return the current match page number and match string."
(with-current-buffer pdfgrep-buffer-name
Expand All @@ -93,6 +78,13 @@ the PDFGrep job before it finishes, type \\[kill-compilation]."
'match cur)))
(substring cur start (next-property-change start cur))))))

(defvar doc-view-doc-type)
(declare-function doc-view-goto-page "doc-view")

(declare-function pdf-view-goto-page "ext:pdf-view")
(declare-function pdf-isearch-hl-matches "ext:pdf-isearch")
(declare-function pdf-isearch-search-page "ext:pdf-isearch")

(defun pdfgrep-goto-locus (_msg _mk _end-mk)
"Jump to a match corresponding.
_MSG, _MK and _END-MK parameters are ignored. This function is
Expand All @@ -106,6 +98,7 @@ used to advice `compilation-goto-locus'."
(when (cdr meta)
(pdf-isearch-hl-matches nil (pdf-isearch-search-page (cdr meta)) t)))))

;;;###autoload
(define-minor-mode pdfgrep-mode
"Toggle PDFGrep mode.

Expand All @@ -117,6 +110,21 @@ the mode if ARG is omitted or nil."
(advice-add 'compilation-goto-locus :after #'pdfgrep-goto-locus)
(advice-remove 'compilation-goto-locus #'pdfgrep-goto-locus)))

(defun pdfgrep (command-args)
"Run pdfgrep with user-specified COMMAND-ARGS, collect output in a buffer.
You can use \\[next-error], or RET in the `pdfgrep-buffer-name'
buffer, to go to the lines where PDFGrep found matches. To kill
the PDFGrep job before it finishes, type \\[kill-compilation]."
(interactive (list (read-shell-command "Run pdfgrep (like this): "
(pdfgrep-default-command)
'pdfgrep-history)))
(unless pdfgrep-mode
(error "PDFGrep is not enabled, run `pdfgrep-mode' first."))
(unless (executable-find "pdfgrep")
(error "The 'pdfgrep' command not available on your system."))
(compilation-start command-args 'grep-mode
(lambda (_x) pdfgrep-buffer-name)))

(provide 'pdfgrep)

;;; pdfgrep.el ends here