From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +LyrFzvB32HvSQAAgWs5BA (envelope-from ) for ; Thu, 13 Jan 2022 07:05:47 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id kJ1nEDvB32GgPgAAG6o9tA (envelope-from ) for ; Thu, 13 Jan 2022 07:05:47 +0100 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 B6D482E6FA for ; Thu, 13 Jan 2022 07:05:46 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DE83B5F75F; Thu, 13 Jan 2022 06:05:41 +0000 (UTC) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id C35C15F709 for ; Thu, 13 Jan 2022 06:05:38 +0000 (UTC) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id C1E991B0004B; Thu, 13 Jan 2022 08:05:36 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1642053937; 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; bh=tY5ThBo9CuXOq2lfcFWgJcZquHIHyTTbsroLHiX7lkk=; b=ScHKXoCZxl3BnOdmRs86E7TUVbdAmxFiys4FOTY6P7dhgBkJYqOk4hORIi1mPFu6esylB3 uREB0wZATYvTwWaFdXECmHMpxOHORAWvzB1HeXlOHf96PRoM0WwA4Ky8IUryq2Z38/MJJF SP0YvgIsbaZlClzr6AhQhz+Ai5bFQUZQ02ja8gWasm8676Z/Ng2K+UDcy1oSGvN6XsPZG7 CwrAY8AnRzl5/HB1Lm2aOX4zW9ipqE/pxAuWPvH9NrKQbUikNX9MMiAHrFmhf1msnIiGKW z+KUsgY3Jwo7mzoZKFkM5luBXqodXhMUEWmHo4GujbP0QbnHlLJAgt4v/Qmy+Q== From: Tomi Ollila To: jao , notmuch@notmuchmail.org Subject: Re: [PATCH v4] emacs: customizable names for search buffers In-Reply-To: <20220110181644.1457631-1-jao@gnu.org> References: <20220110181644.1457631-1-jao@gnu.org> User-Agent: Notmuch/0.33+54~gcaf4513 (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1642053937; a=rsa-sha256; cv=none; b=PB2n8P/a3LXpdpLAqVH8sjM1wnZ9wtFjzRUzZu75O2op4CMCYEhhZ3FeHij0OzMUv3PX6/ /ZlWflFwQdMKPj6WOqXPjnf0bOxXVms2TDK8DdZxTYUHMDcaUixB8Ed9P+Ode4x1es2dw1 ZxqQVzd4JgIXy+C4JAGBW5N3Jki3ZzptvkHo3Gckf0Jsj165Gew4lqYIbcRtRCqh8lHVm8 uJ4Oj9e4Pk2NT/nEol2ikm6njp/XGu+pbAMmrsND1uq+163qShBLzkMngsHoywvEqWKPQq OYlMKfbEL9SeB4jhOreNtGL6IiV5aft60qDP6jvx1JqSuEceQDpkZT26fkLLWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1642053936; 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; bh=tY5ThBo9CuXOq2lfcFWgJcZquHIHyTTbsroLHiX7lkk=; b=iDcGYPUuR7MXxuAo0jWp2hP+yrZZDakIUUF9rqj00YYqEnGEq4X+y032Mzt4Ny7UVS0s5I VPkVduXA14cBX4pdoOX5nC2EzPYJ7r/9dyjFF6IyYhGp1KfwRouAQRKquoSh+i4hbyge6T S2lsAdU+wyuDnx9JPCJC68VELphXFvAagzm77gMhGyk7oN3o61wmI63Xz4fW3mWSyq+BzA S6RnAF2uD4eSOf7Ci1UtPlIqc2RkCumOBd1I1c7Didsbw9+Iz0C+eXQK3A2nP3IV2j04WB WW/vclGnrxjyAq0Lb/rnPO+7IQO9Xj0oshHfWg0EOF2VtRQnbie+3QMlEpsCWw== Message-ID-Hash: GICNPFKSKXOJHCZ6RVECDBSK54YFZV3X X-Message-ID-Hash: GICNPFKSKXOJHCZ6RVECDBSK54YFZV3X 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 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-Country: DE ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642053946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Y9qQ10TDuHPan6g5x35nGO02D5BP6X6ZmvaUDkH4w4s=; b=nfNZvk1/ElKDp1tYHeeAWmULzUYXEjKtaKI2hzb8eRHy/DnTH4ElXUm1vTxlzd879XwqpN bQ/yXknSuNiHsQ2KJ8KIjXSgB3aaCkj/RINx/CerrDTrNmFFh61HyHVCqlo3Wchpao/XpK cGC3VogB1pt9mtYIHxwOkkL5c3/cWxYbTxc+ivaFEtPYVOGea0hHrgKfphGTJmwSHZo3b5 u3kKUQWtaa1Wm2bzQhedGEwT/GrxfYaFe/6iJLv0KJps6rJmSwMWBUYgcoCc+ZDB37Q1vR RPsd+O5ttStUxea0QJvsisJJFCio1X1HhB2z/24HDf9CMNo108USlvCjzXNh3A== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1642053946; a=rsa-sha256; cv=fail; b=b5fXqjTi1NhFWYeL3gocUx6WPTXAAhXN1unPE4oEWsvq/x2lMjIghwngO4sfs+dUvZX7RH +IZcb3AlPaXR2Df2N6XPrabIfDHc5Qqg60C1Hmw0X8MZWIpIpCAXsC5WqDAoIdwZWnV/pt kF/wmFgDwY93/MQgXXfyCbfZXwAK6Xgwdr5Grq8+dx9vQBoaZE9nrAPTFQb9t8dSfaDU7n CLDqWUZr77G3MqftRMHpb1AAvLm0ht6Bj5ORPFPohsqgZtnxKSvetSYS18hHG6R3fW23tc xPuoo6SMqkuZzdXTe7mSJAWUMp/U67u74jfz+M7IOeVDcKui5LE4GsIOdOgclg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=ScHKXoCZ; 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: -0.90 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=ScHKXoCZ; 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: B6D482E6FA X-Spam-Score: -0.90 X-Migadu-Scanner: scn0.migadu.com X-TUID: g3eKid8MEydq On Mon, Jan 10 2022, jao@gnu.org wrote: > Customizable names for buffers presenting search results, via two > custom variables (notmuch-search-buffer-name-format and > notmuch-saved-search-buffer-name-format), defaulting to values > currently used for plain searches and including too tree and > unthreaded search buffers. > > --- > > This is a much improved version of the patch in > id:20220108204121.1053932-1-jao@gnu.org, according to discussion on > that thread. > > This version fixes a doc string. > > Signed-off-by: jao > --- > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index 85a54706..afb0a115 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -915,7 +915,37 @@ See `notmuch-tag' for information on the format of TAG-CHANGES." > (notmuch-search-get-tags-region (point-min) (point-max)) "Tag all"))) > (notmuch-search-tag tag-changes (point-min) (point-max) t)) > > -(defun notmuch-search-buffer-title (query) > +(defcustom notmuch-search-buffer-name-format "*notmuch-%t-%s*" > + "Format for the name of search results buffers. > + > +In this spec, %s will be replaced by a description of the search > +query and %t by its type (search, tree or unthreaded). > + > +See also `notmuch-saved-search-buffer-name-format'" > + :type 'string > + :group 'notmuch-search) > + > +(defcustom notmuch-saved-search-buffer-name-format "*notmuch-saved-%t-%s*" > + "Format for the name of search results buffers. > + > +In this spec, %s will be replaced by the saved search name and %t > +by its type (search, tree or unthreaded). > + > +See also `notmuch-search-buffer-name-format'" > + :type 'string > + :group 'notmuch-search) > + > +(defun notmuch-search-format-buffer-name (query type saved) > + "Compose a buffer name for the given QUERY, TYPE (search, tree, > +unthreaded) and whether it's SAVED (t or nil)." > + (let ((fmt (if saved > + notmuch-saved-search-buffer-name-format > + notmuch-search-buffer-name-format))) > + (if (fboundp 'format-spec) > + (format-spec fmt `((?t . ,(or type "search")) (?s . ,query)))) > + (format (replace-regexp-in-string "\\b%t\\b" (or type "search") fmt) query))) I am curious about this regexp, \b is matching word/non-word boundary -- so I had to test it. (replace-regexp-in-string "\\b%t\\b" "repl" "foo %t bar") ;; no replacement (replace-regexp-in-string "\\b%t\\b" "repl" "foo-%t-bar") ;; no replacement ... (replace-regexp-in-string "\\b%t\\b" "repl" "foox%t-bar") ;; replacement! before % there is "word" character and after t there is "non-word" character. I wonder whether that works... (or is it just something I don't understand).. Also tried (format-spec "foo-%t-bar" '((?t . "repl"))) ;; which works as I'd expect. Tomi