From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id HJ5NCvvcTmFlmgAAgWs5BA (envelope-from ) for ; Sat, 25 Sep 2021 10:25:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id yGhWBfvcTmFIHgAAbx9fmQ (envelope-from ) for ; Sat, 25 Sep 2021 08:25:31 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4DBBF1B3AB for ; Sat, 25 Sep 2021 10:25:30 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D37E226DDF; Sat, 25 Sep 2021 04:25:25 -0400 (EDT) Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by mail.notmuchmail.org (Postfix) with ESMTPS id C95DE26DD3 for ; Sat, 25 Sep 2021 04:25:22 -0400 (EDT) Received: by mail-pl1-x62c.google.com with SMTP id y5so5700714pll.3 for ; Sat, 25 Sep 2021 01:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=SnZL7J+lqCjzA6nl6+0eadW5ifWAlwlruPcQ9uut7Pk=; b=EpzdLaVfX0kZXAZfF+hUvczd35mfAvdsIbn6X4E23mY1Enw/pFefK6c+tlQGuA7fIh ugMXYAxLDSKv5dT19SzrPokLApHQYtpl70fKoY3bbxZENxJPx+eU49Uwn/exCrWjhO7D 4LBUMY+vVkqaRQAPKMeFe+CKd+cL1fH2LmRQUlAxvVDfCR0Gjsjs8Nrmh3pJPpcaQPyq jhc6Hj+86HfELz0RNM189gIug79BEQo77OJqtkODwcp89+DSz7ybNaRy5JVm6j9+BxCK gxeEV5xy/hA8JbM4ZS2KiCH8/bJd9aEerDSTdbNxBGiGpq0kZQTvklp8VZloH48SJPY1 qeVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=SnZL7J+lqCjzA6nl6+0eadW5ifWAlwlruPcQ9uut7Pk=; b=AHwQjxdcCeFmQ6F9CqQTuxmKdBjEt6m8XxFooRTzLmSgsgCVeQNN29eG4bIT8jJt/Q LUXYl0qm2MHM/dC7FlXgN0R7xcVFt+TZ6Bi197FgAxC0mLIQ9F6QWrL8foCEZ2bqezv5 mWFR3v9wVFy4jp8gsq073p27vAHaFk+w/YMrFF8AcPVIZTT8Fr9Qh3CZEJgTjbNypxTp CmOwKHEMdwoQUBdjViFoz4jBibEEr4lQ2ucpKPE3qMUskexOo/cBWh/CdVlZsHiY0XfC 9Rtu47jma5by5FW+/glNuZ471xMAGsNXMQmgItA5d8aRPycMgD3fwzuwlHF/ncCxXl74 DI4g== X-Gm-Message-State: AOAM530rPYhHON+6Cbz85RymkSmyPUKqBxzBxMKejuooDLBBJn4dbZss Q7LGGpSJOsvqtygFjWYO2u6rDOaQzTo= X-Google-Smtp-Source: ABdhPJy3lcSnnPyPPMQvGHGECWxTlmZ0uPpLE68TM4ykr0+jhIC0Eo/Vlzy4jWzD8id9H/+luqYELQ== X-Received: by 2002:a17:90a:4d4e:: with SMTP id l14mr7250227pjh.4.1632558321516; Sat, 25 Sep 2021 01:25:21 -0700 (PDT) Received: from localhost (c-24-56-227-241.customer.broadstripe.net. [24.56.227.241]) by smtp.gmail.com with ESMTPSA id z124sm1316845pfb.108.2021.09.25.01.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 01:25:20 -0700 (PDT) From: Natnael Kahssay To: David Bremner , notmuch@notmuchmail.org Subject: Re: [bug] notmuch-read-tag-changes, incompatability with consult, non-standard usage of completing-read-multiple In-Reply-To: <87h7efuv6i.fsf@tethera.net> References: <86a6k7hd43.fsf@gmail.com> <87h7efuv6i.fsf@tethera.net> Date: Sat, 25 Sep 2021 01:25:13 -0700 Message-ID: <864ka9oydy.fsf@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 5SYB26KYJMWRL5RQUZQR5UYMTDBWZNDD X-Message-ID-Hash: 5SYB26KYJMWRL5RQUZQR5UYMTDBWZNDD X-MailFrom: thisnkk@gmail.com 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 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: multipart/mixed; boundary="===============6376981358996438299==" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632558330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=7V0oRmyG9/qe1j/4RFD7hiDeUIAnyWqokI+xWqnEScA=; b=ROJnlii4hmPpR3T/ooVYSPhvn8y1vCBRMZo3avLpj9zLLBPdLMSa2/7cV2HiRlMxvATKoo o2bPD83SK4JFFUbiDBoXP8+1SYqv3RfIyXqIrlln2lgN+4+g2feDzYXCHmnSevAjfFa9t5 rPNl3JtxFUY7shJwg9ZVkea7Cyk0IvcTGQyWc0DqWR0RMJ8p+ZkPduWoAX6/XLxDnedvH1 ol5lnVXPeW094jqOzasAg4MkkLL20LN+D55Zv2QcgE6BUsvXHTewwx6xwncDTHjAC6NFiZ HhlOiiVqayKGcg0UC0KvMMw3oiSBRIFef+3VTlLMKJIEYPALRE3lU8d9BYLR0g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632558330; a=rsa-sha256; cv=none; b=U2jm7W5oqDrTnPfqTlFk7YApkawDSLeaOefzSxZ63cjexLSO6rJNrBy+63jmGfQvlHJfiV 5Gy3+Y+x8wT2/ja+z6QRvIvz+rfo5N5RgkLcooQELr6vuqHieN4khkB1RDnBQI/QznKtXm WMs8bjgsN9mxYPeN2RBW1ee74UHE60a4vbGW9zTeU96qJJGSTxf3oD6qIIvdlViJCz+Xla Zy6uweG+0WYxVjw1x7XtJS6OVitnjZEdafAlI7SbTbGhB/8bQ6dK1dpVWCOmYK/ibFXh0c KH3ZlA/xc0H4oKZV+XyM36OIpnmY51gaRaxIKwVeB7dF5NcvMdEA6LxI6qK7OQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=EpzdLaVf; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Spam-Score: -3.22 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=EpzdLaVf; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: 4DBBF1B3AB X-Spam-Score: -3.22 X-Migadu-Scanner: scn0.migadu.com X-TUID: gkIYE2nCcdPo --===============6376981358996438299== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable David Bremner writes: > This seems related to the discussion starting at > > https://nmbug.notmuchmail.org/nmweb/show/87im0w6u5r.fsf%40m4x.org > > See in particular > > https://nmbug.notmuchmail.org/nmweb/show/m2pmud2xxa.fsf%40dme.org yes, it is the same problem. I don't know how to reply to https://nmbug.notmuchmail.org/nmweb/show/m2pmu= d2xxa.fsf%40dme.org so I will reply here. > What if someone has trailing spaces on their tags deliberately? From=20my experiment below, notmuch, through completing-read-multiple, alre= ady trims crm-separator out of tags both left and right side regardless. Th= erefore, =3Dstring-trim-right=3D or even =3Dstring-trim=3D can be used. It = is in package subr. Therefore notmuch wouldn't need new dependencies. #+begin_src emacs-lisp :results org (let ((crm-separator " ")) (completing-read-multiple "> " (mapcar (lambda (tag-op) (concat tag-op crm-separator)) '(" first= " "second" "third")))) #+end_src #+RESULTS: #+begin_src org (first third second first) #+end_src > This seems like an oddity of the code in `notmuch-read-tag-changes' that > appends a space to every possible completion. It would probably be a > more annoying change to some users, but I'd be more inclined to remove > that code than this change. Given what I wrote above, (mapcar #'string-trim-right res) seems like a ple= asant compromise. Users keep this convenience feature and the bug is solved= without introducing new libraries and minimal modification. #+begin_src emacs-lisp (defun notmuch-read-tag-changes (current-tags &optional prompt initial-inpu= t) "Prompt for tag changes in the minibuffer. CURRENT-TAGS is a list of tags that are present on the message or messages to be changed. These are offered as tag removal completions. CURRENT-TAGS may contain duplicates. PROMPT, if non-nil, is the query string to present in the minibuffer. It defaults to \"Tags\". INITIAL-INPUT, if non-nil, will be the initial input in the minibuffer." (let* ((all-tag-list (notmuch-tag-completions)) (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list)) (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags)) (tag-list (append add-tag-list remove-tag-list)) (prompt (concat (or prompt "Tags") " (+add -drop): ")) (crm-separator " ") ;; By default, space is bound to "complete word" function. ;; Re-bind it to insert a space instead. Note that ;; still does the completion. (crm-local-completion-map (let ((map (make-sparse-keymap))) (set-keymap-parent map crm-local-completion-map) (define-key map " " 'self-insert-command) map))) (mapcar #'string-trim-right (delete "" (completing-read-multiple prompt ;; Append the separator to each completion so when the ;; user completes a tag they can immediately begin ;; entering another. `completing-read-multiple' ;; ultimately splits the input on crm-separator, so we ;; don't need to strip this back off (we just need to ;; delete "empty" entries caused by trailing spaces). (mapcar (lambda (tag-op) (concat tag-op crm-separator)) tag= -list) nil nil initial-input 'notmuch-read-tag-changes-history))))) #+end_src --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFGBAEBCAAwFiEEO/M99lSJ/E1opP+ldO60b6d7v6wFAmFO3OkSHHRoaXNua2tA Z21haWwuY29tAAoJEHTutG+ne7+sfc4IAI/SHHLs4R9PTD4tqeiTkm4GGUOqCSOx gL2AFNWg3wzAbGnFxkgsNx1HWVAzoP5i6kIoAecbXn978sd4EvF8FutiHMwVyNvD v27W4Je+MpRCoJYnfeuAzPrDUuCz0/e0IascbPSLKX3QDYzT7EYEPXAe8KE4BY1H 5vnqHXMzyrYy+WMIwFunjcpgWadWvhiEesmp/9a4fBqJpBY5NPbpHZ2nz6td7F2P 82IV61s14iw6fS3SQuE4xw/PSvGp+WyxUBdMhrW3qukHSPHIt5N9vAugJHwbUDkN H6/s7cMsav8WW/HlZOxU17a0ZDBzowDYWBfmCDpiqS0G/rHA8MX1PVs= =rfdl -----END PGP SIGNATURE----- --=-=-=-- --===============6376981358996438299== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6376981358996438299==--