From: "João Távora" <joaotavora@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: master 7fc0292: Allow completion styles to adjust completion metadata
Date: Sat, 26 Oct 2019 17:59:20 +0100 [thread overview]
Message-ID: <CALDnm52Mvg0epK9ufkoZ4ELcZaFq600k2HkxQhz-jWFmvuuTwA@mail.gmail.com> (raw)
In-Reply-To: <jwva79ncwwa.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]
You're right, this version didn't work for many reasons. Once we get
cl-defgeneric to work, we can fix it to work by return value, as you
suggest...
João
On Sat, Oct 26, 2019, 17:12 Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > +(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
>
>
[-- Attachment #2: Type: text/html, Size: 2616 bytes --]
prev parent reply other threads:[~2019-10-26 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191026121258.26047.33907@vcs0.savannah.gnu.org>
[not found] ` <20191026121259.B54E720664@vcs0.savannah.gnu.org>
2019-10-26 16:12 ` master 7fc0292: Allow completion styles to adjust completion metadata Stefan Monnier
2019-10-26 16:59 ` João Távora [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALDnm52Mvg0epK9ufkoZ4ELcZaFq600k2HkxQhz-jWFmvuuTwA@mail.gmail.com \
--to=joaotavora@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).