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 3F2D66DE0314 for ; Tue, 23 May 2017 09:45:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.154 X-Spam-Level: X-Spam-Status: No, score=-0.154 tagged_above=-999 required=5 tests=[AWL=-0.134, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] 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 Ss8S8XEA9XDL for ; Tue, 23 May 2017 09:45:17 -0700 (PDT) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by arlo.cworth.org (Postfix) with ESMTPS id 737036DE0191 for ; Tue, 23 May 2017 09:45:17 -0700 (PDT) Received: by mail-lf0-f47.google.com with SMTP id a5so39930414lfh.2 for ; Tue, 23 May 2017 09:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=sNKoUs3LqLsHUHA9y8iEZlBwK2+022EycnbqSj99iIk=; b=FkWJMYoO6M3xnNzOCriBMZQVNIcLV9eQRmKt/RvYnicvn6QHpRfaUbhtOar0+bP5K4 O9KQoMTuhhAArsDG6znwrv0ohbzdK5/nC7Q5yxAzy1oyvLyCFjaovpMdaeaF46+LtwWA OeacppwGKquIGBtZBHviCQKOd/8k8IHUTN6wt9PcrpoPqzorB15GsMDbtiv4CzgtRObn 5IysAClMgjXkWcN9M+TEiLYYTYpGpiUG5l4DjQvnuuIYjleghi5AW1uRvOF3FwadZVra IsZ35yeLWFAXpUxxhLz+4QUP0rL7k+Q/ksALTCtUnbNd9tJxA5hxsminJ5Cvk2vAEXZ2 QI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=sNKoUs3LqLsHUHA9y8iEZlBwK2+022EycnbqSj99iIk=; b=p+kYyFwHn8frfGh7AcwA5WPLlwlV35kQJ1rSpifCJdQK4F5OV/5YmuhP+3Zx0uyWOs ywR58M9YmvCW9Zkb/8MJa5N+Ecg8eHwSm+G/b/6q21RvKhBIWmUhANzvV+TEMkctiqOY oPWJrDC/YOxzae0pvmEs/5JYIBI5SI7RUwZTqWzs8sKykU++sduKN80KQMLrbln38AzM PzyO9XV4KAaX5v6G9HFzqytGv3uKUAgk1kSf/ucUj3X5KTXix8vTk8i6zDduqVZm5sK+ BiyVA3Fuw56cisykxp9VLT6djwu1rKWqjFAMN9aKwvvb+pYf3n69CDXtthSK5QZ//4pK tjJw== X-Gm-Message-State: AODbwcDStw04m/kRkvSzaGFRpV6ccOM1WxO8t4s5yu7TYE+vf/W2yc1H ZP1M69pLEhgPi1MQ X-Received: by 10.25.25.139 with SMTP id 133mr8062689lfz.33.1495557915155; Tue, 23 May 2017 09:45:15 -0700 (PDT) Received: from localhost (mobile-access-bcee7f-185.dhcp.inet.fi. [188.238.127.185]) by smtp.gmail.com with ESMTPSA id n204sm271654lfn.16.2017.05.23.09.45.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2017 09:45:14 -0700 (PDT) From: Jani Nikula To: Damien Cassou , notmuch@notmuchmail.org Cc: notmuch@freelists.org Subject: Re: Add support for imenu In-Reply-To: <87mva3r3wo.fsf@cassou.me> References: <87mva3r3wo.fsf@cassou.me> Date: Tue, 23 May 2017 19:45:12 +0300 Message-ID: <87y3tna5ev.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain 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 16:45:19 -0000 On Tue, 23 May 2017, Damien Cassou wrote: > Please find attached a patch adding imenu support in both search > and show modes. I would appreciate a commit message explaining what the patch is about, written to someone who doesn't know what imenu is, or how it could be applicable in search and show modes. Please also look into using git send-email if possible, instead of attaching the patch. BR, Jani. > > -- > Damien Cassou > http://damiencassou.seasidehosting.st > > "Success is the ability to go from one failure to another without > losing enthusiasm." --Winston Churchill > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch