[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] New consult-denote package
From: |
Protesilaos Stavrou |
Subject: |
Re: [ELPA] New consult-denote package |
Date: |
Thu, 09 May 2024 12:38:55 +0300 |
> 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