Skip to content

Commit 6eb4db2

Browse files
committed
Insert buffer-file-name as PATTERN if pdf-view-mode is active
- checks if pdf-view-mode is active - if it's active it inserts the file name of the currently loaded pdf as PATTERN
1 parent a4ca0a1 commit 6eb4db2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pdfgrep.el

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ Not including `pdfgrep-ignore-case'."
6161

6262
(defun pdfgrep-default-command ()
6363
"Compute the default pdfgrep command for `pdfgrep'."
64-
(let ((cmd (concat pdfgrep-program pdfgrep-options
65-
(when pdfgrep-ignore-case
66-
"-i "))))
67-
(if pdfgrep-ignore-errors
68-
(cons (concat cmd " 2>/dev/null") (1+ (length cmd)))
69-
cmd)))
64+
(let* ((cmd (concat pdfgrep-program pdfgrep-options
65+
(when pdfgrep-ignore-case
66+
"-i ")))
67+
(cmd-ignore-errors (if pdfgrep-ignore-errors
68+
(cons (concat cmd " 2>/dev/null") (1+ (length cmd)))
69+
nil)))
70+
(cond ((and (equal major-mode 'pdf-view-mode) cmd-ignore-errors)
71+
(cons (concat (car cmd-ignore-errors) " " buffer-file-name) (cdr cmd-ignore-errors)))
72+
((equal major-mode 'pdf-view-mode)
73+
(cons (concat cmd " " buffer-file-name) (1+ (length cmd))))
74+
(pdfgrep-ignore-errors cmd-ignore-errors)
75+
(t cmd))))
7076

7177
(defun pdfgrep (command-args)
7278
"Run pdfgrep with user-specified COMMAND-ARGS, collect output in a buffer.

0 commit comments

Comments
 (0)