From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sPpuBGng/V+1OwAA0tVLHw (envelope-from ) for ; Tue, 12 Jan 2021 17:46:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id oEg1AGng/V8IcQAAbx9fmQ (envelope-from ) for ; Tue, 12 Jan 2021 17:46:17 +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 658EE940309 for ; Tue, 12 Jan 2021 17:46:16 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id E893129EEA; Tue, 12 Jan 2021 12:46:03 -0500 (EST) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by mail.notmuchmail.org (Postfix) with ESMTPS id 679CB29DCB for ; Tue, 12 Jan 2021 12:46:01 -0500 (EST) Received: by mail-wm1-x32c.google.com with SMTP id k10so2668435wmi.3 for ; Tue, 12 Jan 2021 09:46:01 -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=MkZD1T7V+xLaPblcuodlRaoDFZ/8mlTLwDKMGZ/yDIY=; b=hoAqBywxQKm1FvWSr+oCP8oc4U1aG4EU09e5Lm5rIv010dYrFMZjdgAsHVL2Sj+Jzr ukFTak6eRdYdEjV6gWOH8ljviyhj0WlWXhuUToHxBrclolv1OFRhYF2ppyrpUT/dNgMC hpAO4e8rCXXXLQ+/pHc04cnJKeARaAlo0wzDJpa5D5VGRX4bKQHFrPxyRs+i3A1di+Ao gOivRK0Xhp0rHQ8n5aLDvW82yz1+LURTcoTxZL/PaSgZSMwAkTOdqLcWYogH7xIVL5sm gW+yEWhJPi2jDBTXQYRDsgZcWNFQqJGPBcv+nPiRgads+0Cv4lP/3HnGf8tCmrS//HY4 PdHg== 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=MkZD1T7V+xLaPblcuodlRaoDFZ/8mlTLwDKMGZ/yDIY=; b=N6wXrt1QZ1h2sm397QM9kKYpqcbG/iyEmwQJCdn0LPcjcE0OdDJOkRN49uRXkk9Oo5 P466kdcKP0KJKYtZte2uDyoIeRXD2ZUA3NifHLkuiTcqZ85Zkx/M9WRFxOGIw/Bjxt+f ttw743ZFsWmgo6nfRvThzVnq1tJRaUQK/ViUyT6fNCZGB3QgC3Tew6rgiuE1PbgkvEaw LWcV3Z8+EswpJidmnXgW2axlHfX/bTdF1IztVX1a8336dHqTMHhIcW3KeIJHVr7EXRs2 3SC5L8B+vaVs4+TlT0cDmaxvCOPCwf4x6GGOTJNF3Jz5uW+7+TTW8sSA1u09Om/qZLe1 cDrQ== X-Gm-Message-State: AOAM5311iWdRPuAsKToy2ycg7BTzy9HqnJrVbiaNK3uDbv86LkARHdDh K+63S8b952ztqAfixJPJmFCgV1zQtRnUZtd9 X-Google-Smtp-Source: ABdhPJzFfs1b+Uyn8UYL/om0ZeBAQuzr9m5B5UQQlSAViJV+w4NoKZJ5WKLCHWq8+lBWf/XpOQHfWw== X-Received: by 2002:a7b:cb93:: with SMTP id m19mr382797wmi.45.1610473559849; Tue, 12 Jan 2021 09:45:59 -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 h5sm6336930wrp.56.2021.01.12.09.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 09:45:59 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 623d9aaa; Tue, 12 Jan 2021 17:45:58 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v2 1/3] emacs: Use pcase in notmuch-search-insert-field Date: Tue, 12 Jan 2021 17:45:55 +0000 Message-Id: <20210112174557.2229802-2-dme@dme.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112174557.2229802-1-dme@dme.org> References: <20210112174557.2229802-1-dme@dme.org> MIME-Version: 1.0 Message-ID-Hash: D7PLKE4RN3H7T3EEV4NA74LQONMJGLHG X-Message-ID-Hash: D7PLKE4RN3H7T3EEV4NA74LQONMJGLHG 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.08 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=dme-org.20150623.gappssmtp.com header.s=20150623 header.b=hoAqBywx; 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: 658EE940309 X-Spam-Score: -0.08 X-Migadu-Scanner: scn1.migadu.com X-TUID: K/TUuRtJpGaM Rather than lots of string-equal calls, use the pcase macro. --- emacs/notmuch.el | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 83bcee57..efbf5bd0 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -65,7 +65,9 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(eval-when-compile + (require 'cl-lib) + (require 'pcase)) (require 'mm-view) (require 'message) @@ -822,26 +824,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.29.2