Gnus development mailing list
 help / color / mirror / Atom feed
* Summary minor mode for Emacs-hacking groups?
@ 2020-05-01 19:06 Eric Abrahamsen
  2020-05-01 19:24 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-01 19:06 UTC (permalink / raw)
  To: ding

I feel like I've seen other people talk about this before...

I'd like a minor-mode that can be activated in certain Gnus groups, that
buttonizes references to Emacs commit hashes, and bug-report numbers.

Basically, in all gmane.emacs.* groups, I'd like to have things that
looked like Emacs bug numbers or git commit hashes buttonized: I'd like
commit hashes to open the relevant commit in Magit, and bug numbers to
open the relevant bug report in debbugs.

Has anyone seen or made anything like this?

Eric



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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 19:06 Summary minor mode for Emacs-hacking groups? Eric Abrahamsen
@ 2020-05-01 19:24 ` Andreas Schwab
  2020-05-01 19:32   ` Eric Abrahamsen
  2020-05-01 22:34 ` Emanuel Berg
  2020-05-02  6:58 ` Tassilo Horn
  2 siblings, 1 reply; 13+ messages in thread
From: Andreas Schwab @ 2020-05-01 19:24 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

On Mai 01 2020, Eric Abrahamsen wrote:

> Basically, in all gmane.emacs.* groups, I'd like to have things that
> looked like Emacs bug numbers or git commit hashes buttonized: I'd like
> commit hashes to open the relevant commit in Magit, and bug numbers to
> open the relevant bug report in debbugs.
>
> Has anyone seen or made anything like this?

It's not difficult to write your own article treatment function.  I'd
suggest to take a look at gnus-article-add-buttons.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 19:24 ` Andreas Schwab
@ 2020-05-01 19:32   ` Eric Abrahamsen
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-01 19:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: ding

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Mai 01 2020, Eric Abrahamsen wrote:
>
>> Basically, in all gmane.emacs.* groups, I'd like to have things that
>> looked like Emacs bug numbers or git commit hashes buttonized: I'd like
>> commit hashes to open the relevant commit in Magit, and bug numbers to
>> open the relevant bug report in debbugs.
>>
>> Has anyone seen or made anything like this?
>
> It's not difficult to write your own article treatment function.  I'd
> suggest to take a look at gnus-article-add-buttons.

Well sure, I was hoping someone else had already done it :)


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 19:06 Summary minor mode for Emacs-hacking groups? Eric Abrahamsen
  2020-05-01 19:24 ` Andreas Schwab
@ 2020-05-01 22:34 ` Emanuel Berg
  2020-05-01 23:31   ` Eric Abrahamsen
  2020-05-02  6:58 ` Tassilo Horn
  2 siblings, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2020-05-01 22:34 UTC (permalink / raw)
  To: ding

Eric Abrahamsen wrote:

> I'd like a minor-mode that can be activated in
> certain Gnus groups, that buttonizes references to
> Emacs commit hashes, and bug-report numbers.

Does it have to be a minor-mode?

What about a function that parses the `thing-at-point'
and acts accordingly? Because the commit hashes and
bug-report numbers look a certain uniform way, right,
and can thus be recognized and acted upon, DWIM style?

> Has anyone seen or made anything like this?

I always thought Emacs would benefit from more
interconnectivity - which could be automated, generated
on the fly, and opted-in with an option variable so not
to enrage conservative users. (Or DWIM as above.) The
docstrings, the source code, the manuals, the info
pages including their sources, the man page(s), the web
archives and other resources, the [M]ELPA packs, it
should all be interconnected IMO to all extents
that's reasonable.


                          Fasten your seatbelt Dorothy,
                          for Kansas - is going bye-bye
                                                -Cipher


-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 22:34 ` Emanuel Berg
@ 2020-05-01 23:31   ` Eric Abrahamsen
  2020-05-05  2:44     ` Emanuel Berg
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-01 23:31 UTC (permalink / raw)
  To: ding

Emanuel Berg <moasenwood@zoho.eu> writes:

> Eric Abrahamsen wrote:
>
>> I'd like a minor-mode that can be activated in
>> certain Gnus groups, that buttonizes references to
>> Emacs commit hashes, and bug-report numbers.
>
> Does it have to be a minor-mode?
>
> What about a function that parses the `thing-at-point'
> and acts accordingly? Because the commit hashes and
> bug-report numbers look a certain uniform way, right,
> and can thus be recognized and acted upon, DWIM style?

Right, a function that is only run when the minor-mode is turned on :)

The minor mode is just because the behavior would be specific to one's
local Emacs installation. I'm subscribed to other groups where commit
hashes are referenced, entirely unrelated to Emacs, and this function
would do the wrong thing there.

>> Has anyone seen or made anything like this?
>
> I always thought Emacs would benefit from more
> interconnectivity - which could be automated, generated
> on the fly, and opted-in with an option variable so not
> to enrage conservative users. (Or DWIM as above.) The
> docstrings, the source code, the manuals, the info
> pages including their sources, the man page(s), the web
> archives and other resources, the [M]ELPA packs, it
> should all be interconnected IMO to all extents
> that's reasonable.

I'm into it in principle, but not really sure what "interconnected"
means here!


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 19:06 Summary minor mode for Emacs-hacking groups? Eric Abrahamsen
  2020-05-01 19:24 ` Andreas Schwab
  2020-05-01 22:34 ` Emanuel Berg
@ 2020-05-02  6:58 ` Tassilo Horn
  2020-05-02  7:18   ` Tassilo Horn
  2 siblings, 1 reply; 13+ messages in thread
From: Tassilo Horn @ 2020-05-02  6:58 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

Hi Eric,

> I'd like a minor-mode that can be activated in certain Gnus groups,
> that buttonizes references to Emacs commit hashes, and bug-report
> numbers.

Wouldn't just activating bug-reference-mode in gnus-article-mode with

  (setq-local bug-reference-url-format
              "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s")

deal with at least emacs bug numbers (including all GNU package bug
reports who also use GNU debbugs)?  Of course, that would just produce
clickable links and not Gnus buttons but it is readily available...

I'm gonna try that out...

Bye,
Tassilo


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-02  6:58 ` Tassilo Horn
@ 2020-05-02  7:18   ` Tassilo Horn
  2020-05-02 15:15     ` Eric Abrahamsen
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Tassilo Horn @ 2020-05-02  7:18 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Tassilo Horn <tsdh@gnu.org> writes:

> Wouldn't just activating bug-reference-mode in gnus-article-mode with
>
>   (setq-local bug-reference-url-format
>               "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s")
>
> deal with at least emacs bug numbers (including all GNU package bug
> reports who also use GNU debbugs)?  Of course, that would just produce
> clickable links and not Gnus buttons but it is readily available...
>
> I'm gonna try that out...

I did so, and it works just fine.  Things like bug#19199 are rendered as
links and invoking bug-reference-push-button (C-c RET by default) opens
the debbugs bug page in your browser.  Some adjustments could be made:

  * Tabbing through the article just recognizes Gnus buttons and not
    those bug-reference links so you have to navigate to them manually.

  * Maybe you'd want to open debbugs bugs using the debbugs emacs
    package rather than your browser (but this is nothing Gnus-related).

Bye,
Tassilo





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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-02  7:18   ` Tassilo Horn
@ 2020-05-02 15:15     ` Eric Abrahamsen
  2020-05-02 21:21     ` Eric Abrahamsen
  2020-05-07 19:03     ` Eric Abrahamsen
  2 siblings, 0 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-02 15:15 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding

Tassilo Horn <tsdh@gnu.org> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Wouldn't just activating bug-reference-mode in gnus-article-mode with
>>
>>   (setq-local bug-reference-url-format
>>               "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s")
>>
>> deal with at least emacs bug numbers (including all GNU package bug
>> reports who also use GNU debbugs)?  Of course, that would just produce
>> clickable links and not Gnus buttons but it is readily available...

Well that's what I didn't know I didn't know! Thanks for the pointer.

>> I'm gonna try that out...
>
> I did so, and it works just fine.  Things like bug#19199 are rendered as
> links and invoking bug-reference-push-button (C-c RET by default) opens
> the debbugs bug page in your browser.  Some adjustments could be made:
>
>   * Tabbing through the article just recognizes Gnus buttons and not
>     those bug-reference links so you have to navigate to them manually.
>
>   * Maybe you'd want to open debbugs bugs using the debbugs emacs
>     package rather than your browser (but this is nothing Gnus-related).

I would rather use debbugs (and use widgets), but maybe that's something
that can be added to bug-reference-mode.

Thanks again,
Eric


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-02  7:18   ` Tassilo Horn
  2020-05-02 15:15     ` Eric Abrahamsen
@ 2020-05-02 21:21     ` Eric Abrahamsen
  2020-05-07 19:03     ` Eric Abrahamsen
  2 siblings, 0 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-02 21:21 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding

Tassilo Horn <tsdh@gnu.org> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Wouldn't just activating bug-reference-mode in gnus-article-mode with
>>
>>   (setq-local bug-reference-url-format
>>               "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s")
>>
>> deal with at least emacs bug numbers (including all GNU package bug
>> reports who also use GNU debbugs)?  Of course, that would just produce
>> clickable links and not Gnus buttons but it is readily available...

I decided what I'd do is write the absolute minimum amount of code that
did exactly what I want, and then see if it could be refactored into
`bug-reference-mode'. The code below does pretty much everything, which
is sort of amazing. It's terrible code in that everything's hard-coded
and there's no error handling and no window management, but it works
remarkably well. It remains to be seen if there are enough similarities
with `bug-reference-mode' to try to add it in. `bug-reference-mode' is
very much built around overlays containing urls.

(defun gnus-buggy-open-bug (bug-str)
"Open bug number BUG-STR."
 (let ((bug-num (string-to-number bug-str)))
(unless (zerop bug-num)
(debbugs-gnu-bugs bug-num))))

(defun gnus-buggy-visit-commit (commit)
  "Visit commit with hash COMMIT using `magit'."
  (magit-status source-directory)
  (magit-show-commit commit))

(push '("\\([Bb]ug#\\([[:digit:]]+\\)\\)"
	1 (string-match-p "gmane\\.emacs" gnus-newsgroup-name)
	gnus-buggy-open-bug 2)
      gnus-button-alist)

(push '("[0-9,a-f]\\{7,40\\}"
	0 (string-match-p "gmane\\.emacs" gnus-newsgroup-name)
	gnus-buggy-visit-commit 0)
      gnus-button-alist)


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-01 23:31   ` Eric Abrahamsen
@ 2020-05-05  2:44     ` Emanuel Berg
  0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2020-05-05  2:44 UTC (permalink / raw)
  To: ding

I don't know if this has been mentioned already in
the thread but I just stumbled across this:

$ aptitude show elpa-debian-el

  [...]
  gnus-BTS - provides buttons for bug numbers seen in Gnus messages

Why this is Debian specific I don't know.

I just installed it, it also contains apt-sources,
a "major mode for editing Debian sources.list files",
and that works. So if anyone can provide a bug number
I'll report back :)

Maybe I can find one in gmane.emacs.bugs ...

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-02  7:18   ` Tassilo Horn
  2020-05-02 15:15     ` Eric Abrahamsen
  2020-05-02 21:21     ` Eric Abrahamsen
@ 2020-05-07 19:03     ` Eric Abrahamsen
  2020-05-11 16:09       ` Tassilo Horn
  2 siblings, 1 reply; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-07 19:03 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding

Tassilo Horn <tsdh@gnu.org> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Wouldn't just activating bug-reference-mode in gnus-article-mode with
>>
>>   (setq-local bug-reference-url-format
>>               "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s")
>>
>> deal with at least emacs bug numbers (including all GNU package bug
>> reports who also use GNU debbugs)?  Of course, that would just produce
>> clickable links and not Gnus buttons but it is readily available...
>>
>> I'm gonna try that out...
>
> I did so, and it works just fine.  Things like bug#19199 are rendered as
> links and invoking bug-reference-push-button (C-c RET by default) opens
> the debbugs bug page in your browser.  Some adjustments could be made:
>
>   * Tabbing through the article just recognizes Gnus buttons and not
>     those bug-reference links so you have to navigate to them manually.
>
>   * Maybe you'd want to open debbugs bugs using the debbugs emacs
>     package rather than your browser (but this is nothing Gnus-related).

Looks like you've been busy! So number two now works correctly, but
still not number one? I wonder if there's a way to get buttons and links
to be treated the same by Gnus. It would also be useful to have the bug
links be accessible to "w" in the Summary buffer.

Thanks for all the work,
Eric


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-07 19:03     ` Eric Abrahamsen
@ 2020-05-11 16:09       ` Tassilo Horn
  2020-05-14  0:28         ` Eric Abrahamsen
  0 siblings, 1 reply; 13+ messages in thread
From: Tassilo Horn @ 2020-05-11 16:09 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

Hi Eric,

>> I did so, and it works just fine.  Things like bug#19199 are rendered
>> as links and invoking bug-reference-push-button (C-c RET by default)
>> opens the debbugs bug page in your browser.  Some adjustments could
>> be made:
>>
>>   * Tabbing through the article just recognizes Gnus buttons and not
>>     those bug-reference links so you have to navigate to them manually.
>>
>>   * Maybe you'd want to open debbugs bugs using the debbugs emacs
>>     package rather than your browser (but this is nothing Gnus-related).
>
> Looks like you've been busy! So number two now works correctly, but
> still not number one? I wonder if there's a way to get buttons and
> links to be treated the same by Gnus.

This seems to work for buttonizing bug references in articles, and
hitting RET on such a button opens the bug in debbugs (if you have it
installed):

--8<---------------cut here---------------start------------->8---
modified   lisp/gnus/gnus-art.el
@@ -7945,6 +7945,15 @@ gnus-article-add-buttons
       ;; We skip the headers.
       (article-goto-body)
       (setq beg (point))
+      ;; If bug-reference-mode is active, add an entry to buttonize bug
+      ;; references.
+      (when (and (boundp 'bug-reference-mode)
+                 bug-reference-mode)
+        (declare-function bug-reference-push-button "bug-reference"
+                          (&optional pos _use-mouse-action))
+        (push (list bug-reference-bug-regexp 0 t
+                    #'bug-reference-push-button)
+              alist))
       (while (setq entry (pop alist))
 	(setq regexp (eval (car entry)))
 	(goto-char beg)
--8<---------------cut here---------------end--------------->8---

I'm not sure if that's the right place to add that functionality.

> It would also be useful to have the bug links be accessible to "w" in
> the Summary buffer.

Well, you can use C-c RET or your custom binding of
`bug-reference-push-button' when you've enabled `bug-reference-mode'
there.

Bye,
Tassilo
-- 
Dr. Tassilo Horn
SHD Einzelhandelssoftware GmbH
Rennweg 60, 56626 Andernach, Deutschland
Telefon +49 2632 295-449
Telefax +49 2632 295-100
E-Mail: hta@shd.de, Homepage: www.shd.de
Rechtsform GmbH - Sitz Andernach
Registergericht: Amtsgericht Koblenz HRB 20741
Geschäftsführer: Stefan Hahne


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

* Re: Summary minor mode for Emacs-hacking groups?
  2020-05-11 16:09       ` Tassilo Horn
@ 2020-05-14  0:28         ` Eric Abrahamsen
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2020-05-14  0:28 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding

Tassilo Horn <tsdh@gnu.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
> Hi Eric,
>
>>> I did so, and it works just fine.  Things like bug#19199 are rendered
>>> as links and invoking bug-reference-push-button (C-c RET by default)
>>> opens the debbugs bug page in your browser.  Some adjustments could
>>> be made:
>>>
>>>   * Tabbing through the article just recognizes Gnus buttons and not
>>>     those bug-reference links so you have to navigate to them manually.
>>>
>>>   * Maybe you'd want to open debbugs bugs using the debbugs emacs
>>>     package rather than your browser (but this is nothing Gnus-related).
>>
>> Looks like you've been busy! So number two now works correctly, but
>> still not number one? I wonder if there's a way to get buttons and
>> links to be treated the same by Gnus.
>
> This seems to work for buttonizing bug references in articles, and
> hitting RET on such a button opens the bug in debbugs (if you have it
> installed):
>
> modified   lisp/gnus/gnus-art.el
> @@ -7945,6 +7945,15 @@ gnus-article-add-buttons
>        ;; We skip the headers.
>        (article-goto-body)
>        (setq beg (point))
> +      ;; If bug-reference-mode is active, add an entry to buttonize bug
> +      ;; references.
> +      (when (and (boundp 'bug-reference-mode)
> +                 bug-reference-mode)
> +        (declare-function bug-reference-push-button "bug-reference"
> +                          (&optional pos _use-mouse-action))
> +        (push (list bug-reference-bug-regexp 0 t
> +                    #'bug-reference-push-button)
> +              alist))
>        (while (setq entry (pop alist))
>  	(setq regexp (eval (car entry)))
>  	(goto-char beg)
>
> I'm not sure if that's the right place to add that functionality.

Okay cool. I'm not sure that's the right place, either, but at least
you've provided the code, and that's most of the work done. I'll play
with this.

Thanks again,
Eric


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

end of thread, other threads:[~2020-05-14  0:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 19:06 Summary minor mode for Emacs-hacking groups? Eric Abrahamsen
2020-05-01 19:24 ` Andreas Schwab
2020-05-01 19:32   ` Eric Abrahamsen
2020-05-01 22:34 ` Emanuel Berg
2020-05-01 23:31   ` Eric Abrahamsen
2020-05-05  2:44     ` Emanuel Berg
2020-05-02  6:58 ` Tassilo Horn
2020-05-02  7:18   ` Tassilo Horn
2020-05-02 15:15     ` Eric Abrahamsen
2020-05-02 21:21     ` Eric Abrahamsen
2020-05-07 19:03     ` Eric Abrahamsen
2020-05-11 16:09       ` Tassilo Horn
2020-05-14  0:28         ` Eric Abrahamsen

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 NNTP newsgroup(s).