Re: [PATCH] emacs: When completing tags, offer each tag once

Subject: Re: [PATCH] emacs: When completing tags, offer each tag once

Date: Tue, 02 Feb 2021 15:23:10 -0400

To: Tomi Ollila, David Edmondson, notmuch@notmuchmail.org

Cc:

From: David Bremner


Tomi Ollila <tomi.ollila@iki.fi> writes:

> On Mon, Feb 01 2021, David Edmondson wrote:
>
>> On Monday, 2021-02-01 at 11:49:36 -04, David Bremner wrote:
>>
>>> David Edmondson <dme@dme.org> writes:
>>>>  
>>>> +(defun notmuch-search-uniq-tags (tags)
>>>> +  (let (result)
>>>> +    (mapc (lambda (tag)
>>>> +	    (unless (member tag result)
>>>> +	      (push tag result)))
>>>> +	  tags)
>>>> +    result))
>>>
>>> I leave elisp style to others...
>>
>> Me too :-)
>>
>>> Is there some bound on the length of tags? Otherwise this seems like
>>> it's potentially a bit slow?
>>
>> No, there isn't any bound. I'd be surprised to see lists longer than low
>> tens of elements.
>>
>> For similar functionality the dash library provides `-distinct', which
>> uses a lookup table if there are more than 32 elements in the list,
>> claiming that this is the break-point for the hash based approach to be
>> faster.

Maybe delete-dups (subr.el) would be useful here? It is destructive, but
even with a copy (if needed), it should still be faster.

d
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: