From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 3RdfNe4ZJ2PAAgEAbAwnHQ (envelope-from ) for ; Sun, 18 Sep 2022 15:15:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0GtYNO4ZJ2PmCgEA9RJhRA (envelope-from ) for ; Sun, 18 Sep 2022 15:15:26 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (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 9724411909 for ; Sun, 18 Sep 2022 15:15:26 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id EB2CD5E012; Sun, 18 Sep 2022 13:15:23 +0000 (UTC) X-Greylist: delayed 562 seconds by postgrey-1.36 at yantan; Sun, 18 Sep 2022 13:15:20 UTC Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 54F355DC06 for ; Sun, 18 Sep 2022 13:15:20 +0000 (UTC) Received: from c53.nor.fi (unknown [IPv6:2a0b:a700:bb::53]) (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) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 9BDDF1B001B4; Sun, 18 Sep 2022 16:05:57 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1663506357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pTqNWP+sCg4SHYtMSFS3q4hSGUPUb3toy54lAPtd7eg=; b=Me0SUtumOHm0xcpvHv8txgHmsArlBQbiF7wWE7GnAK17phinLindt526XgmM1D++hXaE7A OWPJdEXsET5C85eBK6ibWwOKe2gSY3d2ZslRB57XWIOgGs+pwZH9C0bGuD6hJqyP/bLc5I 59zpq791KfTCDlyREC01kPdTdp6jxLr/O2CvIQoJudwb9qW2IVj4wpNFn5Q2TiTxL9/kFY 8XWQJjViq19bSlc/cRofYKeXrJpf3fcM+8DswY8oDFbEAfavdDwBWFodti3/tSnMkctkkt S/za8hGenJQE8Zx+yfuBNVUh/D7679a15BhQ9xAZnqhnjPWu85h6I2cZv09MIw== From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH] emacs: add notmuch-search-edit-search and notmuch-tree-edit-search Date: Sun, 18 Sep 2022 16:05:50 +0300 Message-Id: <20220918130550.213777-1-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1663506357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pTqNWP+sCg4SHYtMSFS3q4hSGUPUb3toy54lAPtd7eg=; b=q3siHReQtl2iwsiw+uoVZsO1f1h7fadX7wEa8ypvaE0fnoKuyGZ9vzfQn56SSPgM7GE7zW Xq3ndxfCv3GiD4KridBL0Ar2PP+r7Vflauus6sFKvd4CmVFMXg3jyifSQtqjsGjc6G44KZ pCwzQB3qvfAbTC79V32Qzb0U2kzoHI8zKkQNIGs6tgfV3T4hhC0Qib6OP1A8liQ1ihGJtu iUaDgbZEYIqFrBik8GZSQKVLBKyJ2GVNoCkUNUcMfTQvbBuM5pF4+ShKKsHr0wZkZFau7a 5Denx9IjGEcJZFWNda+8BPJ63itKvZdkj4Ird+MOTFzjDJ8A5Dztcs6DWM+7xA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1663506357; a=rsa-sha256; cv=none; b=kcqrylOvrgE8OI7BMsK0PmoXRX71VvpuK4KUq7s1LfYWc0o47B1RVRS3bFoIKvi6jUilQZ DQIhFBM7P2VwI6vKaNI4LPTVSC68gibCeM43VUDAFiR6fOOkhgSvHqLuDOhok3fHuT5Xhj 2IWYSgIjIf8j4QQvZtJ1ywmk2aA20QBNRyMIuZUCGq3rtH7tJhyCuXSaGsQ84zPm7bUrAc H06MjHH70wbMHuCS0uWxQATnv96V7045Hkcu5UDpXbq9D9IMKM5qeX4c17ZLvcUrsQ4klX iGarHklkqbC0vNGlLjryHMVRJiC2GkcuVVCnkzE6YgZSufz1AZtHjazXERkBqQ== Message-ID-Hash: JTPDKXSJVDIA4FQWHX4ZPIUB2IJXVKSA X-Message-ID-Hash: JTPDKXSJVDIA4FQWHX4ZPIUB2IJXVKSA X-MailFrom: tomi.ollila@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: tomi.ollila@iki.fi X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663506926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=+itYJSXZ4D9Qsz7qUt1F0iamZs1kriQVRMZluPYClPg=; b=e5ceVvJps7Z1EqnXdzR8Dmrm0aiJFOiuy8J9sBgHgpIW0VvVz/GzMTdyQRZxGWATH1tqzm LOycA2zqG3eIBbM1XHYdLnFtX9aEpsXMVGJu6L640Q9CBDUGz2oRG5oDuYfGqa+QJrFtcw P39B+3Pq/UimITBjl7zGEudotKXq30x2MwUXl/jrQPLEglHjnYfge8y5W94qPbWMlVfu0V aerh51qwsqhhefRizBoSzcmAvJPr3Wkbo15yC/3kSOPbTGdAzsDJRCSMlSLOYnkVi35WJI QEhcIqelKLWbstAvdvSi5qaT+R5c5usjNxm1qDccu4I1TK/4UJMlb94nRVYEzw== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1663506926; a=rsa-sha256; cv=fail; b=hkx1PxVJ4f3Wb2QK1iVOBOMxkqs6oTn3dhkhQwMtbH8v1sOA4DN8ydVR8eeydqbP8gMjnh 32NaVo5Jn67i2aeGnjB/ACLrNlQHElntk49U5Kqb0mdSGSQncnZnYVUvixvk8DfJhUEWq0 ZF1OJtv+jS/+vM/4ZttJK/1ukDIuR32FoS68oeZCK9XgxdOVJvWzxZ6MiulnnYZd6oUobm wpuI/vYfQ4lwCU3EuF4Rcwkyakw96gTlN5H4N16VPfxN2uGzGma/WtVpWoGM4faz5EIcHd cCjDziPr1cbojhZn8WG3lYD/fDSgjCCAcaW0I2qhetybt3cfXqusNcJ/sl/Z3w== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=Me0SUtum; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 3.80 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=Me0SUtum; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 9724411909 X-Spam-Score: 3.80 X-Migadu-Scanner: scn1.migadu.com X-TUID: LGNRJ3ZaONzX ...and bind these to "E" in their respective keymaps. Expected to be called interactively, then using read-from-minibuffer with current search string as initial contents for editing. (Noninteractive use makes little sense, but is supported.) With this one can expand (as an opposite to limit) their query and have e.g. (some of their) saved searches as search "templates". While at it, removed `(defvar notmuch-search-query-string)` from notmuch-tree.el; it is unused (`notmuch-tree-basic-query` is used instead). Thanks to Jose Antonio Ortega Ruiz for his example for notmuch-tree code, and better interactive use. --- emacs/notmuch-tree.el | 19 ++++++++++++++++--- emacs/notmuch.el | 7 +++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 7ceddee2..b3c2c992 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -45,9 +45,6 @@ (declare-function notmuch-search-previous-thread "notmuch" ()) (declare-function notmuch-tree-from-search-thread "notmuch" ()) -;; the following variable is defined in notmuch.el -(defvar notmuch-search-query-string) - ;; this variable distinguishes the unthreaded display from the normal tree display (defvar-local notmuch-tree-unthreaded nil "A buffer local copy of argument unthreaded to the function notmuch-tree.") @@ -399,6 +396,7 @@ (defvar notmuch-tree-mode-map (define-key map "V" 'notmuch-tree-view-raw-message) (define-key map "l" 'notmuch-tree-filter) (define-key map "t" 'notmuch-tree-filter-by-tag) + (define-key map "E" 'notmuch-tree-edit-search) ;; The main tree view bindings (define-key map (kbd "RET") 'notmuch-tree-show-message) @@ -1265,6 +1263,21 @@ (defun notmuch-tree-filter-by-tag (tag) nil notmuch-search-oldest-first))) +(defun notmuch-tree-edit-search (query) + "Edit the current search" + (interactive (list (read-from-minibuffer "Edit search: " + notmuch-tree-basic-query))) + (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto))) + (notmuch-tree-close-message-window) + (notmuch-tree query + notmuch-tree-query-context + nil + nil + nil + notmuch-tree-unthreaded + nil + notmuch-search-oldest-first))) + ;;; _ (provide 'notmuch-tree) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 5cb7acd2..26181758 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -190,6 +190,7 @@ (defvar notmuch-search-mode-map (define-key map "c" 'notmuch-search-stash-map) (define-key map "t" 'notmuch-search-filter-by-tag) (define-key map "l" 'notmuch-search-filter) + (define-key map "E" 'notmuch-search-edit-search) (define-key map [mouse-1] 'notmuch-search-show-thread) (define-key map "k" 'notmuch-tag-jump) (define-key map "*" 'notmuch-search-tag-all) @@ -1156,6 +1157,12 @@ (defun notmuch-search-by-tag (tag) (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) (notmuch-search (concat "tag:" tag))) +(defun notmuch-search-edit-search (query) + "Edit the current search" + (interactive (list (read-from-minibuffer "Edit search: " + notmuch-search-query-string))) + (notmuch-search query notmuch-search-oldest-first)) + ;;;###autoload (defun notmuch () "Run notmuch and display saved searches, known tags, etc." -- 2.34.1