unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: jao <jao@gnu.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v4] emacs: customizable names for search buffers
Date: Thu, 13 Jan 2022 08:05:34 +0200	[thread overview]
Message-ID: <m2h7a8yxu9.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20220110181644.1457631-1-jao@gnu.org>

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 <jao@gnu.org>
> ---
> 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


  reply	other threads:[~2022-01-13  6:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 18:16 [PATCH v4] emacs: customizable names for search buffers jao
2022-01-13  6:05 ` Tomi Ollila [this message]
2022-01-13 22:43   ` Jose A Ortega Ruiz
2022-01-14  0:57     ` Jose A Ortega Ruiz
2022-01-16 19:42       ` Tomi Ollila
2022-01-16 20:40         ` Jose A Ortega Ruiz
2022-01-16 20:34     ` Kyle Meyer
2022-01-16 22:25       ` Jose A Ortega Ruiz
2022-01-16 23:06         ` Kyle Meyer
2022-01-16 23:51           ` Jose A Ortega Ruiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2h7a8yxu9.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=jao@gnu.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).