From 28b889404a73093ace55868e28fa41cdb5d4a3fb Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 23 May 2020 10:52:03 -0700 Subject: add notmuch-slurp-debbug-at-point Signed-off-by: Sean Whitton --- mailscripts.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index 2280f5a..3e5b3b5 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -1,10 +1,10 @@ ;;; mailscripts.el --- functions to access tools in the mailscripts package ;; Author: Sean Whitton -;; Version: 0.20 +;; Version: 0.21 ;; Package-Requires: (notmuch projectile) -;; Copyright (C) 2018, 2019 Sean Whitton +;; Copyright (C) 2018, 2019, 2020 Sean Whitton ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ (require 'notmuch) (require 'projectile) +(require 'thingatpt) (defgroup mailscripts nil "Customisation of functions in the mailscripts package.") @@ -55,6 +56,16 @@ If NO-OPEN, don't open the thread." (unless no-open (notmuch-show (concat "Bug#" bug)))) +;;;###autoload +(defun notmuch-slurp-debbug-at-point () + "Slurp Debian bug with bug number at point and open the thread in notmuch." + (interactive) + (save-excursion + ;; the bug number might be prefixed with a # or 'Bug#'; try + ;; skipping over those to see if there's a number afterwards + (skip-chars-forward "#bBug" (+ 4 (point))) + (notmuch-slurp-debbug (number-to-string (number-at-point))))) + ;;;###autoload (defun notmuch-slurp-this-debbug () "When viewing a Debian bug in notmuch, download any missing messages." -- cgit v1.2.3 From 73f4786d9315c5e40e88f8f34fb221ba4fbe5355 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 23 May 2020 10:59:34 -0700 Subject: notmuch-slurp-this-debbug: if fail to extract bug number, prompt Signed-off-by: Sean Whitton --- debian/changelog | 2 ++ mailscripts.el | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index 6565a39..a38fe6d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ mailscripts (0.20-2) UNRELEASED; urgency=medium * mailscripts.el: - new command: notmuch-slurp-debbug-at-point + - notmuch-slurp-this-debbug: if fail to extract bug number from + subject line, prompt user for one -- Sean Whitton Sat, 23 May 2020 10:49:57 -0700 diff --git a/mailscripts.el b/mailscripts.el index 3e5b3b5..36f5732 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -71,8 +71,10 @@ If NO-OPEN, don't open the thread." "When viewing a Debian bug in notmuch, download any missing messages." (interactive) (let ((subject (notmuch-show-get-subject))) - (when (string-match "Bug#\\([0-9]+\\):" subject) - (notmuch-slurp-debbug (match-string 1 subject) t)) + (notmuch-slurp-debbug + (if (string-match "Bug#\\([0-9]+\\):" subject) + (match-string 1 subject) + (read-string "Bug number: ")) t) (notmuch-refresh-this-buffer))) ;;;###autoload -- cgit v1.2.3 From ce481dee7327c6ee4809370658009ee29994adcb Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 23 May 2020 11:07:19 -0700 Subject: notmuch-slurp-debbug: invoke notmuch to find the thread-id Signed-off-by: Sean Whitton --- debian/changelog | 4 ++++ mailscripts.el | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'mailscripts.el') diff --git a/debian/changelog b/debian/changelog index a38fe6d..7363245 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ mailscripts (0.20-2) UNRELEASED; urgency=medium - new command: notmuch-slurp-debbug-at-point - notmuch-slurp-this-debbug: if fail to extract bug number from subject line, prompt user for one + - notmuch-slurp-debbug: invoke notmuch to determine the thread-id + rather than passing the search query directly to `notmuch-show'. + That is not how `notmuch-show' is meant to be called and can result + in strange behaviour. -- Sean Whitton Sat, 23 May 2020 10:49:57 -0700 diff --git a/mailscripts.el b/mailscripts.el index 36f5732..50e3b89 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -54,7 +54,15 @@ If NO-OPEN, don't open the thread." (interactive "sBug number: ") (call-process-shell-command (concat "notmuch-slurp-debbug " bug)) (unless no-open - (notmuch-show (concat "Bug#" bug)))) + (let* ((search (concat "Bug#" bug)) + (thread-id (car (process-lines notmuch-command + "search" + "--output=threads" + "--limit=1" + "--format=text" + "--format-version=4" search)))) + (notmuch-show thread-id nil nil nil + (concat "*notmuch-show-" search "*"))))) ;;;###autoload (defun notmuch-slurp-debbug-at-point () -- cgit v1.2.3