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

Add support to show/hide results from all files at once #140

Merged
merged 1 commit into from
Nov 30, 2023
Merged
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
16 changes: 16 additions & 0 deletions deadgrep.el
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ Returns a list ordered by the most recently accessed."
;; TODO: this should work when point is anywhere in the file, not
;; just on its heading.
(define-key map (kbd "TAB") #'deadgrep-toggle-file-results)
(define-key map (kbd "S-C-i") #'deadgrep-toggle-all-file-results)
(define-key map (kbd "<backtab>") #'deadgrep-toggle-all-file-results)

;; Keybinding chosen to match `kill-compilation'.
(define-key map (kbd "C-c C-k") #'deadgrep-kill-process)
Expand Down Expand Up @@ -1240,6 +1242,20 @@ Keys are interned filenames, so they compare with `eq'.")
(deadgrep--show)
(deadgrep--hide)))))

(defun deadgrep-toggle-all-file-results ()
"Show/hide the results of all files."
(interactive)
(let ((should-show (cl-some #'cdr deadgrep--hidden-files)))
(save-excursion
(goto-char (point-min))
(while (not (eq (point) (point-max)))
(goto-char (or (next-single-property-change (point) 'deadgrep-filename)
(point-max)))
(when (deadgrep--filename)
(if should-show
(deadgrep--show)
(deadgrep--hide)))))))

(defun deadgrep--show ()
(-let* ((file-name (deadgrep--filename))
((start-pos end-pos) (alist-get (intern file-name) deadgrep--hidden-files)))
Expand Down
Loading