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

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

Date: Mon, 01 Feb 2021 16:13:33 +0000

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: David Edmondson


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.)

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: