-
Notifications
You must be signed in to change notification settings - Fork 0
/
helm-everything.el
80 lines (65 loc) · 2.42 KB
/
helm-everything.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
;;; package --- Summary
;;; Commentary:
;;; Code:
;; ;;; use es.exe provided by everything
;; Switch Description
;; -r Search the database using a basic POSIX regular expression.
;; -i Does a case sensitive search.
;; -w Does a whole word search.
;; -p Does a full path search.
;; -h
;; --help Display this help.
;; -n <num> Limit the amount of results shown to <num>.
;; -s Sort by full path.
(require 'helm)
(defgroup everything nil
"Bridge to the Windows desktop search-engine everything. See http://www.voidtools.com."
:group 'external
:prefix "everything-")
(defcustom everything-cmd "path/to/es.exe" "Path to es.exe."
:group 'everything
:type 'string)
(defvar everything-result-buffer "*everything*" "Name of buffer to write the query response to.
After successfully fetching the matching filenames, this buffer holds one filename per line.
See `everything-post-process-hook' to post-process this buffer.")
(defun everything-query-list nil
"Query Input And Return Output As List."
(interactive)
(with-current-buffer (current-buffer)
(everything-CLI-query (read-from-minibuffer "Query: "))
(set-buffer (get-buffer-create everything-result-buffer))
(while (search-forward "\\" nil t)
(replace-match "/" nil t))
(split-string (buffer-substring-no-properties (point-min) (point))
"\n" t)))
(defun everything-CLI-query (query)
"Main Interface To Everything.
'(everything-cmd-query QUERY)
some es parameters
-r Search the database using a basic POSIX regular expression.
-i Does a case sensitive search.
-w Does a whole word search.
-p Does a full path search.
-h Display this help.
-n <num> Limit the amount of results shown to <num>.
-s Sort by full path"
(let ((args-for-es (list query)))
(when (not (file-exists-p everything-cmd)) (error (concat everything-cmd " not found")))
(when (get-buffer everything-result-buffer)
(kill-buffer everything-result-buffer))
(apply #'call-process everything-cmd nil (get-buffer-create everything-result-buffer) nil args-for-es)))
(defvar helm-everything-source
'((name . "Everything")
(candidate-number-limit . 20)
(candidates . files-from-everything)
(action . (("Find file " . find-file)))
))
(everything-query-list)
(defun helm-everything nil
"Top Level."
(interactive)
(setq files-from-everything (everything-query-list))
(helm-other-buffer helm-everything-source everything-result-buffer))
(provide 'helm-everything)
;
;; helm-everything.el ends here