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

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

[elpa] externals/consult 8e90f2d: Deprecate consult-*-command in favor o


From: ELPA Syncer
Subject: [elpa] externals/consult 8e90f2d: Deprecate consult-*-command in favor of consult-*-config (Fix #384)
Date: Fri, 6 Aug 2021 04:57:07 -0400 (EDT)

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

    Deprecate consult-*-command in favor of consult-*-config (Fix #384)
    
    The variables have been renamed in order to reduce breakage. Improve
    the error messages.
---
 CHANGELOG.org | 13 +++++++++----
 README.org    | 12 ++++++------
 consult.el    | 57 ++++++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 53 insertions(+), 29 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 28992e7..70ae37d 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -13,16 +13,21 @@
 - =consult-grep/git-grep=: Use =--ignore-case=
 - Deprecate =consult-<cmd>-command= in favor of =consult-<cmd>-config.=
 - =consult-find=: Use regular expressions instead of globbing/wildcards by 
default.
+- =consult-find/locate/man=: Add highlighting to the matching file/man page 
names.
 - =consult-grep/git-grep/ripgrep/find/locate=: Add support for multiple 
patterns.
   + =consult-git-grep= and =consult-find= support unordered patterns out of 
the box.
-    For example: "first second third" is transformed to "first -and second 
-and third".
-  + =consult-grep= and =consult-ripgrep= support unordered patterns if the 
program supports it.
+    Example: "first second third" is transformed to "first -and second -and 
third".
+  + =consult-grep= and =consult-ripgrep= support unordered patterns if the 
program
+    supports it.
   + =consult-locate= only support ordered patterns.
-    For example: "first second third" is transformed to "first.*second.*third".
-- =consult-find/locate/man=: Add highlighting.
+    Example: "first second third" is transformed to "first.*second.*third".
 - =consult-grep/git-grep/ripgrep=: Compute the highlighting based on the input,
   instead of relying on the ANSI-escaped output. This works better with 
multiple
   patterns, but may occasionally produce false highlighting.
+- Deprecate =consult-*-command= configuration variables in favor of 
=consult-*config=.
+  The variables have been renamed since the configuration format changed. The 
new
+  configuration variables allow you to specify a command line builder function,
+  which computes the command line.
 
 * Version 0.9 (2021-06-22)
 
diff --git a/README.org b/README.org
index 97d93f6..f5a15f0 100644
--- a/README.org
+++ b/README.org
@@ -917,19 +917,19 @@ configuration examples.
  | consult-buffer-filter            | Filter for =consult-buffer=              
               |
  | consult-buffer-sources           | List of virtual buffer sources           
             |
  | consult-crm-prefix               | Prefix string for CRM candidates         
             |
- | consult-find-command             | Command line arguments for find          
             |
+ | consult-find-config              | Command line arguments for find          
             |
  | consult-fontify-max-size         | Buffers larger than this limit are not 
fontified      |
  | consult-fontify-preserve         | Preserve fontification for line-based 
commands.       |
- | consult-git-grep-command         | Command line arguments for git-grep      
             |
+ | consult-git-grep-config          | Command line arguments for git-grep      
             |
  | consult-goto-line-numbers        | Show line numbers for 
=consult-goto-line=               |
  | consult-grep-max-columns         | Maximal number of columns of the 
matching lines       |
- | consult-grep-command             | Command line arguments for grep          
             |
+ | consult-grep-config              | Command line arguments for grep          
             |
  | consult-imenu-config             | Mode-specific configuration for 
=consult-imenu=         |
  | consult-line-numbers-widen       | Show absolute line numbers when 
narrowing is active.  |
  | consult-line-point-placement     | Placement of the point used by 
=consult-line=           |
  | consult-line-start-from-top      | Start the =consult-line= search from the 
top            |
- | consult-locate-command           | Command line arguments for locate        
             |
- | consult-man-command              | Command line arguments for man           
             |
+ | consult-locate-config            | Command line arguments for locate        
             |
+ | consult-man-config               | Command line arguments for man           
             |
  | consult-mode-command-filter      | Filter for =consult-mode-command=        
               |
  | consult-mode-histories           | Mode-specific history variables          
             |
  | consult-narrow-key               | Narrowing prefix key during completion   
             |
@@ -940,7 +940,7 @@ configuration examples.
  | consult-preview-raw-size         | Files larger than this size are 
previewed in raw form |
  | consult-project-root-function    | Function which returns current project 
root           |
  | consult-register-narrow          | Narrowing configuration for 
=consult-register=          |
- | consult-ripgrep-command          | Command line arguments for ripgrep       
             |
+ | consult-ripgrep-config           | Command line arguments for ripgrep       
             |
  | consult-themes                   | List of themes to be presented for 
selection          |
  | consult-widen-key                | Widening key during completion           
             |
 
diff --git a/consult.el b/consult.el
index ecc1a72..c77997b 100644
--- a/consult.el
+++ b/consult.el
@@ -225,7 +225,23 @@ See `consult--multi' for a description of the source 
values."
   "\\`\\(?:./\\)?\\([^\n:]+\\):\\([0-9]+\\):"
   "Regexp used to match file and line of grep output.")
 
-(defcustom consult-grep-command
+;; TODO remove deprecation
+(defmacro consult--obsolete-command-config (&rest vars)
+  "Create obsolete command configuration VARS."
+  (macroexp-progn
+   (mapcan
+    (lambda (var)
+      (let ((sym (intern (format "consult-%s-command" var)))
+            (msg (format "This variable has been deprecated in favor of 
`consult-%s-config'.
+The command configuration format has been updated.
+See `consult-grep-config' or the CHANGELOG for more information.
+Please adjust your configuration." var)))
+        `((defvar ,sym ,msg)
+          (make-obsolete-variable ',sym ,msg "0.9"))))
+    vars)))
+(consult--obsolete-command-config grep ripgrep git-grep find locate man)
+
+(defcustom consult-grep-config
   (list :args "grep --line-buffered --color=never --ignore-case\
                --exclude-dir=.git --line-number -I -r ."
         :command #'consult--grep-command-builder
@@ -245,48 +261,48 @@ the :args string. The dynamically computed arguments are 
appended to these
 static arguments."
   :type 'plist)
 
-(defcustom consult-git-grep-command
+(defcustom consult-git-grep-config
   (list :args "git --no-pager grep --color=never --ignore-case\
                --extended-regexp --line-number -I"
         :command #'consult--git-grep-command-builder
         :match consult--grep-match-regexp
         :highlight #'consult--command-highlight)
   "Command configuration for git-grep, see `consult-git-grep'.
-See `consult-grep-command' for more information."
+See `consult-grep-config' for more information."
   :type 'plist)
 
-(defcustom consult-ripgrep-command
+(defcustom consult-ripgrep-config
   (list :args "rg --line-buffered --color=never --max-columns=1000 
--path-separator /\
                --smart-case --no-heading --line-number ."
         :command #'consult--ripgrep-command-builder
         :match consult--grep-match-regexp
         :highlight #'consult--command-highlight)
   "Command configuration for ripgrep, see `consult-ripgrep'.
-See `consult-grep-command' for more information."
+See `consult-grep-config' for more information."
   :type 'plist)
 
-(defcustom consult-find-command
+(defcustom consult-find-config
   (list :args "find . -not ( -wholename */.* -prune )"
         :command #'consult--find-command-builder
         :highlight #'consult--command-highlight)
   "Command configuration for find, see `consult-find'.
-See `consult-grep-command' for more information."
+See `consult-grep-config' for more information."
   :type 'plist)
 
-(defcustom consult-locate-command
+(defcustom consult-locate-config
   (list :args "locate --ignore-case --existing --regexp"
         :command #'consult--locate-command-builder
         :highlight #'consult--command-highlight)
   "Command configuration for locate, see `consult-locate'.
-See `consult-grep-command' for more information."
+See `consult-grep-config' for more information."
   :type 'plist)
 
-(defcustom consult-man-command
+(defcustom consult-man-config
   (list :args "man -k"
         :command #'consult--man-command-builder
         :highlight #'consult--command-highlight)
   "Command configuration for man, see `consult-man'.
-See `consult-grep-command' for more information."
+See `consult-grep-config' for more information."
   :type 'plist)
 
 (defcustom consult-preview-key 'any
@@ -1712,8 +1728,11 @@ The refresh happens after a DELAY, defaulting to 
`consult-async-refresh-delay'."
 (defun consult--command-builder (cmd)
   "Return command line builder given CMD.
 CMD is the command line builder function or command configuration."
+  ;; TODO remove deprecation
   (when (stringp cmd)
-    (error "`%s' uses a deprecated command configuration %S" this-command cmd))
+    (error "`%s' uses a deprecated command configuration %S.
+Please adjust your configuration.
+See `consult-grep-config' or the CHANGELOG for more information" this-command 
cmd))
   (if (functionp cmd)
       cmd
     (lambda (input) (funcall (plist-get cmd :command) cmd input))))
@@ -4134,7 +4153,7 @@ the directory to search in. By default the project 
directory is used
 if `consult-project-root-function' is defined and returns non-nil.
 Otherwise the `default-directory' is searched."
   (interactive "P")
-  (consult--grep "Grep" consult-grep-command dir initial))
+  (consult--grep "Grep" consult-grep-config dir initial))
 
 ;;;;; Command: consult-git-grep
 
@@ -4152,7 +4171,7 @@ Otherwise the `default-directory' is searched."
 
 See `consult-grep' for more details."
   (interactive "P")
-  (consult--grep "Git-grep" consult-git-grep-command dir initial))
+  (consult--grep "Git-grep" consult-git-grep-config dir initial))
 
 ;;;;; Command: consult-ripgrep
 
@@ -4178,7 +4197,7 @@ See `consult-grep' for more details."
 
 See `consult-grep' for more details."
   (interactive "P")
-  (consult--grep "Ripgrep" consult-ripgrep-command dir initial))
+  (consult--grep "Ripgrep" consult-ripgrep-config dir initial))
 
 ;;;;; Command: consult-find
 
@@ -4237,7 +4256,7 @@ See `consult-grep' for more details regarding the 
asynchronous search."
   (interactive "P")
   (let* ((prompt-dir (consult--directory-prompt "Find" dir))
          (default-directory (cdr prompt-dir)))
-    (find-file (consult--find (car prompt-dir) consult-find-command initial))))
+    (find-file (consult--find (car prompt-dir) consult-find-config initial))))
 
 ;;;;; Command: consult-locate
 
@@ -4255,7 +4274,7 @@ See `consult-grep' for more details regarding the 
asynchronous search."
 The locate process is started asynchronously, similar to `consult-grep'.
 See `consult-grep' for more details regarding the asynchronous search."
   (interactive)
-  (find-file (consult--find "Locate: " consult-locate-command initial)))
+  (find-file (consult--find "Locate: " consult-locate-config initial)))
 
 ;;;;; Command: consult-man
 
@@ -4289,9 +4308,9 @@ The man process is started asynchronously, similar to 
`consult-grep'.
 See `consult-grep' for more details regarding the asynchronous search."
   (interactive)
   (man (consult--read
-        (consult--async-command consult-man-command
+        (consult--async-command consult-man-config
           (consult--async-transform consult--man-format)
-          (consult--async-highlight consult-man-command))
+          (consult--async-highlight consult-man-config))
         :prompt "Manual entry: "
         :require-match t
         :lookup #'consult--lookup-cdr



reply via email to

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