unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Protesilaos Stavrou <info@protesilaos.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: [ELPA] New consult-denote package
Date: Thu, 09 May 2024 12:38:55 +0300	[thread overview]
Message-ID: <87ttj78guo.fsf@protesilaos.com> (raw)
In-Reply-To: <87cypvz999.fsf@posteo.net>

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Thu,  9 May 2024 08:20:50 +0000

> [... 18 lines elided]

>> The FIXME there is about the following use of the temp buffer to do a
>> completion-in-region in. Basically, I was looking for a function that
>> would complete a string against the list of candidates. What I have
>> there works, of course, but feels I am missing something.
>
> Isn't that the same as
>
>   (try-completion input new-collection)
>
> or am I missing something?

The 'try-completion' does not seem to read the 'completion-styles'. It
works if the input matches the prefix of the candidate, but otherwise it
returns nil.

Trying it with this:

    (defun denote--completion-table (category candidates)
      "Pass appropriate metadata CATEGORY to completion CANDIDATES."
      (lambda (string pred action)
        (if (eq action 'metadata)
            `(metadata (category . ,category))
          (complete-with-action action candidates string pred))))

    (setq completion-styles '(basic substring)) ; I also have `orderless' in my setup

    ;; This returns nil
    (try-completion
     "magritte"
     (denote--completion-table
      'file
      '("20220220T122457--magritte-pipe__attachment_painting_philosophy.jpg"
        "20231129T125442--note-with-a-title__denote_test.txt")))

    ;; This returns the candidate
    (try-completion
     "2022"
     (denote--completion-table
      'file
      '("20220220T122457--magritte-pipe__attachment_painting_philosophy.jpg"
        "20231129T125442--note-with-a-title__denote_test.txt")))

-- 
Protesilaos Stavrou
https://protesilaos.com



  reply	other threads:[~2024-05-09  9:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 11:33 [ELPA] New consult-denote package Protesilaos Stavrou
2024-05-08 17:19 ` Philip Kaludercic
2024-05-09  4:00   ` Protesilaos Stavrou
2024-05-09  8:20     ` Philip Kaludercic
2024-05-09  9:38       ` Protesilaos Stavrou [this message]
2024-05-09 10:30         ` Visuwesh

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=87ttj78guo.fsf@protesilaos.com \
    --to=info@protesilaos.com \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /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).