From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id oCU2JxwWGGCdLQAA0tVLHw (envelope-from ) for ; Mon, 01 Feb 2021 14:54:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EEYOIxwWGGByTAAAB5/wlQ (envelope-from ) for ; Mon, 01 Feb 2021 14:54:20 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8CA6594059B for ; Mon, 1 Feb 2021 14:54:19 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DC33D28CD9; Mon, 1 Feb 2021 09:54:10 -0500 (EST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by mail.notmuchmail.org (Postfix) with ESMTPS id 31C4128CAD for ; Mon, 1 Feb 2021 09:54:08 -0500 (EST) Received: by mail-ej1-x633.google.com with SMTP id bl23so24789938ejb.5 for ; Mon, 01 Feb 2021 06:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d6di6OcrF/LB5j9dKuI05cgh3jKZa7U0fCOmmxwhZTA=; b=VOjysadPuLb1UNvvfgw3L3wdYYpcRrna2P2jBEWoEbHR2r4KSd9DCQ88WmJc0BbfEv 3RUgYI08eTrbZ2Ap1UMPAlMuqrQT4KSjlhnItaaHgW/Xl5Ziq1JAZEGhEs1W/AGIute6 9bngdScK0C9djcetmx6oy/JYTrJ9cKlaJp3PDfMlKgX1M6jd6OD1ghEsxevT5dyb8Sct /m9pw1dCdeJX1T3OEQkraM1+p2OAiKogMicT8XYLbRpmMk0Jud/2YD/ZQOiVU2CD/n1l lZbI0pS+2AbcTj0oMjrYg23LiOIuMmDydFXlqwdyItmA8jRDs79uzPCSyd2XY5mjf3tk dZ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d6di6OcrF/LB5j9dKuI05cgh3jKZa7U0fCOmmxwhZTA=; b=bnBJ6M1rmcbcYUGjTvvhb89/E9u5NjcNC/wfMl01BQN+ZccWiZdSfsjb+iN4jiiZ+J BOHkNLJd3ZUiBDFYgL0fy3VeLZ0J04UkV/u7Z7wxphEGaU86N8H30eTCTZBUtXTCdgbU Duy4nPoBp7UfO12eIGcezv1dG/NSbhYvn8WmXsrbr+IcyvC3AQr6aVZpZSU2uOLtCNJx ikk66xbueOJ2gcyTgks56dg4OlZzS+1S8hncnyaUgTU2aKG62nLQb4yZ02KXmai44vi+ rly3nUUDYRZR4d76F3l4NyLaKeADF+TnT9sBw/aZcJ9dVmMgdrebuz8BQMKLdEI/FZGP McmA== X-Gm-Message-State: AOAM532YUBbIcyR3EsVVvfdc669Nh4+4S3GGmUTHop+DiXkGvZV43M0H 5QUtPcMEejIpBfDsY8um0D0aUWsu1VZgmzb/ X-Google-Smtp-Source: ABdhPJyuacfqqEn4FHhzLu3J4XHROlZoW6Hbh/2BzVvVa3axJmQTRdGUF1XH5DTaDAtvm7eJqSkxBg== X-Received: by 2002:a17:906:1741:: with SMTP id d1mr18418799eje.182.1612191244063; Mon, 01 Feb 2021 06:54:04 -0800 (PST) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [2001:8b0:bb71:7140:64::1]) by smtp.gmail.com with ESMTPSA id o11sm8754433eds.19.2021.02.01.06.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 06:54:03 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 144b3adf; Mon, 1 Feb 2021 14:54:02 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: When completing tags, offer each tag once Date: Mon, 1 Feb 2021 14:54:02 +0000 Message-Id: <20210201145402.561245-1-dme@dme.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Message-ID-Hash: Y6CHEOOIPBT2JNWKOFWO2YYHYBYELJ3H X-Message-ID-Hash: Y6CHEOOIPBT2JNWKOFWO2YYHYBYELJ3H X-MailFrom: dme@dme.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 CC: David Edmondson X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.01 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=dme-org.20150623.gappssmtp.com header.s=20150623 header.b=VOjysadP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 8CA6594059B X-Spam-Score: -0.01 X-Migadu-Scanner: scn0.migadu.com X-TUID: qAYJ0rWmWwbv When prompting for one or more tags to add or remove to/from one or more threads, ensure that the set of tags offered for completion contains no duplicates. Some completion packages (e.g. selectrum) will include every member of the offered list, resulting in the same tag being indicated as a possibility several times. --- emacs/notmuch.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 26efcccd..ceec5b5d 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -572,12 +572,20 @@ thread." (defun notmuch-search-get-tags (&optional pos) (plist-get (notmuch-search-get-result pos) :tags)) +(defun notmuch-search-uniq-tags (tags) + (let (result) + (mapc (lambda (tag) + (unless (member tag result) + (push tag result))) + tags) + result)) + (defun notmuch-search-get-tags-region (beg end) (let (output) (notmuch-search-foreach-result beg end (lambda (pos) (setq output (append output (notmuch-search-get-tags pos))))) - output)) + (notmuch-search-uniq-tags output))) (defun notmuch-search-interactive-tag-changes (&optional initial-input) "Prompt for tag changes for the current thread or region. -- 2.29.2