]> git.eshelyaron.com Git - emacs.git/commitdiff
Drop completion--adjust-metadata style property
authorEshel Yaron <me@eshelyaron.com>
Thu, 12 Dec 2024 16:00:26 +0000 (17:00 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 12 Dec 2024 16:00:26 +0000 (17:00 +0100)
lisp/minibuffer.el

index d60fb9af40ba20b30d97c6403f6ab061b507004c..5400c57804c5a5af1ad51a44633c60d13e9374f7 100644 (file)
@@ -1391,11 +1391,8 @@ in a slash."
             (or (funcall func defp)
                 (setq completions--only-exceptional-candidates
                       (funcall func pred))))
-           (t (funcall func pred))))
-         (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata)))
+           (t (funcall func pred)))))
     (setq completion--matching-style (cdr result-and-style))
-    (when (and adjust-fn metadata)
-      (setcdr metadata (cdr (funcall adjust-fn metadata))))
     (if requote
         (funcall requote (car result-and-style) n)
       (car result-and-style))))
@@ -5322,40 +5319,6 @@ that is non-nil."
   :version "27.1"
   :type 'boolean)
 
-(put 'flex 'completion--adjust-metadata 'completion--flex-adjust-metadata)
-
-(defun completion--flex-adjust-metadata (metadata)
-  "If `flex' is actually doing filtering, adjust sorting."
-  (let ((flex-is-filtering-p completion-pcm--regexp)
-        (existing-sf (completion-metadata-get metadata 'sort-function)))
-    (cl-flet
-        ((compose-flex-sort-fn (existing-sort-fn)
-           (lambda (completions)
-             (let* ((sorted (sort
-                             (mapcar
-                              (lambda (str)
-                                (cons
-                                 (- (completion--flex-score
-                                     (or (get-text-property
-                                          0 'completion--unquoted str)
-                                         str)
-                                     completion-pcm--regexp))
-                                 str))
-                              (if existing-sort-fn
-                                  (funcall existing-sort-fn completions)
-                                completions))
-                             #'car-less-than-car))
-                    (cell sorted))
-               ;; Reuse the list
-               (while cell
-                 (setcar cell (cdar cell))
-                 (pop cell))
-               sorted))))
-      `(metadata
-        ,@(and flex-is-filtering-p
-               `((sort-function . ,(compose-flex-sort-fn existing-sf))))
-        ,@(cdr metadata)))))
-
 (defun completion-flex--make-flex-pattern (pattern)
   "Convert PCM-style PATTERN into PCM-style flex pattern.