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 21:09:48 +0200

To: David Edmondson, David Bremner, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


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.
>
> I'm a bit loath to just re-implement that. Am I allowed to depend on
> dash? (I'd guess not, but figured that it's worth asking.)

list-packages doesn't tell whether dash is from elpa or from melpa --
nevertheless so far notmuch hasn't even required anything from elpa,
so I'd default to 'no'.

Anyway, I'd guess this is fast enough for the vast majority of the 
specific use cases of this feature (dash is more generic(?)), and there
are worse hiccups elsewhere (although such is never an excuse to make
other code slow).

Tomi

>
> dme.
> -- 
> Why stay in college? Why go to night school?
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: