discussion and development of piem
 help / color / mirror / code / Atom feed
* [PATCH 1/2] piem: Add :gnu-package keyword to piem-inboxes
@ 2023-06-08 16:59 jlicht
  2023-06-08 16:59 ` [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed jlicht
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: jlicht @ 2023-06-08 16:59 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

With the `:gnu-package` keyword, users can configure a regex to match
against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.
---
 Documentation/piem.texi |  6 ++++++
 piem.el                 | 18 +++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Documentation/piem.texi b/Documentation/piem.texi
index 26962a4..99185d3 100644
--- a/Documentation/piem.texi
+++ b/Documentation/piem.texi
@@ -168,6 +168,12 @@ repository (e.g., if the inbox receives patches for multiple projects,
 or if you use a few dedicated Git worktrees for different types of
 patches), set @code{:coderepo} to a list of locations.
 
+@cindex issue tracking
+@cindex Debbugs, issue tracking system
+When using the Debbugs instance at @uref{https://bugs.gnu.org} to
+retrieve messages, an inbox can mapped to each message by setting
+@code{:gnu-package} for an inbox.
+
 @findex piem-merged-inboxes
 @vindex piem-get-inboxes-from-config
 If you mirror some inboxes locally (e.g., for fast local access or for
diff --git a/piem.el b/piem.el
index 568e91b..b910893 100644
--- a/piem.el
+++ b/piem.el
@@ -83,6 +83,8 @@ list that supports the following properties:
       A URL hosting HTTPS archives.
   :maildir
       A Maildir directory to inject messages into.
+  :gnu-package
+      A GNU Bug Tracker label to match with for the inbox.
 
 Here's an example for the public-inbox project itself:
 
@@ -393,7 +395,7 @@ files."
                   (rx string-start "publicinbox."
                       (group (one-or-more not-newline)) "."
                       (group
-                       (or "address" "coderepo" "listid" "maildir" "url"))
+                       (or "address" "coderepo" "listid" "maildir" "url" "gnu-package"))
                       string-end)
                   key)
              (let* ((inbox-name (match-string 1 key))
@@ -493,12 +495,14 @@ non-nil, make the match specific for that message."
 This should be called from a buffer containing a message and is
 intended to be used by libraries implementing a function for
 `piem-get-inbox-functions'."
-  (pcase-let ((`(,listid ,to ,cc)
-               (piem--message-fetch-decoded-fields '("list-id" "to" "cc"))))
+  (pcase-let ((`(,listid ,to ,cc ,x-gnu-pr-package)
+               (piem--message-fetch-decoded-fields
+                '("list-id" "to" "cc" "x-gnu-pr-package"))))
     (catch 'hit
       (dolist (inbox (piem-merged-inboxes))
         (let* ((info (cdr inbox))
-               (p-listid (plist-get info :listid)))
+               (p-listid (plist-get info :listid))
+               (p-package (plist-get info :gnu-package)))
           (when (and listid
                      p-listid
                      (string-match-p (concat "<" (regexp-quote p-listid) ">")
@@ -508,7 +512,11 @@ intended to be used by libraries implementing a function for
                      (to (mapconcat #'identity (list to cc)
                                     " ")))
             (when (string-match-p (regexp-quote addr) to)
-              (throw 'hit (car inbox)))))))))
+              (throw 'hit (car inbox))))
+          (when (and x-gnu-pr-package
+                     p-package
+                     (string-match-p (regexp-quote p-package) x-gnu-pr-package))
+            (throw 'hit (car inbox))))))))
 
 (defun piem-inbox ()
   "Return the current buffer's inbox."
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed.
  2023-06-08 16:59 [PATCH 1/2] piem: Add :gnu-package keyword to piem-inboxes jlicht
@ 2023-06-08 16:59 ` jlicht
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
  2023-06-10  9:58 ` [PATCH v3 " jlicht
  2 siblings, 0 replies; 29+ messages in thread
From: jlicht @ 2023-06-08 16:59 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem-gnus.el | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/piem-gnus.el b/piem-gnus.el
index 4011fa2..e8e5f1e 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -56,6 +56,20 @@
             (match-string 1 mid)
           mid)))))
 
+(defun piem-gnus--from-line (buffer)
+  "Returns a cons of the first line of BUFFER, if it is an
+mbboxrd from-line (or nil if none), and the remaining lines of
+BUFFER."
+  (with-current-buffer buffer
+    (let ((start (point-min))
+          (end (point-max)))
+      (goto-char start)
+      (let* ((eol (line-end-position))
+             (line (buffer-substring-no-properties start eol)))
+        (if (string-match-p "^From " line)
+            (cons line (buffer-substring-no-properties (+ eol 1) end))
+          (cons nil (buffer-substring-no-properties start end)))))))
+
 (defun piem-gnus-mid-to-thread (mid)
   (when (and (derived-mode-p 'gnus-summary-mode)
              (string-equal (substring
@@ -75,16 +89,17 @@
             gnus-break-pages)
         (mapc (lambda (article)
                 (gnus-summary-display-article article)
-                (push (format
-                       "From mboxrd@z Thu Jan  1 00:00:00 1970\n%s\n"
-                       (replace-regexp-in-string ; From-munge
-                        "^>*From "
-                        ">\\&"
-                        (with-current-buffer gnus-article-buffer
-                          (buffer-substring-no-properties
-                           (point-min)
-                           (point-max)))))
-                      messages))
+                (let ((from-line-cons
+                       (piem-gnus--from-line gnus-article-buffer)))
+                  (push (format
+                         "%s\n%s\n"
+                         (or (car from-line-cons)
+                             "From mboxrd@z Thu Jan  1 00:00:00 1970")
+                         (replace-regexp-in-string
+                          "^>*From "
+                          ">\\&"
+                          (cdr from-line-cons)))
+                        messages)))
               articles)
         (lambda ()
           (insert (apply #'concat (nreverse messages))))))))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 0/5] New piem-debbugs integration.
  2023-06-08 16:59 [PATCH 1/2] piem: Add :gnu-package keyword to piem-inboxes jlicht
  2023-06-08 16:59 ` [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed jlicht
@ 2023-06-09 12:48 ` jlicht
  2023-06-09 12:48   ` [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
                     ` (5 more replies)
  2023-06-10  9:58 ` [PATCH v3 " jlicht
  2 siblings, 6 replies; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

I tidied up the changes, making sure that the :gnu-package
header-matching is only used as a fallback by piem-gnus, and factored
the logic such that the new piem-debbugs integration can also make use
of it..

I copied the copyright blurb, as IANAL, but please adjust according to
your preferences if you don't like it.

Jelle Licht (5):
  piem: Add :gnu-package keyword to piem-inboxes
  gnus: Skip adding mboxrd from-line when not needed.
  piem: Add piem-inbox-by-gnu-package-match.
  gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header.
  Add basic integration for debbugs.

 Documentation/piem.texi |  6 ++++
 piem-debbugs.el         | 66 +++++++++++++++++++++++++++++++++++++++++
 piem-gnus.el            | 41 ++++++++++++++++++-------
 piem.el                 | 19 +++++++++++-
 4 files changed, 120 insertions(+), 12 deletions(-)
 create mode 100644 piem-debbugs.el

-- 
2.40.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
@ 2023-06-09 12:48   ` jlicht
  2023-06-10  4:52     ` Kyle Meyer
  2023-06-09 12:48   ` [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

With the `:gnu-package` keyword, users can configure a regex to match
against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.
---
 Documentation/piem.texi | 6 ++++++
 piem.el                 | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/piem.texi b/Documentation/piem.texi
index 26962a4..99185d3 100644
--- a/Documentation/piem.texi
+++ b/Documentation/piem.texi
@@ -168,6 +168,12 @@ repository (e.g., if the inbox receives patches for multiple projects,
 or if you use a few dedicated Git worktrees for different types of
 patches), set @code{:coderepo} to a list of locations.
 
+@cindex issue tracking
+@cindex Debbugs, issue tracking system
+When using the Debbugs instance at @uref{https://bugs.gnu.org} to
+retrieve messages, an inbox can mapped to each message by setting
+@code{:gnu-package} for an inbox.
+
 @findex piem-merged-inboxes
 @vindex piem-get-inboxes-from-config
 If you mirror some inboxes locally (e.g., for fast local access or for
diff --git a/piem.el b/piem.el
index 568e91b..914dd23 100644
--- a/piem.el
+++ b/piem.el
@@ -83,6 +83,8 @@ list that supports the following properties:
       A URL hosting HTTPS archives.
   :maildir
       A Maildir directory to inject messages into.
+  :gnu-package
+      A GNU Bug Tracker label to match with for the inbox.
 
 Here's an example for the public-inbox project itself:
 
@@ -393,7 +395,7 @@ files."
                   (rx string-start "publicinbox."
                       (group (one-or-more not-newline)) "."
                       (group
-                       (or "address" "coderepo" "listid" "maildir" "url"))
+                       (or "address" "coderepo" "listid" "maildir" "url" "gnu-package"))
                       string-end)
                   key)
              (let* ((inbox-name (match-string 1 key))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed.
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
  2023-06-09 12:48   ` [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
@ 2023-06-09 12:48   ` jlicht
  2023-06-10  4:55     ` Kyle Meyer
  2023-06-09 12:48   ` [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem-gnus.el | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/piem-gnus.el b/piem-gnus.el
index 4011fa2..e8e5f1e 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -56,6 +56,20 @@
             (match-string 1 mid)
           mid)))))
 
+(defun piem-gnus--from-line (buffer)
+  "Returns a cons of the first line of BUFFER, if it is an
+mbboxrd from-line (or nil if none), and the remaining lines of
+BUFFER."
+  (with-current-buffer buffer
+    (let ((start (point-min))
+          (end (point-max)))
+      (goto-char start)
+      (let* ((eol (line-end-position))
+             (line (buffer-substring-no-properties start eol)))
+        (if (string-match-p "^From " line)
+            (cons line (buffer-substring-no-properties (+ eol 1) end))
+          (cons nil (buffer-substring-no-properties start end)))))))
+
 (defun piem-gnus-mid-to-thread (mid)
   (when (and (derived-mode-p 'gnus-summary-mode)
              (string-equal (substring
@@ -75,16 +89,17 @@
             gnus-break-pages)
         (mapc (lambda (article)
                 (gnus-summary-display-article article)
-                (push (format
-                       "From mboxrd@z Thu Jan  1 00:00:00 1970\n%s\n"
-                       (replace-regexp-in-string ; From-munge
-                        "^>*From "
-                        ">\\&"
-                        (with-current-buffer gnus-article-buffer
-                          (buffer-substring-no-properties
-                           (point-min)
-                           (point-max)))))
-                      messages))
+                (let ((from-line-cons
+                       (piem-gnus--from-line gnus-article-buffer)))
+                  (push (format
+                         "%s\n%s\n"
+                         (or (car from-line-cons)
+                             "From mboxrd@z Thu Jan  1 00:00:00 1970")
+                         (replace-regexp-in-string
+                          "^>*From "
+                          ">\\&"
+                          (cdr from-line-cons)))
+                        messages)))
               articles)
         (lambda ()
           (insert (apply #'concat (nreverse messages))))))))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match.
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
  2023-06-09 12:48   ` [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
  2023-06-09 12:48   ` [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
@ 2023-06-09 12:48   ` jlicht
  2023-06-10  4:57     ` Kyle Meyer
  2023-06-09 12:48   ` [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header jlicht
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/piem.el b/piem.el
index 914dd23..3fffb0e 100644
--- a/piem.el
+++ b/piem.el
@@ -490,6 +490,21 @@ non-nil, make the match specific for that message."
                   (mail-decode-encoded-word-string val)))
               headers))))
 
+(defun piem-inbox-by-gnu-package-match (gnu-package)
+  "Return inbox based on matching :gnu-package properties.
+GNU-PACKAGE should be a string. This function is intended to be
+used by libraries implementing a function for
+`piem-get-inbox-function'."
+  (when gnu-package
+    (catch 'hit
+      (dolist (inbox (piem-merged-inboxes))
+        (let* ((info (cdr inbox))
+               (p-package (plist-get info :gnu-package)))
+          (when (and gnu-package
+                     p-package
+                     (string-match-p p-package gnu-package))
+            (throw 'hit (car inbox))))))))
+
 (defun piem-inbox-by-header-match ()
   "Return inbox based on matching message headers.
 This should be called from a buffer containing a message and is
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header.
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
                     ` (2 preceding siblings ...)
  2023-06-09 12:48   ` [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
@ 2023-06-09 12:48   ` jlicht
  2023-06-10  4:58     ` Kyle Meyer
  2023-06-09 12:48   ` [PATCH v2 5/5] Add basic integration for debbugs jlicht
  2023-06-10  5:00   ` [PATCH v2 0/5] New piem-debbugs integration Kyle Meyer
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem-gnus.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/piem-gnus.el b/piem-gnus.el
index e8e5f1e..25b80b7 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -42,7 +42,11 @@
   "Return inbox name from a Gnus article"
   (when (derived-mode-p 'gnus-article-mode 'gnus-summary-mode)
     (with-current-buffer gnus-original-article-buffer
-      (piem-inbox-by-header-match))))
+      (or (piem-inbox-by-header-match)
+          (let ((gnu-package
+                 (car (piem--message-fetch-decoded-fields
+                       '("x-gnu-pr-package")))))
+            (piem-inbox-by-gnu-package-match gnu-package))))))
 
 (defun piem-gnus-get-mid ()
   "Return the message ID of a Gnus article."
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 5/5] Add basic integration for debbugs.
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
                     ` (3 preceding siblings ...)
  2023-06-09 12:48   ` [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header jlicht
@ 2023-06-09 12:48   ` jlicht
  2023-06-10  4:59     ` Kyle Meyer
  2023-06-10  5:00   ` [PATCH v2 0/5] New piem-debbugs integration Kyle Meyer
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-09 12:48 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem-debbugs.el | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 piem-debbugs.el

diff --git a/piem-debbugs.el b/piem-debbugs.el
new file mode 100644
index 0000000..8757ddd
--- /dev/null
+++ b/piem-debbugs.el
@@ -0,0 +1,66 @@
+;;; piem-debbugs.el --- debbugs.el integration for piem  -*- lexical-binding: t; -*-
+
+;; Copyright all piem contributors <piem@inbox.kyleam.com>
+
+;; Author: Kyle Meyer <kyle@kyleam.com>
+;; Keywords: vc, tools
+;; Package-Requires: ((emacs "26.3"))
+
+;; 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
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library provides a minor mode, `piem-debbugs-mode', that modifies
+;; `piem' variables to teach functions like `piem-inbox' how to
+;; extract information from debbugs buffers.
+
+;;; Code:
+
+(require 'debbugs)
+(require 'piem)
+
+(defgroup piem-debbugs nil
+  "debbugs integration for piem."
+  :group 'piem)
+
+(defun piem-debbugs-get-inbox ()
+  "Return inbox name from a debbugs buffer."
+  (when (derived-mode-p 'debbugs-gnu-mode)
+    (when-let ((gnu-package (alist-get 'package debbugs-gnu-local-query)))
+      (piem-inbox-by-gnu-package-match gnu-package))))
+
+(defun piem-debbugs-get-mid ()
+  "Return the message ID of a debbugs buffer."
+  (when (derived-mode-p 'debbugs-gnu-mode)
+    (let ((msgid (alist-get 'msgid (debbugs-gnu-current-status))))
+      (when (stringp msgid)
+        (string-trim msgid "<" ">")))))
+
+;;;###autoload
+(define-minor-mode piem-debbugs-mode
+  "Toggle debbugs support for piem.
+With a prefix argument ARG, enable piem-debbugs mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil."
+  :global t
+  :init-value nil
+  (if piem-debbugs-mode
+      (progn
+        (add-hook 'piem-get-inbox-functions #'piem-debbugs-get-inbox)
+        (add-hook 'piem-get-mid-functions #'piem-debbugs-get-mid))
+    (remove-hook 'piem-get-inbox-functions #'piem-debbugs-get-inbox)
+    (remove-hook 'piem-get-mid-functions #'piem-debbugs-get-mid)))
+
+;;; piem-debbugs.el ends here
+(provide 'piem-debbugs)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes
  2023-06-09 12:48   ` [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
@ 2023-06-10  4:52     ` Kyle Meyer
  2023-06-10 10:02       ` Jelle Licht
  0 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  4:52 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> With the `:gnu-package` keyword, users can configure a regex to match
> against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.

Is a regex needed, or would plain string comparison (on downcased
string) be sufficient?

If it is needed, I think the documentation should be adjusted to mention
it's a regex.  That's a bit different than the other headers, where the
user input value itself isn't treated as a regex, even if internally the
match is done with a regex, mostly to handle surrounding text that comes
along with the header.  (As a complete side remark: looking at the
:address handling, it should probably be more careful to not match just
a substring of an address.)

> ---
> diff --git a/Documentation/piem.texi b/Documentation/piem.texi
> index 26962a4..99185d3 100644
> --- a/Documentation/piem.texi
> +++ b/Documentation/piem.texi
> @@ -168,6 +168,12 @@ repository (e.g., if the inbox receives patches for multiple projects,
>  or if you use a few dedicated Git worktrees for different types of
>  patches), set @code{:coderepo} to a list of locations.
>  
> +@cindex issue tracking
> +@cindex Debbugs, issue tracking system
> +When using the Debbugs instance at @uref{https://bugs.gnu.org} to
> +retrieve messages, an inbox can mapped to each message by setting
> +@code{:gnu-package} for an inbox.

Nice, thanks for updating the texi docs.

Reading this made me think about other instances (Debian, perhaps
others), but I'll leave worrying about that until someone interested
comes along.

> @@ -393,7 +395,7 @@ files."
>                    (rx string-start "publicinbox."
>                        (group (one-or-more not-newline)) "."
>                        (group
> -                       (or "address" "coderepo" "listid" "maildir" "url"))
> +                       (or "address" "coderepo" "listid" "maildir" "url" "gnu-package"))

Please move "gnu-package" onto the next line to avoid going too far over
~80 characters.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed.
  2023-06-09 12:48   ` [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
@ 2023-06-10  4:55     ` Kyle Meyer
  2023-06-10 10:07       ` Jelle Licht
  0 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  4:55 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> From: Jelle Licht <jlicht@fsfe.org>

Could you add a bit about why this is needed?  Basically that, at least
over NNTP, gnus-summary-display-article shows a plain message, but when
debbugs.el visits an issues message with Gnus, it's already in mbox
format.

It'd also be nice to add a link to the relevant inbox.kyleam.com thread.

(Convention nit-pick for this and subsequent patches: please drop the
period from the subject, ignoring all Guix muscle memory :>)

> +(defun piem-gnus--from-line (buffer)
> +  "Returns a cons of the first line of BUFFER, if it is an
> +mbboxrd from-line (or nil if none), and the remaining lines of

typo: s/mbboxrd/mboxrd/

> +BUFFER."

To follow Elisp docstring conventions, could you rewrite this so that
the first line is self-contained sentence?

It's marked as internal, so not too important, but I wonder if something
like "piem-gnus--split-message" might give a better hint at what it
does.

> +  (with-current-buffer buffer
> +    (let ((start (point-min))
> +          (end (point-max)))
> +      (goto-char start)
> +      (let* ((eol (line-end-position))
> +             (line (buffer-substring-no-properties start eol)))
> +        (if (string-match-p "^From " line)
> +            (cons line (buffer-substring-no-properties (+ eol 1) end))
> +          (cons nil (buffer-substring-no-properties start end)))))))

Looks fine to me.  And I don't think we need to worry about
save-excursion here, given that we're triggering the display of these
buffers and, in general, this command is making lots of user-visible
changes to the layout anyway (and we didn't know a way to avoid that:
<87turabsb0.fsf@yoctocell.xyz>).


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match.
  2023-06-09 12:48   ` [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
@ 2023-06-10  4:57     ` Kyle Meyer
  2023-06-10 10:08       ` Jelle Licht
  0 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  4:57 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> diff --git a/piem.el b/piem.el
> index 914dd23..3fffb0e 100644
> --- a/piem.el
> +++ b/piem.el
> @@ -490,6 +490,21 @@ non-nil, make the match specific for that message."
>                    (mail-decode-encoded-word-string val)))
>                headers))))
>  
> +(defun piem-inbox-by-gnu-package-match (gnu-package)
> +  "Return inbox based on matching :gnu-package properties.
> +GNU-PACKAGE should be a string. This function is intended to be

Convention: two spaces after period

> +used by libraries implementing a function for
> +`piem-get-inbox-function'."
> +  (when gnu-package
> +    (catch 'hit
> +      (dolist (inbox (piem-merged-inboxes))
> +        (let* ((info (cdr inbox))
> +               (p-package (plist-get info :gnu-package)))
> +          (when (and gnu-package
> +                     p-package
> +                     (string-match-p p-package gnu-package))
> +            (throw 'hit (car inbox))))))))
> +

I think it's nice to have this as a separate function, and I'm guessing
its use in the upcoming piem-debbugs.el is one of the reasons you
decided to do that.

But perhaps piem-inbox-by-gnu-package-match should still be called in
piem-inbox-by-header-match, following the dolist there.  The main
advantage of that is that debbugs.el also has Rmail support, so it'd let
piem-rmail-get-inbox take advantage of this header too.  Plus, if
piem-notmuch users want to match against X-GNU-PR-PACKAGE for whatever
reason, even though they should have a List-ID too, it seems like we
might as well consistently support it.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header.
  2023-06-09 12:48   ` [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header jlicht
@ 2023-06-10  4:58     ` Kyle Meyer
  2023-06-10 10:08       ` Jelle Licht
  0 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  4:58 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> From: Jelle Licht <jlicht@fsfe.org>
>
> ---
>  piem-gnus.el | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/piem-gnus.el b/piem-gnus.el
> index e8e5f1e..25b80b7 100644
> --- a/piem-gnus.el
> +++ b/piem-gnus.el
> @@ -42,7 +42,11 @@
>    "Return inbox name from a Gnus article"
>    (when (derived-mode-p 'gnus-article-mode 'gnus-summary-mode)
>      (with-current-buffer gnus-original-article-buffer
> -      (piem-inbox-by-header-match))))
> +      (or (piem-inbox-by-header-match)
> +          (let ((gnu-package
> +                 (car (piem--message-fetch-decoded-fields
> +                       '("x-gnu-pr-package")))))
> +            (piem-inbox-by-gnu-package-match gnu-package))))))

As mentioned in the last message, I think it'd be good to move this to
piem-inbox-by-header-match.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 5/5] Add basic integration for debbugs.
  2023-06-09 12:48   ` [PATCH v2 5/5] Add basic integration for debbugs jlicht
@ 2023-06-10  4:59     ` Kyle Meyer
  2023-06-10 10:11       ` Jelle Licht
  0 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  4:59 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> From: Jelle Licht <jlicht@fsfe.org>
>
> ---
>  piem-debbugs.el | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
>  create mode 100644 piem-debbugs.el

Please also update the Makefile and piem.texi (Enabling integration
libraries).

>
> diff --git a/piem-debbugs.el b/piem-debbugs.el
> new file mode 100644
> index 0000000..8757ddd
> --- /dev/null
> +++ b/piem-debbugs.el
> @@ -0,0 +1,66 @@
> +;;; piem-debbugs.el --- debbugs.el integration for piem  -*- lexical-binding: t; -*-
> +
> +;; Copyright all piem contributors <piem@inbox.kyleam.com>
> +
> +;; Author: Kyle Meyer <kyle@kyleam.com>

I think your info for author instead of mine is more appropriate, since
you're adding this file.

> +;; Keywords: vc, tools
> +;; Package-Requires: ((emacs "26.3"))

debbugs.el isn't bundled with Emacs, so Package-Requires should list
debbugs too.

> +(defgroup piem-debbugs nil
> +  "debbugs integration for piem."
> +  :group 'piem)
> +
> +(defun piem-debbugs-get-inbox ()
> +  "Return inbox name from a debbugs buffer."
> +  (when (derived-mode-p 'debbugs-gnu-mode)
> +    (when-let ((gnu-package (alist-get 'package debbugs-gnu-local-query)))
> +      (piem-inbox-by-gnu-package-match gnu-package))))
> +
> +(defun piem-debbugs-get-mid ()
> +  "Return the message ID of a debbugs buffer."
> +  (when (derived-mode-p 'debbugs-gnu-mode)
> +    (let ((msgid (alist-get 'msgid (debbugs-gnu-current-status))))
> +      (when (stringp msgid)
> +        (string-trim msgid "<" ">")))))

Nice.  I haven't tested this out yet, but that looks as clean as I was
hoping it would.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 0/5] New piem-debbugs integration.
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
                     ` (4 preceding siblings ...)
  2023-06-09 12:48   ` [PATCH v2 5/5] Add basic integration for debbugs jlicht
@ 2023-06-10  5:00   ` Kyle Meyer
  5 siblings, 0 replies; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10  5:00 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> I tidied up the changes, making sure that the :gnu-package
> header-matching is only used as a fallback by piem-gnus, and factored
> the logic such that the new piem-debbugs integration can also make use
> of it..

Thanks for the series!  I've left some minor comments, but this is
looking very good to me.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 0/5] New piem-debbugs integration
  2023-06-08 16:59 [PATCH 1/2] piem: Add :gnu-package keyword to piem-inboxes jlicht
  2023-06-08 16:59 ` [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed jlicht
  2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
@ 2023-06-10  9:58 ` jlicht
  2023-06-10  9:58   ` [PATCH v3 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
                     ` (5 more replies)
  2 siblings, 6 replies; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

V3 of this series addresses most of the shortcomings identified in the
review of V2, with a point-by-point response still on its way.

Jelle Licht (5):
  piem: Add :gnu-package keyword to piem-inboxes
  gnus: Skip adding mboxrd from-line when not needed
  piem: Add piem-inbox-by-gnu-package-match
  piem-inbox-by-header-match: Fallback to matching via :gnu-package
  Add basic integration for debbugs

 Documentation/piem.texi |  8 +++++
 Makefile                |  8 +++--
 piem-debbugs.el         | 67 +++++++++++++++++++++++++++++++++++++++++
 piem-gnus.el            | 36 ++++++++++++++++------
 piem.el                 | 57 ++++++++++++++++++++++++-----------
 5 files changed, 146 insertions(+), 30 deletions(-)
 create mode 100644 piem-debbugs.el

-- 
2.40.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 1/5] piem: Add :gnu-package keyword to piem-inboxes
  2023-06-10  9:58 ` [PATCH v3 " jlicht
@ 2023-06-10  9:58   ` jlicht
  2023-06-10  9:58   ` [PATCH v3 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

With the `:gnu-package` keyword, users can configure a string to match
against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.
---
 Documentation/piem.texi | 6 ++++++
 piem.el                 | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Documentation/piem.texi b/Documentation/piem.texi
index 26962a4..99185d3 100644
--- a/Documentation/piem.texi
+++ b/Documentation/piem.texi
@@ -168,6 +168,12 @@ repository (e.g., if the inbox receives patches for multiple projects,
 or if you use a few dedicated Git worktrees for different types of
 patches), set @code{:coderepo} to a list of locations.
 
+@cindex issue tracking
+@cindex Debbugs, issue tracking system
+When using the Debbugs instance at @uref{https://bugs.gnu.org} to
+retrieve messages, an inbox can mapped to each message by setting
+@code{:gnu-package} for an inbox.
+
 @findex piem-merged-inboxes
 @vindex piem-get-inboxes-from-config
 If you mirror some inboxes locally (e.g., for fast local access or for
diff --git a/piem.el b/piem.el
index 568e91b..cf78d9b 100644
--- a/piem.el
+++ b/piem.el
@@ -83,6 +83,8 @@ list that supports the following properties:
       A URL hosting HTTPS archives.
   :maildir
       A Maildir directory to inject messages into.
+  :gnu-package
+      A GNU Bug Tracker label to match with for the inbox.
 
 Here's an example for the public-inbox project itself:
 
@@ -393,7 +395,9 @@ files."
                   (rx string-start "publicinbox."
                       (group (one-or-more not-newline)) "."
                       (group
-                       (or "address" "coderepo" "listid" "maildir" "url"))
+                       (or "address" "coderepo"
+                           "listid" "maildir"
+                           "url" "gnu-package"))
                       string-end)
                   key)
              (let* ((inbox-name (match-string 1 key))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v3 2/5] gnus: Skip adding mboxrd from-line when not needed
  2023-06-10  9:58 ` [PATCH v3 " jlicht
  2023-06-10  9:58   ` [PATCH v3 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
@ 2023-06-10  9:58   ` jlicht
  2023-06-10  9:58   ` [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

When using Gnus over NNTP, `gnus-summary-display-article' shows a
plain message, but when debbugs.el visits an issue message with Gnus,
it's already in mbox format.

Link: https://inbox.kyleam.com/piem/87cz2dun0y.fsf@kyleam.com
---
 piem-gnus.el | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/piem-gnus.el b/piem-gnus.el
index 4011fa2..7120512 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -56,6 +56,21 @@
             (match-string 1 mid)
           mid)))))
 
+(defun piem-gnus--from-line (buffer)
+  "Split a buffer into from-line and the rest of the message.
+
+Returns a cons of the first line of BUFFER, if it is an mboxrd
+from-line (or nil if none), and the remaining lines of BUFFER."
+  (with-current-buffer buffer
+    (let ((start (point-min))
+          (end (point-max)))
+      (goto-char start)
+      (let* ((eol (line-end-position))
+             (line (buffer-substring-no-properties start eol)))
+        (if (string-match-p "^From " line)
+            (cons line (buffer-substring-no-properties (+ eol 1) end))
+          (cons nil (buffer-substring-no-properties start end)))))))
+
 (defun piem-gnus-mid-to-thread (mid)
   (when (and (derived-mode-p 'gnus-summary-mode)
              (string-equal (substring
@@ -75,16 +90,17 @@
             gnus-break-pages)
         (mapc (lambda (article)
                 (gnus-summary-display-article article)
-                (push (format
-                       "From mboxrd@z Thu Jan  1 00:00:00 1970\n%s\n"
-                       (replace-regexp-in-string ; From-munge
-                        "^>*From "
-                        ">\\&"
-                        (with-current-buffer gnus-article-buffer
-                          (buffer-substring-no-properties
-                           (point-min)
-                           (point-max)))))
-                      messages))
+                (let ((from-line-cons
+                       (piem-gnus--from-line gnus-article-buffer)))
+                  (push (format
+                         "%s\n%s\n"
+                         (or (car from-line-cons)
+                             "From mboxrd@z Thu Jan  1 00:00:00 1970")
+                         (replace-regexp-in-string
+                          "^>*From "
+                          ">\\&"
+                          (cdr from-line-cons)))
+                        messages)))
               articles)
         (lambda ()
           (insert (apply #'concat (nreverse messages))))))))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match
  2023-06-10  9:58 ` [PATCH v3 " jlicht
  2023-06-10  9:58   ` [PATCH v3 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
  2023-06-10  9:58   ` [PATCH v3 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
@ 2023-06-10  9:58   ` jlicht
  2023-06-10 23:17     ` Kyle Meyer
  2023-06-10  9:58   ` [PATCH v3 4/5] piem-inbox-by-header-match: Fallback to matching via :gnu-package jlicht
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/piem.el b/piem.el
index cf78d9b..3a76d43 100644
--- a/piem.el
+++ b/piem.el
@@ -492,6 +492,22 @@ non-nil, make the match specific for that message."
                   (mail-decode-encoded-word-string val)))
               headers))))
 
+(defun piem-inbox-by-gnu-package-match (gnu-package)
+  "Return inbox based on matching :gnu-package properties.
+GNU-PACKAGE should be a string.  This function is intended to be
+used by libraries implementing a function for
+`piem-get-inbox-function'."
+  (when gnu-package
+    (catch 'hit
+      (dolist (inbox (piem-merged-inboxes))
+        (let* ((info (cdr inbox))
+               (p-package (plist-get info :gnu-package)))
+          (when (and gnu-package
+                     p-package
+                     (string-match-p (regexp-quote p-package)
+                                     gnu-package))
+            (throw 'hit (car inbox))))))))
+
 (defun piem-inbox-by-header-match ()
   "Return inbox based on matching message headers.
 This should be called from a buffer containing a message and is
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v3 4/5] piem-inbox-by-header-match: Fallback to matching via :gnu-package
  2023-06-10  9:58 ` [PATCH v3 " jlicht
                     ` (2 preceding siblings ...)
  2023-06-10  9:58   ` [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
@ 2023-06-10  9:58   ` jlicht
  2023-06-10  9:58   ` [PATCH v3 5/5] Add basic integration for debbugs jlicht
  2023-06-10 23:16   ` [PATCH v3 0/5] New piem-debbugs integration Kyle Meyer
  5 siblings, 0 replies; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 piem.el | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/piem.el b/piem.el
index 3a76d43..88309ab 100644
--- a/piem.el
+++ b/piem.el
@@ -513,22 +513,25 @@ used by libraries implementing a function for
 This should be called from a buffer containing a message and is
 intended to be used by libraries implementing a function for
 `piem-get-inbox-functions'."
-  (pcase-let ((`(,listid ,to ,cc)
-               (piem--message-fetch-decoded-fields '("list-id" "to" "cc"))))
-    (catch 'hit
-      (dolist (inbox (piem-merged-inboxes))
-        (let* ((info (cdr inbox))
-               (p-listid (plist-get info :listid)))
-          (when (and listid
-                     p-listid
-                     (string-match-p (concat "<" (regexp-quote p-listid) ">")
-                                     listid))
-            (throw 'hit (car inbox)))
-          (when-let ((addr (plist-get info :address))
-                     (to (mapconcat #'identity (list to cc)
-                                    " ")))
-            (when (string-match-p (regexp-quote addr) to)
-              (throw 'hit (car inbox)))))))))
+  (pcase-let ((`(,listid ,to ,cc ,gnu-package)
+               (piem--message-fetch-decoded-fields
+                '("list-id" "to" "cc" "x-gnu-pr-package"))))
+    (or (catch 'hit
+          (dolist (inbox (piem-merged-inboxes))
+            (let* ((info (cdr inbox))
+                   (p-listid (plist-get info :listid)))
+              (when (and listid
+                         p-listid
+                         (string-match-p
+                          (concat "<" (regexp-quote p-listid) ">")
+                          listid))
+                (throw 'hit (car inbox)))
+              (when-let ((addr (plist-get info :address))
+                         (to (mapconcat #'identity (list to cc)
+                                        " ")))
+                (when (string-match-p (regexp-quote addr) to)
+                  (throw 'hit (car inbox)))))))
+        (piem-inbox-by-gnu-package-match gnu-package))))
 
 (defun piem-inbox ()
   "Return the current buffer's inbox."
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v3 5/5] Add basic integration for debbugs
  2023-06-10  9:58 ` [PATCH v3 " jlicht
                     ` (3 preceding siblings ...)
  2023-06-10  9:58   ` [PATCH v3 4/5] piem-inbox-by-header-match: Fallback to matching via :gnu-package jlicht
@ 2023-06-10  9:58   ` jlicht
  2023-06-10 23:16   ` [PATCH v3 0/5] New piem-debbugs integration Kyle Meyer
  5 siblings, 0 replies; 29+ messages in thread
From: jlicht @ 2023-06-10  9:58 UTC (permalink / raw)
  To: piem; +Cc: Jelle Licht

From: Jelle Licht <jlicht@fsfe.org>

---
 Documentation/piem.texi |  2 ++
 Makefile                |  8 +++--
 piem-debbugs.el         | 67 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 piem-debbugs.el

diff --git a/Documentation/piem.texi b/Documentation/piem.texi
index 99185d3..091a054 100644
--- a/Documentation/piem.texi
+++ b/Documentation/piem.texi
@@ -222,6 +222,7 @@ command @code{piem-clear-merged-inboxes} to clear the cache.
 
 @node Enabling integration libraries
 @section Enabling integration libraries
+@findex piem-debbugs-mode
 @findex piem-elfeed-mode
 @findex piem-eww-mode
 @findex piem-gnus-mode
@@ -233,6 +234,7 @@ particular Emacs modes to link a buffer with a registered inbox.  piem
 currently has libraries to support
 
 @itemize
+@item Debbugs
 @item EWW
 @item Elfeed
 @item Gnus
diff --git a/Makefile b/Makefile
index b8d9fe6..917cbaa 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,10 @@ EMACS   = emacs
 # Rely on EMACSLOADPATH for everything but the current directory.
 BATCH   = $(EMACS) --batch -Q -L . -L tests
 
-EL = piem.el piem-b4.el piem-elfeed.el piem-eww.el piem-gnus.el \
-     piem-lei.el piem-maildir.el piem-notmuch.el piem-rmail.el \
-     tests/piem-lei-tests.el tests/piem-rmail-tests.el tests/piem-tests.el
+EL = piem.el piem-b4.el piem-debbugs.el piem-elfeed.el piem-eww.el	\
+     piem-gnus.el piem-lei.el piem-maildir.el piem-notmuch.el		\
+     piem-rmail.el tests/piem-lei-tests.el tests/piem-rmail-tests.el	\
+     tests/piem-tests.el
 ELC = $(EL:.el=.elc)
 
 all: compile Documentation/piem.info piem-autoloads.el
@@ -33,6 +34,7 @@ docs: Documentation/piem.html Documentation/piem.info
 
 piem-b4.elc: piem-b4.el piem.elc
 piem-elfeed.elc: piem-elfeed.el piem.elc
+piem-debbugs.elc: piem-debbugs.el piem.elc
 piem-eww.elc: piem-eww.el piem.elc
 piem-gnus.elc: piem-gnus.el piem.elc
 piem-lei.elc: piem-lei.el piem.elc
diff --git a/piem-debbugs.el b/piem-debbugs.el
new file mode 100644
index 0000000..00b0354
--- /dev/null
+++ b/piem-debbugs.el
@@ -0,0 +1,67 @@
+;;; piem-debbugs.el --- Debbugs integration for piem  -*- lexical-binding: t; -*-
+
+;; Copyright all piem contributors <piem@inbox.kyleam.com>
+
+;; Author: Jelle Licht <jlicht@fsfe.org>
+;; Keywords: vc, tools
+;; Package-Requires: ((emacs "26.3")(debbugs "0.29"))
+
+;; 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
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library provides a minor mode, `piem-debbugs-mode', that modifies
+;; `piem' variables to teach functions like `piem-inbox' how to
+;; extract information from Debbugs buffers.
+
+;;; Code:
+
+(require 'debbugs-gnu)
+(require 'piem)
+
+(defgroup piem-debbugs nil
+  "Debbugs integration for piem."
+  :group 'piem)
+
+(defun piem-debbugs-get-inbox ()
+  "Return inbox name from a Debbugs buffer."
+  (when (and (derived-mode-p 'debbugs-gnu-mode)
+             (boundp 'debbugs-gnu-local-query))
+    (when-let ((gnu-package (alist-get 'package debbugs-gnu-local-query)))
+      (piem-inbox-by-gnu-package-match gnu-package))))
+
+(defun piem-debbugs-get-mid ()
+  "Return the message ID of a Debbugs buffer."
+  (when (derived-mode-p 'debbugs-gnu-mode)
+    (let ((msgid (alist-get 'msgid (debbugs-gnu-current-status))))
+      (when (stringp msgid)
+        (string-trim msgid "<" ">")))))
+
+;;;###autoload
+(define-minor-mode piem-debbugs-mode
+  "Toggle Debbugs support for piem.
+With a prefix argument ARG, enable piem-debbugs mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil."
+  :global t
+  :init-value nil
+  (if piem-debbugs-mode
+      (progn
+        (add-hook 'piem-get-inbox-functions #'piem-debbugs-get-inbox)
+        (add-hook 'piem-get-mid-functions #'piem-debbugs-get-mid))
+    (remove-hook 'piem-get-inbox-functions #'piem-debbugs-get-inbox)
+    (remove-hook 'piem-get-mid-functions #'piem-debbugs-get-mid)))
+
+;;; piem-debbugs.el ends here
+(provide 'piem-debbugs)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes
  2023-06-10  4:52     ` Kyle Meyer
@ 2023-06-10 10:02       ` Jelle Licht
  0 siblings, 0 replies; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 10:02 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> With the `:gnu-package` keyword, users can configure a regex to match
>> against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.
>
> Is a regex needed, or would plain string comparison (on downcased
> string) be sufficient?

It is not needed, so I made it a plain-old-string that matches via
`regexp-quote' in V3. We can revisit this decision at any point if someone has
a need for more extensive matching.

> If it is needed, I think the documentation should be adjusted to mention
> it's a regex.  That's a bit different than the other headers, where the
> user input value itself isn't treated as a regex, even if internally the
> match is done with a regex, mostly to handle surrounding text that comes
> along with the header.  (As a complete side remark: looking at the
> :address handling, it should probably be more careful to not match just
> a substring of an address.)
>
>> ---
>> diff --git a/Documentation/piem.texi b/Documentation/piem.texi
>> index 26962a4..99185d3 100644
>> --- a/Documentation/piem.texi
>> +++ b/Documentation/piem.texi
>> @@ -168,6 +168,12 @@ repository (e.g., if the inbox receives patches for multiple projects,
>>  or if you use a few dedicated Git worktrees for different types of
>>  patches), set @code{:coderepo} to a list of locations.
>>  
>> +@cindex issue tracking
>> +@cindex Debbugs, issue tracking system
>> +When using the Debbugs instance at @uref{https://bugs.gnu.org} to
>> +retrieve messages, an inbox can mapped to each message by setting
>> +@code{:gnu-package} for an inbox.
>
> Nice, thanks for updating the texi docs.
>
> Reading this made me think about other instances (Debian, perhaps
> others), but I'll leave worrying about that until someone interested
> comes along.

AFAIK, the GNU Bug Tracker is a bespoke deployment of Debbugs, to put it
nicely. I'd be open to extending support for other instances of Debbugs,
but preferably after getting something functional merged first, if it's
all the same to you too.

>> @@ -393,7 +395,7 @@ files."
>>                    (rx string-start "publicinbox."
>>                        (group (one-or-more not-newline)) "."
>>                        (group
>> -                       (or "address" "coderepo" "listid" "maildir" "url"))
>> +                       (or "address" "coderepo" "listid" "maildir" "url" "gnu-package"))
>
> Please move "gnu-package" onto the next line to avoid going too far over
> ~80 characters.

Addressed in V3.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed.
  2023-06-10  4:55     ` Kyle Meyer
@ 2023-06-10 10:07       ` Jelle Licht
  0 siblings, 0 replies; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 10:07 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> From: Jelle Licht <jlicht@fsfe.org>
>
> Could you add a bit about why this is needed?  Basically that, at least
> over NNTP, gnus-summary-display-article shows a plain message, but when
> debbugs.el visits an issues message with Gnus, it's already in mbox
> format.
I copied over this explanation into the commit message for V3.

>
> It'd also be nice to add a link to the relevant inbox.kyleam.com thread.

Done in V3.

> (Convention nit-pick for this and subsequent patches: please drop the
> period from the subject, ignoring all Guix muscle memory :>)

Big ask, but done in V3 ;-).

>> +(defun piem-gnus--from-line (buffer)
>> +  "Returns a cons of the first line of BUFFER, if it is an
>> +mbboxrd from-line (or nil if none), and the remaining lines of
>
> typo: s/mbboxrd/mboxrd/

Done in V3.

>> +BUFFER."
>
> To follow Elisp docstring conventions, could you rewrite this so that
> the first line is self-contained sentence?

My best attempt at this, done in V3.

> It's marked as internal, so not too important, but I wonder if something
> like "piem-gnus--split-message" might give a better hint at what it
> does.

I like the current name, but not enough get out my soapbox.
Concretely, feel free to change it if you feel strongly when applying
the patches; otherwise, leaving it as-is in V3 :-).

>> +  (with-current-buffer buffer
>> +    (let ((start (point-min))
>> +          (end (point-max)))
>> +      (goto-char start)
>> +      (let* ((eol (line-end-position))
>> +             (line (buffer-substring-no-properties start eol)))
>> +        (if (string-match-p "^From " line)
>> +            (cons line (buffer-substring-no-properties (+ eol 1) end))
>> +          (cons nil (buffer-substring-no-properties start end)))))))
>
> Looks fine to me.  And I don't think we need to worry about
> save-excursion here, given that we're triggering the display of these
> buffers and, in general, this command is making lots of user-visible
> changes to the layout anyway (and we didn't know a way to avoid that:
> <87turabsb0.fsf@yoctocell.xyz>).

I looked into save-excursion here as well, but as you mention things are
already making several visible changes. A 'gnus-save-excursion' macro
would be nifty, but seems out-of-scope for piem imho.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match.
  2023-06-10  4:57     ` Kyle Meyer
@ 2023-06-10 10:08       ` Jelle Licht
  0 siblings, 0 replies; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 10:08 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> diff --git a/piem.el b/piem.el
>> index 914dd23..3fffb0e 100644
>> --- a/piem.el
>> +++ b/piem.el
>> @@ -490,6 +490,21 @@ non-nil, make the match specific for that message."
>>                    (mail-decode-encoded-word-string val)))
>>                headers))))
>>  
>> +(defun piem-inbox-by-gnu-package-match (gnu-package)
>> +  "Return inbox based on matching :gnu-package properties.
>> +GNU-PACKAGE should be a string. This function is intended to be
>
> Convention: two spaces after period

Done in V3. Any setting or .dir-locals I can use to not consistently
keep forgetting to do this?

>> +used by libraries implementing a function for
>> +`piem-get-inbox-function'."
>> +  (when gnu-package
>> +    (catch 'hit
>> +      (dolist (inbox (piem-merged-inboxes))
>> +        (let* ((info (cdr inbox))
>> +               (p-package (plist-get info :gnu-package)))
>> +          (when (and gnu-package
>> +                     p-package
>> +                     (string-match-p p-package gnu-package))
>> +            (throw 'hit (car inbox))))))))
>> +
>
> I think it's nice to have this as a separate function, and I'm guessing
> its use in the upcoming piem-debbugs.el is one of the reasons you
> decided to do that.
>
> But perhaps piem-inbox-by-gnu-package-match should still be called in
> piem-inbox-by-header-match, following the dolist there.  The main
> advantage of that is that debbugs.el also has Rmail support, so it'd let
> piem-rmail-get-inbox take advantage of this header too.  Plus, if
> piem-notmuch users want to match against X-GNU-PR-PACKAGE for whatever
> reason, even though they should have a List-ID too, it seems like we
> might as well consistently support it.

Done in V3.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header.
  2023-06-10  4:58     ` Kyle Meyer
@ 2023-06-10 10:08       ` Jelle Licht
  0 siblings, 0 replies; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 10:08 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> From: Jelle Licht <jlicht@fsfe.org>
>>
>> ---
>>  piem-gnus.el | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/piem-gnus.el b/piem-gnus.el
>> index e8e5f1e..25b80b7 100644
>> --- a/piem-gnus.el
>> +++ b/piem-gnus.el
>> @@ -42,7 +42,11 @@
>>    "Return inbox name from a Gnus article"
>>    (when (derived-mode-p 'gnus-article-mode 'gnus-summary-mode)
>>      (with-current-buffer gnus-original-article-buffer
>> -      (piem-inbox-by-header-match))))
>> +      (or (piem-inbox-by-header-match)
>> +          (let ((gnu-package
>> +                 (car (piem--message-fetch-decoded-fields
>> +                       '("x-gnu-pr-package")))))
>> +            (piem-inbox-by-gnu-package-match gnu-package))))))
>
> As mentioned in the last message, I think it'd be good to move this to
> piem-inbox-by-header-match.

Done in V3, (which drops this particular patch).

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 5/5] Add basic integration for debbugs.
  2023-06-10  4:59     ` Kyle Meyer
@ 2023-06-10 10:11       ` Jelle Licht
  0 siblings, 0 replies; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 10:11 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> From: Jelle Licht <jlicht@fsfe.org>
>>
>> ---
>>  piem-debbugs.el | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 66 insertions(+)
>>  create mode 100644 piem-debbugs.el
>
> Please also update the Makefile and piem.texi (Enabling integration
> libraries).

Done in V3, including cleaning up some warnings when running `make'.

>>
>> diff --git a/piem-debbugs.el b/piem-debbugs.el
>> new file mode 100644
>> index 0000000..8757ddd
>> --- /dev/null
>> +++ b/piem-debbugs.el
>> @@ -0,0 +1,66 @@
>> +;;; piem-debbugs.el --- debbugs.el integration for piem  -*- lexical-binding: t; -*-
>> +
>> +;; Copyright all piem contributors <piem@inbox.kyleam.com>
>> +
>> +;; Author: Kyle Meyer <kyle@kyleam.com>
>
> I think your info for author instead of mine is more appropriate, since
> you're adding this file.

Done in V3.

>> +;; Keywords: vc, tools
>> +;; Package-Requires: ((emacs "26.3"))
>
> debbugs.el isn't bundled with Emacs, so Package-Requires should list
> debbugs too.

I looked through the history of the debbugs.el project, and everything
we make use of seems to already exist debbugs.el version 0.29. Going
back even further than that seemed silly to me, as we already depend on
Emacs 26.3.

>> +(defgroup piem-debbugs nil
>> +  "debbugs integration for piem."
>> +  :group 'piem)
>> +
>> +(defun piem-debbugs-get-inbox ()
>> +  "Return inbox name from a debbugs buffer."
>> +  (when (derived-mode-p 'debbugs-gnu-mode)
>> +    (when-let ((gnu-package (alist-get 'package debbugs-gnu-local-query)))
>> +      (piem-inbox-by-gnu-package-match gnu-package))))
>> +
>> +(defun piem-debbugs-get-mid ()
>> +  "Return the message ID of a debbugs buffer."
>> +  (when (derived-mode-p 'debbugs-gnu-mode)
>> +    (let ((msgid (alist-get 'msgid (debbugs-gnu-current-status))))
>> +      (when (stringp msgid)
>> +        (string-trim msgid "<" ">")))))
>
> Nice.  I haven't tested this out yet, but that looks as clean as I was
> hoping it would.

Indeed, thanks for the guidance.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 0/5] New piem-debbugs integration
  2023-06-10  9:58 ` [PATCH v3 " jlicht
                     ` (4 preceding siblings ...)
  2023-06-10  9:58   ` [PATCH v3 5/5] Add basic integration for debbugs jlicht
@ 2023-06-10 23:16   ` Kyle Meyer
  2023-06-10 23:46     ` Jelle Licht
  5 siblings, 1 reply; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10 23:16 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> From: Jelle Licht <jlicht@fsfe.org>
>
> V3 of this series addresses most of the shortcomings identified in the
> review of V2, with a point-by-point response still on its way.

Thanks, v2 vs v3 range-diff included below.  Pushed (0a8def10) with one
minor that I'll mention in a direct reply.

1:  d079d395 ! 1:  8f41c76e piem: Add :gnu-package keyword to piem-inboxes
    @@ Metadata
      ## Commit message ##
         piem: Add :gnu-package keyword to piem-inboxes
     
    -    With the `:gnu-package` keyword, users can configure a regex to match
    +    With the `:gnu-package` keyword, users can configure a string to match
         against the X-GNU-PR-PACKAGE email header for the GNU Bug Tracker.
     
      ## Documentation/piem.texi ##
    @@ piem.el: (defun piem--merge-config-inboxes ()
                            (group (one-or-more not-newline)) "."
                            (group
     -                       (or "address" "coderepo" "listid" "maildir" "url"))
    -+                       (or "address" "coderepo" "listid" "maildir" "url" "gnu-package"))
    ++                       (or "address" "coderepo"
    ++                           "listid" "maildir"
    ++                           "url" "gnu-package"))
                            string-end)
                        key)
                   (let* ((inbox-name (match-string 1 key))
2:  cfd68e3a ! 2:  614c8fac gnus: Skip adding mboxrd from-line when not needed.
    @@ Metadata
     Author: Jelle Licht <jlicht@fsfe.org>
     
      ## Commit message ##
    -    gnus: Skip adding mboxrd from-line when not needed.
    +    gnus: Skip adding mboxrd from-line when not needed
    +
    +    When using Gnus over NNTP, `gnus-summary-display-article' shows a
    +    plain message, but when debbugs.el visits an issue message with Gnus,
    +    it's already in mbox format.
    +
    +    Link: https://inbox.kyleam.com/piem/87cz2dun0y.fsf@kyleam.com
     
      ## piem-gnus.el ##
     @@ piem-gnus.el: (defun piem-gnus-get-mid ()
    @@ piem-gnus.el: (defun piem-gnus-get-mid ()
                mid)))))
      
     +(defun piem-gnus--from-line (buffer)
    -+  "Returns a cons of the first line of BUFFER, if it is an
    -+mbboxrd from-line (or nil if none), and the remaining lines of
    -+BUFFER."
    ++  "Split a buffer into from-line and the rest of the message.
    ++
    ++Returns a cons of the first line of BUFFER, if it is an mboxrd
    ++from-line (or nil if none), and the remaining lines of BUFFER."
     +  (with-current-buffer buffer
     +    (let ((start (point-min))
     +          (end (point-max)))
3:  3d0fd6b7 ! 3:  7bd0c696 piem: Add piem-inbox-by-gnu-package-match.
    @@ Metadata
     Author: Jelle Licht <jlicht@fsfe.org>
     
      ## Commit message ##
    -    piem: Add piem-inbox-by-gnu-package-match.
    +    piem: Add piem-inbox-by-gnu-package-match
     
      ## piem.el ##
     @@ piem.el: (defun piem--message-fetch-decoded-fields (headers)
    @@ piem.el: (defun piem--message-fetch-decoded-fields (headers)
      
     +(defun piem-inbox-by-gnu-package-match (gnu-package)
     +  "Return inbox based on matching :gnu-package properties.
    -+GNU-PACKAGE should be a string. This function is intended to be
    ++GNU-PACKAGE should be a string.  This function is intended to be
     +used by libraries implementing a function for
     +`piem-get-inbox-function'."
     +  (when gnu-package
    @@ piem.el: (defun piem--message-fetch-decoded-fields (headers)
     +               (p-package (plist-get info :gnu-package)))
     +          (when (and gnu-package
     +                     p-package
    -+                     (string-match-p p-package gnu-package))
    ++                     (string-match-p (regexp-quote p-package)
    ++                                     gnu-package))
     +            (throw 'hit (car inbox))))))))
     +
      (defun piem-inbox-by-header-match ()
4:  033dfd22 < -:  -------- gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header.
-:  -------- > 4:  7d8ce7f0 piem-inbox-by-header-match: Fallback to matching via :gnu-package
5:  d74e4f02 ! 5:  0377247e Add basic integration for debbugs.
    @@ Metadata
     Author: Jelle Licht <jlicht@fsfe.org>
     
      ## Commit message ##
    -    Add basic integration for debbugs.
    +    Add basic integration for debbugs
    +
    + ## Documentation/piem.texi ##
    +@@ Documentation/piem.texi: Registering inboxes
    + 
    + @node Enabling integration libraries
    + @section Enabling integration libraries
    ++@findex piem-debbugs-mode
    + @findex piem-elfeed-mode
    + @findex piem-eww-mode
    + @findex piem-gnus-mode
    +@@ Documentation/piem.texi: Enabling integration libraries
    + currently has libraries to support
    + 
    + @itemize
    ++@item Debbugs
    + @item EWW
    + @item Elfeed
    + @item Gnus
    +
    + ## Makefile ##
    +@@ Makefile: EMACS   = emacs
    + # Rely on EMACSLOADPATH for everything but the current directory.
    + BATCH   = $(EMACS) --batch -Q -L . -L tests
    + 
    +-EL = piem.el piem-b4.el piem-elfeed.el piem-eww.el piem-gnus.el \
    +-     piem-lei.el piem-maildir.el piem-notmuch.el piem-rmail.el \
    +-     tests/piem-lei-tests.el tests/piem-rmail-tests.el tests/piem-tests.el
    ++EL = piem.el piem-b4.el piem-debbugs.el piem-elfeed.el piem-eww.el	\
    ++     piem-gnus.el piem-lei.el piem-maildir.el piem-notmuch.el		\
    ++     piem-rmail.el tests/piem-lei-tests.el tests/piem-rmail-tests.el	\
    ++     tests/piem-tests.el
    + ELC = $(EL:.el=.elc)
    + 
    + all: compile Documentation/piem.info piem-autoloads.el
    +@@ Makefile: docs: Documentation/piem.html Documentation/piem.info
    + 
    + piem-b4.elc: piem-b4.el piem.elc
    + piem-elfeed.elc: piem-elfeed.el piem.elc
    ++piem-debbugs.elc: piem-debbugs.el piem.elc
    + piem-eww.elc: piem-eww.el piem.elc
    + piem-gnus.elc: piem-gnus.el piem.elc
    + piem-lei.elc: piem-lei.el piem.elc
     
      ## piem-debbugs.el (new) ##
     @@
    -+;;; piem-debbugs.el --- debbugs.el integration for piem  -*- lexical-binding: t; -*-
    ++;;; piem-debbugs.el --- Debbugs integration for piem  -*- lexical-binding: t; -*-
     +
     +;; Copyright all piem contributors <piem@inbox.kyleam.com>
     +
    -+;; Author: Kyle Meyer <kyle@kyleam.com>
    ++;; Author: Jelle Licht <jlicht@fsfe.org>
     +;; Keywords: vc, tools
    -+;; Package-Requires: ((emacs "26.3"))
    ++;; Package-Requires: ((emacs "26.3")(debbugs "0.29"))
     +
     +;; 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
    @@ piem-debbugs.el (new)
     +
     +;; This library provides a minor mode, `piem-debbugs-mode', that modifies
     +;; `piem' variables to teach functions like `piem-inbox' how to
    -+;; extract information from debbugs buffers.
    ++;; extract information from Debbugs buffers.
     +
     +;;; Code:
     +
    -+(require 'debbugs)
    ++(require 'debbugs-gnu)
     +(require 'piem)
     +
     +(defgroup piem-debbugs nil
    -+  "debbugs integration for piem."
    ++  "Debbugs integration for piem."
     +  :group 'piem)
     +
     +(defun piem-debbugs-get-inbox ()
    -+  "Return inbox name from a debbugs buffer."
    -+  (when (derived-mode-p 'debbugs-gnu-mode)
    ++  "Return inbox name from a Debbugs buffer."
    ++  (when (and (derived-mode-p 'debbugs-gnu-mode)
    ++             (boundp 'debbugs-gnu-local-query))
     +    (when-let ((gnu-package (alist-get 'package debbugs-gnu-local-query)))
     +      (piem-inbox-by-gnu-package-match gnu-package))))
     +
     +(defun piem-debbugs-get-mid ()
    -+  "Return the message ID of a debbugs buffer."
    ++  "Return the message ID of a Debbugs buffer."
     +  (when (derived-mode-p 'debbugs-gnu-mode)
     +    (let ((msgid (alist-get 'msgid (debbugs-gnu-current-status))))
     +      (when (stringp msgid)
    @@ piem-debbugs.el (new)
     +
     +;;;###autoload
     +(define-minor-mode piem-debbugs-mode
    -+  "Toggle debbugs support for piem.
    ++  "Toggle Debbugs support for piem.
     +With a prefix argument ARG, enable piem-debbugs mode if ARG is
     +positive, and disable it otherwise.  If called from Lisp, enable
     +the mode if ARG is omitted or nil."

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match
  2023-06-10  9:58   ` [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
@ 2023-06-10 23:17     ` Kyle Meyer
  0 siblings, 0 replies; 29+ messages in thread
From: Kyle Meyer @ 2023-06-10 23:17 UTC (permalink / raw)
  To: jlicht; +Cc: piem

jlicht@fsfe.org writes:

> +(defun piem-inbox-by-gnu-package-match (gnu-package)
> +  "Return inbox based on matching :gnu-package properties.
> +GNU-PACKAGE should be a string.  This function is intended to be
> +used by libraries implementing a function for
> +`piem-get-inbox-function'."
> +  (when gnu-package
> +    (catch 'hit
> +      (dolist (inbox (piem-merged-inboxes))
> +        (let* ((info (cdr inbox))
> +               (p-package (plist-get info :gnu-package)))
> +          (when (and gnu-package
> +                     p-package
> +                     (string-match-p (regexp-quote p-package)
> +                                     gnu-package))

Adjusted to use string-equal (on downcased values).

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 0/5] New piem-debbugs integration
  2023-06-10 23:16   ` [PATCH v3 0/5] New piem-debbugs integration Kyle Meyer
@ 2023-06-10 23:46     ` Jelle Licht
  2023-06-11  0:55       ` Kyle Meyer
  0 siblings, 1 reply; 29+ messages in thread
From: Jelle Licht @ 2023-06-10 23:46 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Kyle Meyer <kyle@kyleam.com> writes:

> jlicht@fsfe.org writes:
>
>> From: Jelle Licht <jlicht@fsfe.org>
>>
>> V3 of this series addresses most of the shortcomings identified in the
>> review of V2, with a point-by-point response still on its way.
>
> Thanks, v2 vs v3 range-diff included below.  Pushed (0a8def10) with one
> minor that I'll mention in a direct reply.

Thanks for the timely reviews and help!

I am already making use of the latest-and-greatest using the following
guix package expression, and everything I care about seems to work well.

--8<---------------cut here---------------start------------->8---
(define-public emacs-piem-next
  (let ((commit "0a8def1045ac083fb8c9d523cefed91155bfb593")
        (revision "0"))
    (package
      (inherit emacs-piem)
      (version (git-version (package-version emacs-piem) revision commit))
      (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://git.kyleam.com/piem")
                    (commit commit)))
              (file-name (git-file-name (package-name emacs-piem) version))
              (sha256
               (base32
                "1mwncvhrgqkh09bg7mzb2z66p2dnxd8bchcszs9y49cgvqllw9hp"))))
      (propagated-inputs
       (modify-inputs (package-propagated-inputs emacs-piem)
         (append emacs-debbugs))))))
--8<---------------cut here---------------end--------------->8---

If you could CC me on the next release, that'd be wonderful; I can
propose an updated guix package expression (and make sure the info
manual is actually built/installed, which it is not currently).

- Jelle

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 0/5] New piem-debbugs integration
  2023-06-10 23:46     ` Jelle Licht
@ 2023-06-11  0:55       ` Kyle Meyer
  0 siblings, 0 replies; 29+ messages in thread
From: Kyle Meyer @ 2023-06-11  0:55 UTC (permalink / raw)
  To: Jelle Licht; +Cc: piem

Jelle Licht writes:

> If you could CC me on the next release, that'd be wonderful; I can
> propose an updated guix package expression (and make sure the info
> manual is actually built/installed, which it is not currently).

Sure, will do.  (I should get around to doing a release by next
weekend.)

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2023-06-11  0:55 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-08 16:59 [PATCH 1/2] piem: Add :gnu-package keyword to piem-inboxes jlicht
2023-06-08 16:59 ` [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed jlicht
2023-06-09 12:48 ` [PATCH v2 0/5] New piem-debbugs integration jlicht
2023-06-09 12:48   ` [PATCH v2 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
2023-06-10  4:52     ` Kyle Meyer
2023-06-10 10:02       ` Jelle Licht
2023-06-09 12:48   ` [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
2023-06-10  4:55     ` Kyle Meyer
2023-06-10 10:07       ` Jelle Licht
2023-06-09 12:48   ` [PATCH v2 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
2023-06-10  4:57     ` Kyle Meyer
2023-06-10 10:08       ` Jelle Licht
2023-06-09 12:48   ` [PATCH v2 4/5] gnus: Add support for matching inbox by X-GNU-PR-PACKAGE header jlicht
2023-06-10  4:58     ` Kyle Meyer
2023-06-10 10:08       ` Jelle Licht
2023-06-09 12:48   ` [PATCH v2 5/5] Add basic integration for debbugs jlicht
2023-06-10  4:59     ` Kyle Meyer
2023-06-10 10:11       ` Jelle Licht
2023-06-10  5:00   ` [PATCH v2 0/5] New piem-debbugs integration Kyle Meyer
2023-06-10  9:58 ` [PATCH v3 " jlicht
2023-06-10  9:58   ` [PATCH v3 1/5] piem: Add :gnu-package keyword to piem-inboxes jlicht
2023-06-10  9:58   ` [PATCH v3 2/5] gnus: Skip adding mboxrd from-line when not needed jlicht
2023-06-10  9:58   ` [PATCH v3 3/5] piem: Add piem-inbox-by-gnu-package-match jlicht
2023-06-10 23:17     ` Kyle Meyer
2023-06-10  9:58   ` [PATCH v3 4/5] piem-inbox-by-header-match: Fallback to matching via :gnu-package jlicht
2023-06-10  9:58   ` [PATCH v3 5/5] Add basic integration for debbugs jlicht
2023-06-10 23:16   ` [PATCH v3 0/5] New piem-debbugs integration Kyle Meyer
2023-06-10 23:46     ` Jelle Licht
2023-06-11  0:55       ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/piem/

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).