Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6F32B4196F0 for ; Sun, 18 Apr 2010 20:55:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NEVh95mp3GGU for ; Sun, 18 Apr 2010 20:55:51 -0700 (PDT) Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com [74.125.82.53]) by olra.theworths.org (Postfix) with ESMTP id 41651431FC1 for ; Sun, 18 Apr 2010 20:55:51 -0700 (PDT) Received: by wwg30 with SMTP id 30so188831wwg.26 for ; Sun, 18 Apr 2010 20:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=uxthqHz+FzT3KOu66gIWgpHcKGV4tKZ+OzYhtV6U3t4=; b=t7Kww4dNj7WhZhKEBoxVvtsuhEy/Zi/yzH+NoUPJ0iFF17AlhDBTj4nnqGAOXaaOat FNmEwycIJEwfbCiukUFIVhI6F5CH0NyDkFpEktsS6I0C8C+ovjWGPw2x7Iq3TEaxCZdL FORRbCRv3udJnA/kOWuW/tLEYW9XobSPiN3f4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=bRMMircUZ0BDawRSjsSBOd62kdyOk8sdV0uJ+tXePbAO5j0cfMVcxFT9lF7UA4nDLE 0aJao6jnnSu6S/LeMi5d+oPZOnpYLmZN5rbKgK2/KKXOZo71rbOwC1IcdxTbqGn8+bau f1k+HEiB8cr4AWW4eT0ErxaepN7hh2/YDPhqY= MIME-Version: 1.0 Received: by 10.216.89.140 with HTTP; Sun, 18 Apr 2010 20:55:50 -0700 (PDT) Date: Sun, 18 Apr 2010 23:55:50 -0400 Received: by 10.216.87.147 with SMTP id y19mr6270358wee.136.1271649350308; Sun, 18 Apr 2010 20:55:50 -0700 (PDT) Message-ID: Subject: [PATCH] emacs: Try to name search buffers using info in notmuch-folders From: Servilio Afre Puentes To: notmuch Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2010 03:55:52 -0000 This patch obsoletes the one sent in message: r2sb22065d01004150516jf099f3dcw180a7db0dc972c76@mail.gmail.com 8<------ As the user has already defined aliases for certain searches in notmuch-folders, search buffer names that use these aliases will be easier to identify. --- emacs/notmuch.el | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 0adaf8b..f18b1ac 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -695,6 +695,27 @@ characters as well as `_.+-'. (apply 'notmuch-call-notmuch-process "tag" (append action-split (list notmuch-search-query-string) nil)))) +(defun notmuch-search-buffer-title (query) + "Returns the title for a buffer with notmuch search results." + (let* ((folder (rassoc-if (lambda (key) + (string-match (concat "^" (regexp-quote key)) + query)) + notmuch-folders)) + (folder-name (car folder)) + (folder-query (cdr folder))) + (cond ((and folder (equal folder-query query)) + ;; Query is the same as folder search (ignoring case) + (concat "*notmuch-folder-" folder-name "*")) + (folder + (concat "*notmuch-search-" + (replace-regexp-in-string (concat "^" (regexp-quote folder-query)) + (concat "[ " folder-name " ]") + query) + "*")) + (t + (concat "*notmuch-search-" query "*")) + ))) + ;;;###autoload (defun notmuch-search (query &optional oldest-first target-thread target-line) "Run \"notmuch search\" with the given query string and display results. @@ -707,7 +728,7 @@ The optional parameters are used as follows: target-line: The line number to move to if the target thread does not appear in the search results." (interactive "sNotmuch search: ") - (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*")))) + (let ((buffer (get-buffer-create (notmuch-search-buffer-title query)))) (switch-to-buffer buffer) (notmuch-search-mode) (set 'notmuch-search-query-string query) -- 1.7.0.4