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

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

[elpa] externals/consult 750cb6ec97 1/3: Depend on compat


From: ELPA Syncer
Subject: [elpa] externals/consult 750cb6ec97 1/3: Depend on compat
Date: Sun, 8 May 2022 05:57:25 -0400 (EDT)

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

    Depend on compat
---
 consult-register.el |  6 ++----
 consult.el          | 43 ++++++++++++++-----------------------------
 2 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/consult-register.el b/consult-register.el
index c1ebf68505..51d2f36941 100644
--- a/consult-register.el
+++ b/consult-register.el
@@ -143,7 +143,7 @@ If COMPLETION is non-nil format the register for 
completion."
                (key-str (propertize (single-key-description key) 'face 
'consult-key))
                (key-len (max 3 (length key-str)))
                (`(,str . ,props) (consult-register--describe val)))
-    (when (string-match-p "\n" str)
+    (when (string-search "\n" str)
       (let* ((lines (seq-take (seq-remove #'string-blank-p (split-string str 
"\n")) 3))
              (space (apply #'min most-positive-fixnum
                            (mapcar (lambda (x) (string-match-p "[^ ]" x)) 
lines))))
@@ -216,9 +216,7 @@ for the meaning of prefix ARG."
   (condition-case err
       (jump-to-register reg arg)
     (user-error
-     (unless (string-match-p
-              "access aborted"
-              (error-message-string err) )
+     (unless (string-search "access aborted" (error-message-string err))
        (insert-register reg (not arg))))))
 
 (defun consult-register--action (action-list)
diff --git a/consult.el b/consult.el
index bfd3b49dbe..f7875e3582 100644
--- a/consult.el
+++ b/consult.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
 ;; Created: 2020
 ;; Version: 0.17
-;; Package-Requires: ((emacs "27.1"))
+;; Package-Requires: ((emacs "27.1") (compat "28.1"))
 ;; Homepage: https://github.com/minad/consult
 
 ;; This file is part of GNU Emacs.
@@ -51,6 +51,8 @@
 (require 'kmacro)
 (require 'recentf)
 (require 'seq)
+(require 'compat)
+(require 'compat-28)
 
 (defgroup consult nil
   "Consulting `completing-read'."
@@ -636,7 +638,7 @@ matches case insensitively."
    ((eq type 'basic)
     (string-join regexps ".*"))
    (t
-    (when (> (length regexps) 3)
+    (when (length> regexps 3)
       (message "Too many regexps, %S ignored. Use post-filtering!"
                (string-join (seq-drop regexps 3) " "))
       (setq regexps (seq-take regexps 3)))
@@ -753,11 +755,6 @@ The line beginning/ending BEG/END is bound in BODY."
            ,@body
            (setq ,beg (1+ ,end)))))))
 
-(defmacro consult--static-if (cond then &rest else)
-  "If COND yields non-nil at compile time, do THEN, else do ELSE."
-  (declare (indent 2))
-  (if (eval cond 'lexical) then (macroexp-progn else)))
-
 (defun consult--display-width (string)
   "Compute width of STRING taking display and invisible properties into 
account."
   (let ((pos 0) (width 0) (end (length string)))
@@ -770,15 +767,7 @@ The line beginning/ending BEG/END is bound in BODY."
           (while (< pos nextd)
             (let ((nexti (next-single-property-change pos 'invisible string 
nextd)))
               (unless (get-text-property pos 'invisible string)
-                (setq width (+ width
-                               ;; bug#47712: Emacs 28 can compute 
`string-width' of substrings
-                               (consult--static-if (eq 3 (cdr (func-arity 
#'string-width)))
-                                   (string-width string pos nexti)
-                                 (string-width
-                                  ;; Avoid allocation for the full string.
-                                  (if (and (= pos 0) (= nexti end))
-                                      string
-                                    (substring-no-properties string pos 
nexti)))))))
+                (setq width (+ width (compat-string-width string pos nexti))))
               (setq pos nexti))))))
     width))
 
@@ -1226,7 +1215,7 @@ ORIG is the original function, HOOKS the arguments."
                                           buffer-file-name nil)))))
                    (add-hook 'pre-command-hook hook))
                  ;; Only keep a few buffers alive
-                 (while (> (length temporary-buffers) 
consult-preview-max-count)
+                 (while (length> temporary-buffers consult-preview-max-count)
                    (kill-buffer (cdar (last temporary-buffers)))
                    (setq temporary-buffers (nbutlast temporary-buffers))))
                buf)))
@@ -1353,7 +1342,7 @@ FACE is the cursor face."
   "Normalize PREVIEW-KEY, return alist of keys and debounce times."
   (let ((keys)
         (debounce 0))
-    (setq preview-key (consult--ensure-list preview-key))
+    (setq preview-key (ensure-list preview-key))
     (while preview-key
       (if (eq (car preview-key) :debounce)
           (setq debounce (cadr preview-key)
@@ -1547,7 +1536,7 @@ This command is used internally by the narrowing system 
of `consult--read'."
     "" nil :filter
     ,(lambda (&optional _)
        (let ((str (minibuffer-contents-no-properties)))
-         (when-let (pair (or (and (= 1 (length str))
+         (when-let (pair (or (and (length= str 1)
                                   (assoc (aref str 0) consult--narrow-keys))
                              (and (string= str "")
                                   (assoc 32 consult--narrow-keys))))
@@ -1982,10 +1971,6 @@ 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--ensure-list (list)
-  "Ensure that LIST is a list."
-  (if (listp list) list (list list))) ;; Emacs 28 ensure-list
-
 (defun consult--command-builder (builder)
   "Return command line builder given CMD.
 BUILDER is the command line builder function."
@@ -2037,9 +2022,9 @@ ASYNC must be non-nil for async completion functions."
   (delete-dups
    (append
     ;; the defaults are at the beginning of the future history
-    (consult--ensure-list minibuffer-default)
+    (ensure-list minibuffer-default)
     ;; then our custom items
-    (remove "" (remq nil (consult--ensure-list items)))
+    (remove "" (remq nil (ensure-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
@@ -2291,7 +2276,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--ensure-list key)))
+                         (ensure-list key)))
                      sources))))
 
 (defun consult--multi-lookup (sources selected candidates _input narrow &rest 
_)
@@ -3905,8 +3890,8 @@ The command supports previewing the currently selected 
theme."
   (sort buffers
         (lambda (x y)
           (setq x (buffer-name x) y (buffer-name y))
-          (let ((a (and (> (length x) 0) (eq (aref x 0) ?*)))
-                (b (and (> (length y) 0) (eq (aref y 0) ?*))))
+          (let ((a (and (length> x 0) (eq (aref x 0) ?*)))
+                (b (and (length> y 0) (eq (aref y 0) ?*))))
             (if (eq a b)
                 (string< x y)
               (not a))))))
@@ -4309,7 +4294,7 @@ BUILDER is the command argument builder."
                        (content (substring str (match-end 0)))
                        (file-len (length file))
                        (line-len (length line)))
-                  (when (> (length content) consult-grep-max-columns)
+                  (when (length> content consult-grep-max-columns)
                     (setq content (substring content 0 
consult-grep-max-columns)))
                   (when highlight
                     (funcall highlight content))



reply via email to

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