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

    Require Emacs 28.1
---
 CHANGELOG.org      |  2 ++
 README.org         |  3 +-
 consult-flymake.el |  3 +-
 consult.el         | 98 ++++++++++++++++++------------------------------------
 4 files changed, 36 insertions(+), 70 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 613bc69b32..cd7aca3577 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -4,8 +4,10 @@
 
 * Development
 
+- Require Emacs 28.1.
 - ~consult-grep~, ~consult-find~ and similar commands: Ask for project first, 
when
   invoked with double prefix argument ~C-u C-u~.
+- Deprecate ~consult-yank-rotate~ in favor of ~yank-from-kill-ring-rotate~.
 
 * Version 1.8 (2024-07-25)
 
diff --git a/README.org b/README.org
index 44f0754088..49ac998ee7 100644
--- a/README.org
+++ b/README.org
@@ -924,7 +924,6 @@ an overview of all Consult variables and functions with 
their descriptions.
 | consult-ripgrep-args             | Command line arguments for ripgrep        
          |
 | consult-themes                   | List of themes to be presented for 
selection        |
 | consult-widen-key                | Widening key during completion            
          |
-| consult-yank-rotate              | Rotate kill ring                          
          |
 
 ** Project support
 :properties:
@@ -1037,7 +1036,7 @@ There exist multiple fine completion UIs beside Vertico, 
which are supported by
 Consult. Give them a try and find out which interaction model fits best for 
you.
 
 - The builtin completion UI, which pops up the =*Completions*= buffer.
-- The builtin =icomplete-vertical-mode= in Emacs 28 or newer.
+- The builtin =icomplete-vertical-mode=.
 - [[https://git.sr.ht/~protesilaos/mct][mct by Protesilaos Stavrou]]: 
Minibuffer and Completions in Tandem, which builds
   on the default completion UI.
 
diff --git a/consult-flymake.el b/consult-flymake.el
index 3061ffe742..075a78b5c9 100644
--- a/consult-flymake.el
+++ b/consult-flymake.el
@@ -98,8 +98,7 @@ buffers in the current project instead of just the current 
buffer."
   (consult--forbid-minibuffer)
   (consult--read
    (consult-flymake--candidates
-     (if-let (((and project (fboundp 'flymake--project-diagnostics)))
-              (project (project-current)))
+     (if-let ((project (and project (project-current))))
          (flymake--project-diagnostics project)
        (flymake-diagnostics)))
    :prompt "Flymake diagnostic: "
diff --git a/consult.el b/consult.el
index e382893f7a..c3cdfb7a2c 100644
--- a/consult.el
+++ b/consult.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Daniel Mendler <m...@daniel-mendler.de>
 ;; Created: 2020
 ;; Version: 1.8
-;; Package-Requires: ((emacs "27.1") (compat "30"))
+;; Package-Requires: ((emacs "28.1") (compat "30"))
 ;; Homepage: https://github.com/minad/consult
 ;; Keywords: matching, files, completion
 
@@ -163,10 +163,9 @@ nil shows all `custom-available-themes'."
   "Function called after jumping to a location.
 
 Commonly used functions for this hook are `recenter' and
-`reposition-window'.  You may want to add a function which pulses
-the current line, e.g., `pulse-momentary-highlight-one-line' is
-supported on Emacs 28 and newer.  The hook called during preview
-and for the jump after selection."
+`reposition-window'.  You may want to add a function which pulses the
+current line, e.g., `pulse-momentary-highlight-one-line'.  The hook
+called during preview and for the jump after selection."
   :type 'hook)
 
 (defcustom consult-line-start-from-top nil
@@ -380,12 +379,8 @@ mode hooks, e.g., `prog-mode-hook'."
 Each element of the list must have the form (char name handlers...)."
   :type '(alist :key-type character :value-type (cons string (repeat 
function))))
 
-(defcustom consult-yank-rotate
-  (if (boundp 'yank-from-kill-ring-rotate)
-      yank-from-kill-ring-rotate
-    t)
-  "Rotate the `kill-ring' in the `consult-yank' commands."
-  :type 'boolean)
+(define-obsolete-variable-alias
+  'consult-yank-rotate 'yank-from-kill-ring-rotate "1.8")
 
 ;;;; Faces
 
@@ -648,28 +643,6 @@ Turn ARG into a list, and for each element either:
        (setq ,list (cdr ,head))
        nil)))
 
-;; Upstream bug#46326, Consult issue gh:minad/consult#193.
-(defmacro consult--minibuffer-with-setup-hook (fun &rest body)
-  "Variant of `minibuffer-with-setup-hook' using a symbol and `fset'.
-
-This macro is only needed to prevent memory leaking issues with
-the upstream `minibuffer-with-setup-hook' macro.
-FUN is the hook function and BODY opens the minibuffer."
-  (declare (indent 1) (debug t))
-  (let ((hook (gensym "hook"))
-        (append))
-    (when (eq (car-safe fun) :append)
-      (setq append '(t) fun (cadr fun)))
-    `(let ((,hook (make-symbol "consult--minibuffer-setup-hook")))
-       (fset ,hook (lambda ()
-                     (remove-hook 'minibuffer-setup-hook ,hook)
-                     (funcall ,fun)))
-       (unwind-protect
-           (progn
-             (add-hook 'minibuffer-setup-hook ,hook ,@append)
-             ,@body)
-         (remove-hook 'minibuffer-setup-hook ,hook)))))
-
 (defun consult--completion-filter (pattern cands category _highlight)
   "Filter CANDS with PATTERN.
 
@@ -726,7 +699,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 (compat-call string-width string pos 
nexti))))
+                (setq width (+ width (string-width string pos nexti))))
               (setq pos nexti))))))
     width))
 
@@ -813,7 +786,7 @@ asked for the directories or files to search via
                               ;; should instead use the completion metadata.
                               (minibuffer-completing-file-name t)
                               (ignore-case 
read-file-name-completion-ignore-case))
-                          (consult--minibuffer-with-setup-hook
+                          (minibuffer-with-setup-hook
                               (lambda ()
                                 (setq-local completion-ignore-case ignore-case)
                                 (set-syntax-table 
minibuffer-local-filename-syntax))
@@ -840,13 +813,14 @@ asked for the directories or files to search via
      (or paths '("."))
      edir)))
 
+(declare-function project-current "project")
+(declare-function project-root "project")
+
 (defun consult--default-project-function (may-prompt)
   "Return project root directory.
 When no project is found and MAY-PROMPT is non-nil ask the user."
   (when-let (proj (project-current may-prompt))
-    (cond
-     ((fboundp 'project-root) (project-root proj))
-     ((fboundp 'project-roots) (car (project-roots proj))))))
+    (project-root proj)))
 
 (defun consult--project-root (&optional may-prompt)
   "Return project root as absolute path.
@@ -1718,7 +1692,7 @@ The result can be passed as :state argument to 
`consult--read'." type)
 See `consult--with-preview' for the arguments
 PREVIEW-KEY, STATE, TRANSFORM, CANDIDATE and SAVE-INPUT."
   (let ((mb-input "") mb-narrow selected timer previewed)
-    (consult--minibuffer-with-setup-hook
+    (minibuffer-with-setup-hook
         (if (and state preview-key)
             (lambda ()
               (let ((hook (make-symbol 
"consult--preview-minibuffer-exit-hook"))
@@ -1896,6 +1870,7 @@ The default is twice the `consult-narrow-key'."
   "Narrow current completion with KEY.
 
 This command is used internally by the narrowing system of `consult--read'."
+  (declare (completion ignore))
   (interactive
    (list (unless (equal (this-single-command-keys) (consult--widen-key))
            last-command-event)))
@@ -1943,6 +1918,7 @@ This command is used internally by the narrowing system 
of `consult--read'."
 
 This command can be bound to a key in `consult-narrow-map',
 to make it available for commands with narrowing."
+  (declare (completion ignore))
   (interactive)
   (consult--require-minibuffer)
   (let ((minibuffer-message-timeout 1000000))
@@ -1972,10 +1948,6 @@ to make it available for commands with narrowing."
   (when-let ((init (and (memq :keys settings) (plist-get settings :initial))))
     (consult-narrow init)))
 
-;; Emacs 28: hide in M-X
-(put #'consult-narrow-help 'completion-predicate #'ignore)
-(put #'consult-narrow 'completion-predicate #'ignore)
-
 ;;;; Splitting completion style
 
 (defun consult--split-perl (str &optional _plist)
@@ -2064,7 +2036,7 @@ BIND is the asynchronous function binding."
     `(let ((,async ,@(cdr bind))
            (new-chunk (max read-process-output-max consult--process-chunk))
            orig-chunk)
-       (consult--minibuffer-with-setup-hook
+       (minibuffer-with-setup-hook
            ;; Append such that we overwrite the completion style setting of
            ;; `fido-mode'.  See `consult--async-split' and
            ;; `consult--split-setup'.
@@ -2591,7 +2563,7 @@ PREVIEW-KEY are the preview keys."
                                  keymap category initial narrow add-history 
annotate
                                  state preview-key sort lookup group 
inherit-input-method)
   "See `consult--read' for the documentation of the arguments."
-  (consult--minibuffer-with-setup-hook
+  (minibuffer-with-setup-hook
       (:append (lambda ()
                  (add-hook 'after-change-functions 
#'consult--tofu-hide-in-minibuffer nil 'local)
                  (consult--setup-keymap keymap (consult--async-p table) narrow 
preview-key)
@@ -2712,7 +2684,7 @@ input method."
 (cl-defun consult--prompt-1 (&key prompt history add-history initial default
                                   keymap state preview-key transform 
inherit-input-method)
   "See `consult--prompt' for documentation."
-  (consult--minibuffer-with-setup-hook
+  (minibuffer-with-setup-hook
       (:append (lambda ()
                  (consult--setup-keymap keymap nil nil preview-key)
                  (setq-local minibuffer-default-add-function
@@ -3557,7 +3529,7 @@ INITIAL is the initial input."
   (consult--forbid-minibuffer)
   (let ((ro buffer-read-only))
     (unwind-protect
-        (consult--minibuffer-with-setup-hook
+        (minibuffer-with-setup-hook
             (lambda ()
               (when ro
                 (minibuffer-message
@@ -3841,10 +3813,8 @@ From these files, the commands are extracted."
                            (eq (car cmd) 'defun)
                            (commandp sym)
                            (not (get sym 'byte-obsolete-info))
-                           ;; Emacs 28 has a `read-extended-command-predicate'
-                           (if (bound-and-true-p 
read-extended-command-predicate)
-                               (funcall read-extended-command-predicate sym 
buffer)
-                             t))
+                           (or (not read-extended-command-predicate)
+                               (funcall read-extended-command-predicate sym 
buffer)))
                   (let ((name (symbol-name sym)))
                     (unless (string-match-p command-filter name)
                       (push (propertize name
@@ -3897,7 +3867,7 @@ If no MODES are specified, use currently active major and 
minor modes."
   (consult--lookup-member
    (consult--read
     (consult--remove-dups
-     (or (if consult-yank-rotate
+     (or (if yank-from-kill-ring-rotate
              (append kill-ring-yank-pointer
                      (butlast kill-ring (length kill-ring-yank-pointer)))
            kill-ring)
@@ -3920,16 +3890,16 @@ If no MODES are specified, use currently active major 
and minor modes."
   "Select STRING from the kill ring and insert it.
 With prefix ARG, put point at beginning, and mark at end, like `yank' does.
 
-This command behaves like `yank-from-kill-ring' in Emacs 28, which also offers
-a `completing-read' interface to the `kill-ring'.  Additionally the Consult
-version supports preview of the selected string."
+This command behaves like `yank-from-kill-ring', which also offers a
+`completing-read' interface to the `kill-ring'.  Additionally the
+Consult version supports preview of the selected string."
   (interactive (list (consult--read-from-kill-ring) current-prefix-arg))
   (when string
     (setq yank-window-start (window-start))
     (push-mark)
     (insert-for-yank string)
     (setq this-command 'yank)
-    (when consult-yank-rotate
+    (when yank-from-kill-ring-rotate
       (if-let (pos (seq-position kill-ring string))
           (setq kill-ring-yank-pointer (nthcdr pos kill-ring))
         (kill-new string)))
@@ -3949,9 +3919,9 @@ version supports preview of the selected string."
 Otherwise select string from the kill ring and insert it.
 See `yank-pop' for the meaning of ARG.
 
-This command behaves like `yank-pop' in Emacs 28, which also offers a
-`completing-read' interface to the `kill-ring'.  Additionally the Consult
-version supports preview of the selected string."
+This command behaves like `yank-pop', which also offers a
+`completing-read' interface to the `kill-ring'.  Additionally the
+Consult version supports preview of the selected string."
   (interactive "*p")
   (if (eq last-command 'yank)
       (yank-pop (or arg 1))
@@ -3963,9 +3933,7 @@ version supports preview of the selected string."
   "Select STRING from the kill ring.
 
 If there was no recent yank, insert the string.
-Otherwise replace the just-yanked string with the selected string.
-
-There exists no equivalent of this command in Emacs 28."
+Otherwise replace the just-yanked string with the selected string."
   (interactive (list (consult--read-from-kill-ring)))
   (when string
     (if (not (eq last-command 'yank))
@@ -4152,6 +4120,7 @@ of the prompt.  See also `cape-history' from the Cape 
package."
 
 (defun consult-isearch-forward (&optional reverse)
   "Continue Isearch forward optionally in REVERSE."
+  (declare (completion ignore))
   (interactive)
   (consult--require-minibuffer)
   (setq isearch-new-forward (not reverse) isearch-new-nonincremental nil)
@@ -4159,13 +4128,10 @@ of the prompt.  See also `cape-history' from the Cape 
package."
 
 (defun consult-isearch-backward (&optional reverse)
   "Continue Isearch backward optionally in REVERSE."
+  (declare (completion ignore))
   (interactive)
   (consult-isearch-forward (not reverse)))
 
-;; Emacs 28: hide in M-X
-(put #'consult-isearch-backward 'completion-predicate #'ignore)
-(put #'consult-isearch-forward 'completion-predicate #'ignore)
-
 (defvar-keymap consult-isearch-history-map
   :doc "Additional keymap used by `consult-isearch-history'."
   "<remap> <isearch-forward>" #'consult-isearch-forward

Reply via email to