diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-12-07 19:56:42 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-12-07 21:31:08 +0100 |
| commit | 00d95e8c955240acc9e3beb9b0dad9f413319e2d (patch) | |
| tree | b193f01639decd1090a62c0feca03647fe0cbe65 | |
| parent | 7d264fc0d5ad71dcd0750178e27f85a17d497f54 (diff) | |
Make sure that all duplicates are deletedpreserve-text-properties
| -rw-r--r-- | corfu.el | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -579,17 +579,26 @@ FRAME is the existing frame." (defun corfu--delete-dups (list) "Delete `equal-including-properties' consecutive duplicates from LIST." - (let ((link list)) - (while (cdr link) - ;; bug#6581: `equal-including-properties' uses `eq' to compare properties - ;; until 29.1. Approximate by comparing `text-properties-at' position 0. - (pcase-let ((`(,a ,b . ,tail) link)) - (if (if (eval-when-compile (< emacs-major-version 29)) - (and (equal a b) (not (equal a "")) - (equal (text-properties-at 0 a) (text-properties-at 0 b))) - (equal-including-properties a b)) - (setcdr link tail) - (pop link))))) + (let ((beg list)) + (while (cdr beg) + (let ((end (cdr beg))) + (while (equal (car beg) (car end)) (pop end)) + ;; The deduplication is quadratic in the number of duplicates. We can + ;; avoid the quadratic complexity with a hash table which takes + ;; properties into account (available since Emacs 28). + (while (not (eq beg end)) + (let ((dup beg)) + (while (not (eq (cdr dup) end)) + ;; bug#6581: `equal-including-properties' uses `eq' to compare + ;; properties until 29.1. Approximate by comparing + ;; `text-properties-at' position 0. + (if (if (eval-when-compile (< emacs-major-version 29)) + (equal (text-properties-at 0 (car beg)) + (text-properties-at 0 (cadr dup))) + (equal-including-properties (car beg) (cadr dup))) + (setcdr dup (cddr dup)) + (pop dup)))) + (pop beg))))) list) (defun corfu--sort-function () |
