From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 9C5676DE0314 for ; Tue, 23 May 2017 08:30:55 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.101 X-Spam-Level: X-Spam-Status: No, score=-0.101 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XF_qg24oD1WI for ; Tue, 23 May 2017 08:30:53 -0700 (PDT) X-Greylist: delayed 301 seconds by postgrey-1.36 at arlo; Tue, 23 May 2017 08:30:53 PDT Received: from mail.choca.pics (mail.choca.pics [62.210.108.126]) by arlo.cworth.org (Postfix) with ESMTPS id 8046D6DE0191 for ; Tue, 23 May 2017 08:30:53 -0700 (PDT) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 370C1232B36F for ; Tue, 23 May 2017 17:25:48 +0200 (CEST) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id Lmk6oZVVyvBB for ; Tue, 23 May 2017 17:25:47 +0200 (CEST) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 0FC23232B370 for ; Tue, 23 May 2017 17:25:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.choca.pics 0FC23232B370 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cassou.me; s=9EA44F5C-DEF4-11E6-A83F-A08DF322D8FB; t=1495553147; bh=DIvfjD47wzh0WTbBvAWQfULOFZX/qqfSATE1MQkBtaw=; h=From:To:Date:Message-ID:MIME-Version; b=jf+9poI2MFaIQOj3EipT5d+1drqjoNExs9iclNXUy6xGnFZLNrSpa9wB2bb5DFCEH ZhY6jMTBC1Z69zIRTVxsRRNTOTYfjKvxL584ekgeQJfz89CXw6+u4VBoZ0XT5cRyuU vAEdXmF37lLMioVj0Y6MzBqF+1WUgga43D9DnId3NbAraJVuagzTdby3WzGr7m6OWj SDv8q7VYaq22MumeqzG9KkxdpYSlj/5PGVACvDZxbSdE+4a2ZkItq/pNfuzIaCQwJ8 T28Xl14z6wWhD5/y8Ex5vwEIW2Oe63JBRqPnAJQgooj2GDoGbHm14sDJyQ+PMA9dwt yTKsvDrGogwdQ== X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 1kY71h5hXoCq for ; Tue, 23 May 2017 17:25:46 +0200 (CEST) Received: from luz4 (c80-216-198-172.bredband.comhem.se [80.216.198.172]) by mail.choca.pics (Postfix) with ESMTPSA id B4D7B232B36F for ; Tue, 23 May 2017 17:25:46 +0200 (CEST) From: Damien Cassou To: notmuch@notmuchmail.org Subject: Add support for imenu Date: Tue, 23 May 2017 17:25:43 +0200 Message-ID: <87mva3r3wo.fsf@cassou.me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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: Tue, 23 May 2017 15:30:55 -0000 --=-=-= Content-Type: text/plain; format=flowed Please find attached a patch adding imenu support in both search and show modes. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-imenu-support-in-notmuch-show-and-notmuch-search.patch >From aa29c3e4227ad95e940a047494ef5367eaa57596 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Tue, 23 May 2017 17:19:57 +0200 Subject: [PATCH] Add imenu support in notmuch-show and notmuch-search --- emacs/notmuch-show.el | 22 +++++++++++++++++++++- emacs/notmuch.el | 27 ++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index c670160..b7d6429 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1516,7 +1516,11 @@ \\{notmuch-show-mode-map}" (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view) (setq buffer-read-only t - truncate-lines t)) + truncate-lines t) + (setq imenu-prev-index-position-function + #'notmuch-show-imenu-prev-index-position-function) + (setq imenu-extract-index-name-function + #'notmuch-show-imenu-extract-index-name-function)) (defun notmuch-tree-from-show-current-query () "Call notmuch tree with the current query" @@ -2455,6 +2459,22 @@ (list (completing-read "Mime type to use (default text/plain): " (mailcap-mime-types) nil nil nil nil "text/plain"))) (notmuch-show-apply-to-current-part-handle #'notmuch-show--mm-display-part mime-type)) +(defun notmuch-show-imenu-prev-index-position-function () + "Move point to previous message in notmuch-show buffer. +This function is used as a value for +`imenu-prev-index-position-function'." + (if (bobp) + nil + (notmuch-show-previous-message) + t)) + +(defun notmuch-show-imenu-extract-index-name-function () + "Return imenu name for line at point. +This function is used as a value for +`imenu-extract-index-name-function'. Point should be at the +beginning of the line." + (buffer-substring-no-properties (line-beginning-position) (line-end-position))) + (provide 'notmuch-show) ;;; notmuch-show.el ends here diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 40b9fab..90af68e 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -374,7 +374,11 @@ (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view) (set (make-local-variable 'scroll-preserve-screen-position) t) (add-to-invisibility-spec (cons 'ellipsis t)) (setq truncate-lines t) - (setq buffer-read-only t)) + (setq buffer-read-only t) + (setq imenu-prev-index-position-function + #'notmuch-search-imenu-prev-index-position-function) + (setq imenu-extract-index-name-function + #'notmuch-search-imenu-extract-index-name-function)) (defun notmuch-search-get-result (&optional pos) "Return the result object for the thread at POS (or point). @@ -1094,8 +1098,8 @@ (bury-buffer)) ;; Find the first notmuch buffer. (setq first (loop for buffer in (buffer-list) - if (notmuch-interesting-buffer buffer) - return buffer)) + if (notmuch-interesting-buffer buffer) + return buffer)) (if first ;; If the first one we found is any other than the starting @@ -1104,6 +1108,23 @@ (unless (eq first start) (switch-to-buffer first)) (notmuch)))) +;;;; Imenu Support + +(defun notmuch-search-imenu-prev-index-position-function () + "Move point to previous message in notmuch-search buffer. +This function is used as a value for +`imenu-prev-index-position-function'." + (notmuch-search-previous-thread)) + +(defun notmuch-search-imenu-extract-index-name-function () + "Return imenu name for line at point. +This function is used as a value for +`imenu-extract-index-name-function'. Point should be at the +beginning of the line." + (let ((subject (notmuch-search-find-subject)) + (author (notmuch-search-find-authors))) + (format "%s (%s)" subject author))) + (setq mail-user-agent 'notmuch-user-agent) (provide 'notmuch) -- 2.9.4 --=-=-=--