From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MDJzBwp6MmDEUAAA0tVLHw (envelope-from ) for ; Sun, 21 Feb 2021 15:19:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GL02Awp6MmBXJQAAB5/wlQ (envelope-from ) for ; Sun, 21 Feb 2021 15:19:38 +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 81A9A15A4C for ; Sun, 21 Feb 2021 16:19:37 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8715A26C54; Sun, 21 Feb 2021 10:19:18 -0500 (EST) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1FBA326AD5 for ; Sun, 21 Feb 2021 10:19:09 -0500 (EST) Received: by mail-wr1-x42a.google.com with SMTP id h98so11611277wrh.11 for ; Sun, 21 Feb 2021 07:19:09 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=otIpn0g9eEru8NLOGqeuyBtcOQ2n0beq3fOR5w7B1u8=; b=OmBAJJCDEMRvCd+wyDrEd8aOffS9zyi6o6t1D/g0oeAmgej6OMLNrHA+c0uo0Uzm7F SuQDtikVl8co1aZoyvtQkyxOs8QlsJ7dKdcLyY6NXj7ZE5pNhIZgAOJLcvZL6XXF5Aqp fs9eRa5xv/SS4vve1SOTshWHZdcUqQ0qtCusTb8Es5ob+qnAgBOUcSGVVIufCN9tJ2bx JKRBEO4famK1xnQdL7VYyQrNzhp0oqR6CcsEGj29hkov0Hv8l6ty0ykRBlBAe1Zsq2xe EUco0i4HGeCarxziyzijnwwFfMAG6wv3OO61JFofDsHVXVuSMTDhSaQIXRlrC2vMnIQR ItFw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=otIpn0g9eEru8NLOGqeuyBtcOQ2n0beq3fOR5w7B1u8=; b=inoPA1VMkkr7IL5Iyp47gtnJUWTeMVqVR6c9PG5cwLrUtNDMTNKdl76g/EZVj65lUy R2tVatdeNKDW4Ey6S8eb04AnnYI+jazBl+/KcKF/psQmOWPgZJyIaLyd/UIhMcJRAfz9 T3XppOucmfPkHyxdHg2vZHzEeDrH6hgHpRlvC+9WkGA3yTHdJ+liNyPBQzlHUfqnZBTG b2p4hxg/htrEEWWtGo8AD3Frg+Bff8VGroRWDsrVaFH9RHZSaxfS7phJLUcdWaW3066k mwJ4Pa7nCgbsPtSugawJX5mmO2VtsGi914lPI4bjbOHor1K8vXw2ql853B888G/rFGH1 4Hkg== X-Gm-Message-State: AOAM530dike5J0uuRi3MhHAClZG2228R2TFGiiIaMLMbClESnMFhC1bx mD1AAexdEHLZg7e5hFyQTiRK4E3QuQld8rep X-Google-Smtp-Source: ABdhPJyAxcWFgnhA/uTm2MKhphGrcQc53Dba/LUvnvxcdC4zg0ESb52EVpbcPWEUQZI4+PQ+czfw5Q== X-Received: by 2002:a5d:518a:: with SMTP id k10mr17756763wrv.214.1613920744326; Sun, 21 Feb 2021 07:19: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 c62sm23204974wme.16.2021.02.21.07.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 07:19:04 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id e0b18a89; Sun, 21 Feb 2021 15:19:02 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v3 1/3] emacs: Use pcase in notmuch-search-insert-field Date: Sun, 21 Feb 2021 15:19:00 +0000 Message-Id: <20210221151902.2301690-2-dme@dme.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221151902.2301690-1-dme@dme.org> References: <20210221151902.2301690-1-dme@dme.org> MIME-Version: 1.0 Message-ID-Hash: GM3KL6WXZSYXLLKISW3YYFRMCCYLZKMZ X-Message-ID-Hash: GM3KL6WXZSYXLLKISW3YYFRMCCYLZKMZ 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: 1.50 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=dme-org.20150623.gappssmtp.com header.s=20150623 header.b=OmBAJJCD; 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: 81A9A15A4C X-Spam-Score: 1.50 X-Migadu-Scanner: scn1.migadu.com X-TUID: ptp2D6rNRk5X Rather than lots of string-equal calls, use the pcase macro. --- emacs/notmuch.el | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 6d37c623..b9cee19c 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -830,26 +830,26 @@ non-authors is found, assume that all of the authors match." (insert padding)))) (defun notmuch-search-insert-field (field format-string result) - (cond - ((string-equal field "date") - (insert (propertize (format format-string (plist-get result :date_relative)) - 'face 'notmuch-search-date))) - ((string-equal field "count") - (insert (propertize (format format-string - (format "[%s/%s]" (plist-get result :matched) - (plist-get result :total))) - 'face 'notmuch-search-count))) - ((string-equal field "subject") - (insert (propertize (format format-string - (notmuch-sanitize (plist-get result :subject))) - 'face 'notmuch-search-subject))) - ((string-equal field "authors") - (notmuch-search-insert-authors - format-string (notmuch-sanitize (plist-get result :authors)))) - ((string-equal field "tags") - (let ((tags (plist-get result :tags)) - (orig-tags (plist-get result :orig-tags))) - (insert (format format-string (notmuch-tag-format-tags tags orig-tags))))))) + (pcase field + ("date" + (insert (propertize (format format-string (plist-get result :date_relative)) + 'face 'notmuch-search-date))) + ("count" + (insert (propertize (format format-string + (format "[%s/%s]" (plist-get result :matched) + (plist-get result :total))) + 'face 'notmuch-search-count))) + ("subject" + (insert (propertize (format format-string + (notmuch-sanitize (plist-get result :subject))) + 'face 'notmuch-search-subject))) + ("authors" + (notmuch-search-insert-authors format-string + (notmuch-sanitize (plist-get result :authors)))) + ("tags" + (let ((tags (plist-get result :tags)) + (orig-tags (plist-get result :orig-tags))) + (insert (format format-string (notmuch-tag-format-tags tags orig-tags))))))) (defun notmuch-search-show-result (result pos) "Insert RESULT at POS." -- 2.30.0