diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-03-06 18:21:55 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-03-06 18:21:55 +0100 |
| commit | c833f2edcb68466bef53a6ea104371a26d6bc0c8 (patch) | |
| tree | b76475aa20ea2e908f7c8f32d33751b988c95ead | |
| parent | bdae1151e87cb877abf4bdf81ec8dd441187a5f8 (diff) | |
compat-31: New function completion-table-with-metadata
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-31.el | 11 | ||||
| -rw-r--r-- | compat-tests.el | 7 |
3 files changed, 19 insertions, 0 deletions
@@ -8,6 +8,7 @@ - compat-31: New functions =minusp= and =plusp=. - compat-31: New macros =incf= and =decf=. - compat-31: New function =color-blend=. +- compat-31: New function =completion-table-with-metadata=. - Drop support for Emacs 24.x. Emacs 25.1 is required now. In case Emacs 24.x support is still needed, Compat 30 can be used. diff --git a/compat-31.el b/compat-31.el index 84ff7bf..59ea412 100644 --- a/compat-31.el +++ b/compat-31.el @@ -83,5 +83,16 @@ For instance: (push (+ (* (nth i a) alpha) (* (nth i b) (- 1 alpha))) blend)) (nreverse blend))) +;;;; Defined in minibuffer.el + +(compat-defun completion-table-with-metadata (table metadata) ;; <compat-tests:completion-table-with-metadata> + "Return new completion TABLE with METADATA. +METADATA should be an alist of completion metadata. See +`completion-metadata' for a list of supported metadata." + (lambda (string pred action) + (if (eq action 'metadata) + `(metadata . ,metadata) + (complete-with-action action table string pred)))) + (provide 'compat-31) ;;; compat-31.el ends here diff --git a/compat-tests.el b/compat-tests.el index fedbda2..5b12baf 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -3055,6 +3055,13 @@ (let ((completion-category-overrides '((compat-test (a . 10))))) (should-equal 10 (compat-call completion-metadata-get md 'a)))))) +(ert-deftest compat-completion-table-with-metadata () + (let* ((md '((category . text))) + (table (completion-table-with-metadata '("word") md)) + (md2 (completion-metadata "" table nil))) + (should-equal (car md2) 'metadata) + (should (eq (cdr md2) md)))) + (ert-deftest compat-untrusted-content () (should (local-variable-if-set-p 'untrusted-content))) |
