[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 7fc0292: Allow completion styles to adjust completion metadat
From: |
Stefan Monnier |
Subject: |
Re: master 7fc0292: Allow completion styles to adjust completion metadata |
Date: |
Sat, 26 Oct 2019 12:12:50 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> +(cl-defgeneric completion-adjust-metadata-for-style (style metadata)
> + "Adjust METADATA of current completion according to STYLE."
> + (:method (_style _metadata) nil) ; nop by default
Hmm... if "nop" is to return nil, it means it works by side-effect, but
if the metadata is `nil` to start with, there's no side-effect that can
turn it into a non-nil value, right?
So I think it should work by returning a new metadata and hence "nop"
should be to return `metadata` unmodified.
> + (let ((alist (cdr metadata)))
> + (setf (alist-get 'display-sort-function alist)
> + (compose-flex-sort-fn (alist-get 'display-sort-function alist)))
> + (setf (alist-get 'cycle-sort-function alist)
> + (compose-flex-sort-fn (alist-get 'cycle-sort-function alist)))
This works by side-effecting the alist, but those entries may (and
usually) come from immediate constants in the code, so this is
like "self-modifying code" :-(
> + metadata))))
I see here you do return the metadata, good.
> + (result-and-style
> + (completion--some
> + (lambda (style)
> + (let ((probe (funcall (nth n (assq style
> + completion-styles-alist))
> + string table pred point)))
> + (and probe (cons probe style))))
> + (completion--styles metadata))))
> + (completion-adjust-metadata-for-style (cdr result-and-style) metadata)
> (if requote
But here it appears you're not using the return value, unless I'm
missing something.
Stefan
- Re: master 7fc0292: Allow completion styles to adjust completion metadata,
Stefan Monnier <=