Commit f17af863 authored by shankar2k's avatar shankar2k Committed by Jason Blevins

Add deft-filter-hook for filter string changes

parent 462dd37d
......@@ -729,6 +729,9 @@ or kebab-case
(defvar deft-mode-hook nil
"Hook run when entering Deft mode.")
(defvar deft-filter-hook nil
"Hook run when the Deft filter string changes.")
(defvar deft-filter-regexp nil
"A list of string representing the current filter used by Deft.
......@@ -1447,7 +1450,8 @@ Deft buffer."
(when deft-filter-regexp
(setq deft-filter-regexp nil)
(setq deft-current-files deft-all-files)
(deft-refresh))
(deft-refresh)
(run-hooks 'deft-filter-hook))
(message "Filter cleared."))
(defun deft-filter (str &optional reset)
......@@ -1490,7 +1494,8 @@ replace the entire filter string."
(setq deft-filter-regexp (list str))
(setq deft-filter-regexp nil)))
(deft-filter-update)
(deft-refresh-browser))
(deft-refresh-browser)
(run-hooks 'deft-filter-hook))
(defun deft-filter-increment ()
"Append character to the filter regexp and update `deft-current-files'."
......@@ -1502,12 +1507,13 @@ replace the entire filter string."
(if (and deft-incremental-search (string= char " "))
(setq deft-filter-regexp (cons "" deft-filter-regexp))
(progn
(if (car deft-filter-regexp)
(setcar deft-filter-regexp (concat (car deft-filter-regexp) char))
(setq deft-filter-regexp (list char)))
(setq deft-current-files (deft-filter-files deft-current-files))
(setq deft-current-files (delq nil deft-current-files))
(deft-refresh-browser)))))
(if (car deft-filter-regexp)
(setcar deft-filter-regexp (concat (car deft-filter-regexp) char))
(setq deft-filter-regexp (list char)))
(setq deft-current-files (deft-filter-files deft-current-files))
(setq deft-current-files (delq nil deft-current-files))
(deft-refresh-browser)
(run-hooks 'deft-filter-hook)))))
(defun deft-filter-decrement ()
"Remove last character from the filter, if possible, and update.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment