about summary refs log tree commit diff stats
path: root/lisp/acdw-consult.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw-consult.el')
-rw-r--r--lisp/acdw-consult.el93
1 files changed, 0 insertions, 93 deletions
diff --git a/lisp/acdw-consult.el b/lisp/acdw-consult.el deleted file mode 100644 index 84a7fea..0000000 --- a/lisp/acdw-consult.el +++ /dev/null
@@ -1,93 +0,0 @@
1;;; acdw-consult.el -*- lexical-binding: t; coding: utf-8-unix -*-
2
3;; Customization for consult.
4
5(require 'consult)
6
7(defun acdw-consult/sensible-grep (&optional arg)
8 "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep'
9if ripgrep is installed, otherwise `consult-grep'."
10 (interactive "P")
11 (call-interactively
12 (cond ((executable-find "rg")
13 (if (fboundp 'affe-grep)
14 #'affe-grep
15 #'consult-ripgrep))
16 ((string-equal (vc-backend buffer-file-name) "Git")
17 #'consult-git-grep)
18 (t #'consult-grep))))
19
20(defun acdw-consult/sensible-find (&optional arg)
21 "Peform `consult-locate' if locate is installed, otehrwise `consult-find'."
22 (interactive "P")
23 (call-interactively
24 (cond ((executable-find "locate")
25 #'consult-locate)
26 ((fboundp 'affe-find)
27 (when (executable-find "fd")
28 (setq affe-find-command "fd -HI -t f"))
29 #'affe-find)
30 (t #'consult-find))))
31
32;; Orderless Regexp Compiler! -- from Consult Wiki
33(defun consult--orderless-regexp-compiler (input type)
34 (setq input (orderless-pattern-compiler input))
35 (cons
36 (mapcar (lambda (r) (consult--convert-regexp r type)) input)
37 (lambda (str) (orderless--highlight input str))))
38
39(defun acdw-consult/complete-in-region (&rest args)
40 (apply (if vertico-mode
41 #'consult-completion-in-region
42 #'completion--in-region)
43 args))
44
45(defmacro consult-history-to-modes (map-hook-alist)
46 (let (defuns)
47 (dolist (map-hook map-hook-alist)
48 (let ((map-name (symbol-name (car map-hook)))
49 (key-defs `(progn (define-key
50 ,(car map-hook)
51 (kbd "M-r")
52 (function consult-history))
53 (define-key ,(car map-hook)
54 (kbd "M-s") nil))))
55 (push (if (cdr map-hook)
56 `(add-hook ',(cdr map-hook)
57 (defun
58 ,(intern (concat map-name
59 "@consult-history-bind"))
60 nil
61 ,(concat
62 "Bind `consult-history' to M-r in "
63 map-name ".\n"
64 "Defined by `consult-history-to-modes'.")
65 ,key-defs))
66 key-defs)
67 defuns)))
68 `(progn ,@ (nreverse defuns))))
69
70;;; Circe buffers source
71
72(require 'cl-lib)
73(autoload 'circe-server-buffers "circe")
74(autoload 'circe-server-chat-buffers "circe")
75
76(defun circe-all-buffers ()
77 (cl-loop with servers = (circe-server-buffers)
78 for server in servers
79 collect server
80 nconc
81 (with-current-buffer server
82 (cl-loop for buf in (circe-server-chat-buffers)
83 collect buf))))
84
85(defvar circe-buffer-source
86 `(:name "circe"
87 :hidden t
88 :narrow ?c
89 :category buffer
90 :state ,#'consult--buffer-state
91 :items ,(lambda () (mapcar #'buffer-name (circe-all-buffers)))))
92
93(provide 'acdw-consult)