emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult a1dd9f9 1/2: Revert more flexible regexp argume


From: ELPA Syncer
Subject: [elpa] externals/consult a1dd9f9 1/2: Revert more flexible regexp argument filtering for now
Date: Tue, 3 Aug 2021 15:57:07 -0400 (EDT)

branch: externals/consult
commit a1dd9f9414106826c2e6bf63cc8f73ae3edf6afe
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Revert more flexible regexp argument filtering for now
---
 CHANGELOG.org |   2 -
 README.org    |  17 +++-----
 consult.el    | 137 +++++++++++++++++++++++++---------------------------------
 3 files changed, 67 insertions(+), 89 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index ad9d557..7483d89 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -10,8 +10,6 @@
 - Add =consult-line-multi= to search multiple buffers
 - Removed obsolete =consult-yank=, =consult-async-default-split=, 
=consult-config=
 - =consult-ripgrep=: Use =--smart-case=
-- =consult-*-command=: Generalized command line configuration, which supports
-  transformations of the input string.
 
 * Version 0.9 (2021-06-22)
 
diff --git a/README.org b/README.org
index 7c67802..078b8ad 100644
--- a/README.org
+++ b/README.org
@@ -250,14 +250,13 @@ their descriptions.
    search gets started. Consult splits the input string into two parts, if the
    first character is a punctuation character, like =#=. For example
    =#grep-regexp#filter-string=, is split at the second =#=. The string 
=grep-regexp=
-   is passed to Grep. By default, spaces are replaced by ~.*~. The 
=filter-string=
-   is passed to the /fast/ Emacs filtering to further narrow down the list of
-   matches. This is particularly useful if you are using an advanced completion
-   style like orderless. =consult-grep= supports preview. If the
-   =consult-project-root-function= is [[#use-package-example][configured]] and 
returns non-nil, =consult-grep=
-   searches the current project directory. Otherwise the =default-directory= is
-   searched. If =consult-grep= is invoked with prefix argument =C-u M-s g=, 
you can
-   specify the directory manually.
+   is passed to Grep, the =filter-string= is passed to the /fast/ Emacs 
filtering to
+   further narrow down the list of matches. This is particularly useful if you
+   are using an advanced completion style like orderless. =consult-grep= 
supports
+   preview. If the =consult-project-root-function= is 
[[#use-package-example][configured]] and returns
+   non-nil, =consult-grep= searches the current project directory. Otherwise 
the
+   =default-directory= is searched. If =consult-grep= is invoked with prefix
+   argument =C-u M-s g=, you can specify the directory manually.
  - =consult-find=, =consult-locate=: Find file by
    matching the path against a regexp. Like for =consult-grep,= either the 
project
    root or the current directory is the root directory for the search. The 
input
@@ -535,7 +534,6 @@ their descriptions.
  Examples:
 
  - =#defun=: Search for "defun" using grep.
- - =#defun embark=: Search for "defun.*embark" using grep.
  - =#defun#consult=: Search for "defun" using grep, filter with the word
    "consult".
  - =/defun/consult=: It is also possible to use other punctuation
@@ -937,7 +935,6 @@ configuration examples.
  | consult-preview-max-size         | 10485760         | Files larger than 
this size are not previewed         |
  | consult-preview-raw-size         | 102400           | Files larger than 
this size are previewed in raw form |
  | consult-project-root-function    | nil              | Function which 
returns current project root           |
- | consult-regexp-function          | ...              | Convert string to 
regular expression                  |
  | consult-register-narrow          | ...              | Narrowing 
configuration for =consult-register=          |
  | consult-ripgrep-command          | "rg ..."         | Command line 
arguments for ripgrep                    |
  | consult-themes                   | nil              | List of themes to be 
presented for selection          |
diff --git a/consult.el b/consult.el
index d70439f..b06ff08 100644
--- a/consult.el
+++ b/consult.el
@@ -218,65 +218,65 @@ See `consult--multi' for a description of the source 
values."
   :type '(repeat (choice symbol regexp)))
 
 (defcustom consult-git-grep-command
-  '("git --no-pager grep --null --color=always --extended-regexp"
-    "--line-number -I -e"
-    (consult-regexp arg) opts)
-  "Command line arguments for git-grep, see `consult-git-grep'.
-See `consult-ripgrep-command' for details on the configuration."
-  :type 'sexp)
+  "git --no-pager grep --null --color=always --extended-regexp\
+   --line-number -I -e ARG OPTS"
+  "Command line string for git-grep, see `consult-git-grep'.
+
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options."
+  :type 'string)
 
 (defcustom consult-grep-command
-  '("grep --null --line-buffered --color=always --extended-regexp"
-    "--exclude-dir=.git --line-number -I -r . -e"
-    (consult-regexp arg) opts)
-  "Command line arguments for grep, see `consult-grep'.
-See `consult-ripgrep-command' for details on the configuration."
-  :type 'sexp)
+  "grep --null --line-buffered --color=always --extended-regexp\
+   --exclude-dir=.git --line-number -I -r . -e ARG OPTS"
+  "Command line string for grep, see `consult-grep'.
+
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options."
+  :type 'string)
 
 (defcustom consult-grep-max-columns 300
   "Maximal number of columns of grep output."
   :type 'integer)
 
 (defcustom consult-ripgrep-command
-  '("rg --null --line-buffered --color=ansi --max-columns=1000"
-    "--smart-case --no-heading --line-number . -e"
-    (consult-regexp arg) opts)
-  "Command line arguments for ripgrep, see `consult-ripgrep'.
+  "rg --null --line-buffered --color=ansi --max-columns=1000\
+   --smart-case --no-heading --line-number . -e ARG OPTS"
+  "Command line string for ripgrep, see `consult-ripgrep'.
 
-The command line arguments must be specified as a list of strings and
-expressions. The expressions which must evaluate to a string or a list of
-strings. Expressions are evaluated in a lexical context, where `arg' is the
-input argument and `opts' is a list of auxillary command line options."
-  :type 'sexp)
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options."
+  :type 'string)
 
 (defcustom consult-find-command
-  '("find . -not ( -wholename */.* -prune ) -ipath"
-    (string-join `("" ,@(split-string arg nil t) "") "*") opts)
-  "Command line arguments for find, see `consult-find'.
-See `consult-ripgrep-command' for details on the configuration."
-  :type 'sexp)
+  "find . -not ( -wholename */.* -prune ) -ipath *ARG* OPTS"
+  "Command line string for find, see `consult-find'.
+
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options. By default the ARG is wrapped in wildcards."
+  :type 'string)
 
 (defcustom consult-locate-command
-  '("locate --ignore-case --existing --regexp"
-    (consult-regexp arg) opts)
-  "Command line arguments for locate, see `consult-locate'.
-See `consult-ripgrep-command' for details on the configuration."
-  :type 'sexp)
+  "locate --ignore-case --existing --regexp ARG OPTS"
+  "Command line string for locate, see `consult-locate'.
+
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options."
+  :type 'string)
 
 (defcustom consult-man-command
-  '("man -k" arg opts)
-  "Command line arguments for man, see `consult-man'.
-See `consult-ripgrep-command' for details on the configuration."
-  :type 'sexp)
-
-(defcustom consult-regexp-function
-  #'consult-spaced-regexp
-  "Function which transforms a string to a regular expression.
-By default, spaces in the input string are replaced by `.*'. In order to
-disable the regexp transformation, use the `identity' function."
-  :type '(choice (const :tag "Space separated" consult-spaced-regexp)
-                 (const :tag "No transformation" identity)
-                 (function :tag "Custom function")))
+  "man -k ARG OPTS"
+  "Command line string for man, see `consult-man'.
+
+The command string must have a specific format, including ARG and OPTS
+substrings. ARG is replaced by the filter string and OPTS by the auxillary
+command options."
+  :type 'string)
 
 (defcustom consult-preview-key 'any
   "Preview trigger keys, can be nil, 'any, a single key or a list of keys."
@@ -535,14 +535,6 @@ ARGS is a list of commands or sources followed by the list 
of keyword-value pair
 
 ;;;; Helper functions and macros
 
-(defun consult-spaced-regexp (str)
-  "Convert string STR to a regular expression, replace spaces by `.*'."
-  (string-join (split-string str nil t) ".*"))
-
-(defun consult-regexp (str)
-  "Convert string STR to a regular expression, call `consult-regexp-function'."
-  (funcall consult-regexp-function str))
-
 (defmacro consult--keep! (list form)
   "Evaluate FORM for every element of LIST and keep the non-nil results."
   (declare (indent 1))
@@ -1074,7 +1066,8 @@ FACE is the cursor face."
   "Normalize PREVIEW-KEY, return alist of keys and debounce times."
   (let ((keys)
         (debounce 0))
-    (setq preview-key (consult--to-list preview-key))
+    (unless (listp preview-key)
+      (setq preview-key (list preview-key)))
     (while preview-key
       (if (eq (car preview-key) :debounce)
           (setq debounce (cadr preview-key)
@@ -1602,20 +1595,9 @@ The refresh happens after a DELAY, defaulting to 
`consult-async-refresh-delay'."
   "Filter candidates of ASYNC by FUN."
   (consult--async-transform async seq-filter fun))
 
-(defun consult--to-list (list)
-  "Ensure that LIST is a list."
-  (if (listp list) list (list list)))
-
 (defun consult--command-args (cmd)
   "Split command arguments and append to CMD."
-  (when (stringp cmd)
-    (message "`%s' used the deprecated command configuration %S" this-command 
cmd)
-    (setq cmd (list cmd)))
-  (setq cmd (seq-mapcat (lambda (x)
-                          (if (stringp x)
-                              (split-string-and-unquote x)
-                            (list x)))
-                        cmd))
+  (setq cmd (split-string-and-unquote cmd))
   (lambda (input)
     (save-match-data
       (let ((opts))
@@ -1626,14 +1608,11 @@ The refresh happens after a DELAY, defaulting to 
`consult-async-refresh-delay'."
                 input (substring input 0 (match-beginning 0))
                 opts (ignore-errors (split-string-and-unquote opts))))
         (unless (string-blank-p input)
-          (seq-mapcat
-           (lambda (x)
-             (cond
-              ;; TODO OPTS and ARG are deprecated
-              ((equal x "OPTS") opts)
-              ((stringp x) (list (replace-regexp-in-string "ARG" input x 
'fixedcase 'literal)))
-              (t (consult--to-list (eval x `((opts . ,opts) (arg . 
,input)))))))
-           cmd))))))
+          (mapcan (lambda (x)
+                    (if (string= x "OPTS")
+                        opts
+                      (list (replace-regexp-in-string "ARG" input x 'fixedcase 
'literal))))
+                  cmd))))))
 
 (defmacro consult--async-command (cmd &rest args)
   "Asynchronous CMD pipeline.
@@ -1681,9 +1660,13 @@ ASYNC must be non-nil for async completion functions."
   (delete-dups
    (append
     ;; the defaults are at the beginning of the future history
-    (consult--to-list minibuffer-default)
+    (if (listp minibuffer-default)
+        minibuffer-default
+      (list minibuffer-default))
     ;; then our custom items
-    (remove "" (remq nil (consult--to-list items)))
+    (remove "" (remq nil (if (listp items)
+                             items
+                           (list items))))
     ;; Add all the completions for non-async commands. For async commands this 
feature
     ;; is not useful, since if one selects a completion candidate, the async 
search is
     ;; restarted using that candidate string. This usually does not yield a 
desired
@@ -1932,7 +1915,7 @@ INHERIT-INPUT-METHOD, if non-nil the minibuffer inherits 
the input method."
                        (let ((key (if (plist-member src :preview-key)
                                       (plist-get src :preview-key)
                                     consult-preview-key)))
-                         (consult--to-list key)))
+                         (if (listp key) key (list key))))
                      sources))))
 
 (defun consult--multi-lookup (sources _ candidates cand)
@@ -3655,7 +3638,7 @@ AS is a conversion function."
       (when sort
         (setq buffers (funcall (intern (format "consult--buffer-sort-%s" 
sort)) buffers)))
       (when (or filter mode as (stringp root))
-        (let ((mode (consult--to-list mode))
+        (let ((mode (if (listp mode) mode (list mode)))
               (exclude-re (consult--regexp-filter exclude))
               (include-re (consult--regexp-filter include)))
           (consult--keep! buffers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]