Generalize thing-at-point & region functions
This commit is contained in:
parent
d426349f21
commit
27bf3c85b5
7 changed files with 80 additions and 58 deletions
|
@ -264,21 +264,17 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
|
|||
" "
|
||||
(mapconcat #'shell-quote-argument args " "))))
|
||||
(counsel-rg
|
||||
(or (if query query)
|
||||
(when (use-region-p)
|
||||
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
|
||||
(end (or (bound-and-true-p evil-visual-end) (region-end))))
|
||||
(when (> (abs (- end beg)) 1)
|
||||
(let ((query (buffer-substring-no-properties beg end)))
|
||||
;; Escape characters that are special to ivy searches
|
||||
(replace-regexp-in-string "[! |]" (lambda (substr)
|
||||
(cond ((and (string= substr " ")
|
||||
(not (featurep! +fuzzy)))
|
||||
" ")
|
||||
((string= substr "|")
|
||||
"\\\\\\\\|")
|
||||
((concat "\\\\" substr))))
|
||||
(rxt-quote-pcre query)))))))
|
||||
(or query
|
||||
(when (doom-region-active-p)
|
||||
(replace-regexp-in-string
|
||||
"[! |]" (lambda (substr)
|
||||
(cond ((and (string= substr " ")
|
||||
(not (featurep! +fuzzy)))
|
||||
" ")
|
||||
((string= substr "|")
|
||||
"\\\\\\\\|")
|
||||
((concat "\\\\" substr))))
|
||||
(rxt-quote-pcre (doom-thing-at-point-or-region)))))
|
||||
directory args
|
||||
(or prompt
|
||||
(format "rg%s [%s]: "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue