[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra 328da1f 170/395: counsel.el (counsel-rg): Spl
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra 328da1f 170/395: counsel.el (counsel-rg): Split command args in a more familiar way |
Date: |
Thu, 25 Feb 2021 08:31:55 -0500 (EST) |
branch: externals/ivy-hydra
commit 328da1f95ce5f3386b63b28ca41a48bd88cf4144
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
counsel.el (counsel-rg): Split command args in a more familiar way
* counsel.el (counsel--split-command-args): Update.
* ivy-test.el (counsel--split-command-args): Add test.
Before:
-g*.el -- require i
After:
require i -- -g*.el
The advantage is that we usually first input the search string and
only then the command args.
Fixes #2356
Re #1559
---
counsel.el | 18 +++++++-----------
ivy-test.el | 8 ++++++++
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/counsel.el b/counsel.el
index 6b7c290..153a049 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2834,20 +2834,16 @@ regex string."
(defvar counsel--regex-look-around nil)
-(defconst counsel--command-args-separator "-- ")
+(defconst counsel--command-args-separator " -- ")
(defun counsel--split-command-args (arguments)
"Split ARGUMENTS into its switches and search-term parts.
Return pair of corresponding strings (SWITCHES . SEARCH-TERM)."
- (let ((switches "")
- (search-term arguments))
- (when (string-prefix-p "-" arguments)
- (let ((index (string-match counsel--command-args-separator arguments)))
- (when index
- (setq search-term
- (substring arguments (+ (length
counsel--command-args-separator) index)))
- (setq switches (substring arguments 0 index)))))
- (cons switches search-term)))
+ (if (string-match counsel--command-args-separator arguments)
+ (cons
+ (substring arguments (match-end 0))
+ (substring arguments 0 (match-beginning 0)))
+ (cons "" arguments)))
(defun counsel--format-ag-command (extra-args needle)
"Construct a complete `counsel-ag-command' as a string.
@@ -3071,7 +3067,7 @@ EXTRA-RG-ARGS string, if non-nil, is appended to
`counsel-rg-base-command'.
RG-PROMPT, if non-nil, is passed as `ivy-read' prompt argument.
Example input with inclusion and exclusion file patterns:
- -g*.py -g!*test* -- ..."
+ require i -- -g*.el"
(interactive)
(let ((counsel-ag-base-command
(concat counsel-rg-base-command (counsel--rg-targets)))
diff --git a/ivy-test.el b/ivy-test.el
index 37b7ee1..1497fcd 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1499,6 +1499,14 @@ a buffer visiting a file."
:dir ivy-empty))
ivy-empty)))
+(ert-deftest counsel--split-command-args ()
+ (should (equal
+ (counsel--split-command-args "require -- -g*.el")
+ '("-g*.el" . "require")))
+ (should (equal
+ (counsel--split-command-args "counsel--format")
+ '("" . "counsel--format"))))
+
(defun ivy-test-run-tests ()
(let ((test-sets
'(
- [elpa] externals/ivy-hydra 6a902b5 145/395: counsel.el (string-trim-left): Add declare-function, (continued)
- [elpa] externals/ivy-hydra 6a902b5 145/395: counsel.el (string-trim-left): Add declare-function, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 98a29b6 148/395: Fix C-<backspace> not working in counsel-file-jump, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 19bc4ed 149/395: ivy.el (ivy-ignore-buffers): Ignore *tramp/ buffers, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 982a5ac 150/395: ivy.el (ivy--tramp-candidates): The initial directory on remote should be "/", Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 554c178 158/395: ivy.el (ivy-set-actions): Allow to override the default action using "o", Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0cff3e1 157/395: swiper.el (swiper): Add isearch-clean-overlays, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 35d015b 166/395: ivy.el (ivy-avy): Configure no-counsel-M-x, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 18d7ff9 168/395: ivy.el (ivy--set-candidates): Delete duplicates, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra b9eb3c1 162/395: swiper.el (swiper--line-number): Works with ivy-mark, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ba73e45 156/395: ivy.el (ivy-read-action): Avoid ivy-read-action-ivy overwriting ivy--directory, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 328da1f 170/395: counsel.el (counsel-rg): Split command args in a more familiar way,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra 1c1573e 167/395: ivy.el (ivy--update-prompt): Handle auto-insert.el, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 45a3609 176/395: counsel.el (counsel-rg-base-command): Add "-M 120" by default, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0258725 175/395: counsel.el: Fix candidate splitting when eol is CR or CRLF, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 8fae568 184/395: counsel.el (counsel-org-link): Add, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9b36d9c 186/395: swiper.el (swiper-isearch): Use ivy-init-fns-alist, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9e1513f 195/395: ivy.el (ivy--split): Don't split consecutive group brackets, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 7b9b3cc 200/395: ivy.el (ivy--switch-buffer-matcher): Complete remote dirs via ":", Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 829cf8a 212/395: ivy.el (ivy--done): Set ivy-text, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 95896df 221/395: Honour sentence-end-double-space in recent change, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra c0a960b 216/395: ivy.el (ivy-read): Don't error on "Selecting deleted buffer", Basil L. Contovounesios, 2021/02/25