Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Browsing to original article in gwene?
@ 2012-10-05  2:05 Haider Rizvi
  2012-10-05  4:25 ` William Gardella
  0 siblings, 1 reply; 12+ messages in thread
From: Haider Rizvi @ 2012-10-05  2:05 UTC (permalink / raw)
  To: info-gnus-english

I am starting to use gwene using gnus. I am looking for a simple key
binding (like the <ret> key) that will let me open the original
article in a browser. The url is there in the Archived-at
header. 

Looked around the web to see if it was discussed somewhere but didn't
find any relevant discussions.

For the nnrss groups, I have the browse-nnrss-url defined as per the
manual, and bound to <ret> key. Something similar (or may be <ret>
in this context) can be used?

Regards, 
-- 
Haider

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

* Re: Browsing to original article in gwene?
  2012-10-05  2:05 Browsing to original article in gwene? Haider Rizvi
@ 2012-10-05  4:25 ` William Gardella
  2012-10-05  4:32   ` William Gardella
  2012-10-05 13:25   ` Memnon Anon
  0 siblings, 2 replies; 12+ messages in thread
From: William Gardella @ 2012-10-05  4:25 UTC (permalink / raw)
  To: info-gnus-english-mXXj517/zsQ

Hello Haider,

Haider Rizvi <harizvi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I am starting to use gwene using gnus. I am looking for a simple key
> binding (like the <ret> key) that will let me open the original
> article in a browser. The url is there in the Archived-at
> header. 
>
> Looked around the web to see if it was discussed somewhere but didn't
> find any relevant discussions.
>
> For the nnrss groups, I have the browse-nnrss-url defined as per the
> manual, and bound to <ret> key. Something similar (or may be <ret>
> in this context) can be used?

I don't think there's anything set up by default, but it wouldn't be
hard to record a macro to do this.

From a Gwene summary buffer, the sequence would be:

C-u g		(to open the raw article)
s ived-a RET	(to isearch to the Archived-At: header line and leave
		point there)
M-x browse-url

It would also be pretty trivial as a proper Lisp function.

Hope that helped!
WGG

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

* Re: Browsing to original article in gwene?
  2012-10-05  4:25 ` William Gardella
@ 2012-10-05  4:32   ` William Gardella
  2012-10-05 13:25   ` Memnon Anon
  1 sibling, 0 replies; 12+ messages in thread
From: William Gardella @ 2012-10-05  4:32 UTC (permalink / raw)
  To: info-gnus-english-mXXj517/zsQ

William Gardella <gardellawg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
writes:
> I don't think there's anything set up by default, but it wouldn't be
> hard to record a macro to do this.
>
> From a Gwene summary buffer, the sequence would be:
>
> C-u g		(to open the raw article)
> s ived-a RET	(to isearch to the Archived-At: header line and leave
> 		point there)
> M-x browse-url
>
> It would also be pretty trivial as a proper Lisp function.

Oops, I forgot that RET returns to the summary line, not to the line in
the article, so your macro would need to switch buffers as well...

WGG

-- 
I use grml (http://grml.org/)

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

* Re: Browsing to original article in gwene?
  2012-10-05  4:25 ` William Gardella
  2012-10-05  4:32   ` William Gardella
@ 2012-10-05 13:25   ` Memnon Anon
  2012-10-05 15:06     ` Haider Rizvi
  2012-10-07 21:04     ` Toke Høiland-Jørgensen
  1 sibling, 2 replies; 12+ messages in thread
From: Memnon Anon @ 2012-10-05 13:25 UTC (permalink / raw)
  To: info-gnus-english

William Gardella <gardellawg@gmail.com>
writes:

> It would also be pretty trivial as a proper Lisp function.

Something like this?

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
"Start a browser for current gwene article"
  (interactive)
  (dolist (buf (buffer-list))
    (with-current-buffer buf
      (when (eq major-mode 'gnus-article-mode)
	(gnus-summary-show-article '(4))
	(switch-to-buffer buf)
	(goto-char (point-min))
	(re-search-forward "^Archived-at: <\\(.*\\)>$")
	(browse-url (match-string 1))
	(gnus-summary-show-article)))))
#+end_src

Memnon

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

* Re: Browsing to original article in gwene?
  2012-10-05 13:25   ` Memnon Anon
@ 2012-10-05 15:06     ` Haider Rizvi
  2012-10-07 21:04     ` Toke Høiland-Jørgensen
  1 sibling, 0 replies; 12+ messages in thread
From: Haider Rizvi @ 2012-10-05 15:06 UTC (permalink / raw)
  To: info-gnus-english

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> William Gardella <gardellawg@gmail.com>
> writes:
>
>> It would also be pretty trivial as a proper Lisp function.
>
> Something like this?

Thanks Memnon and William. I find that "pretty trivial Lisp" for
others turns out to be not so for me :-) The function Memnon provided
works perfectly.

For now, I have mapped browse-nnrss-url and my-gnus-browse-gwene to
separate keys, but really they do the same job for nnrss and
nntp:gwene (and gmane) groups. So I need to find a trivial wrapper
function that'll do that for me, and assing one key to that wrapper.

Regards, 
-- 
Haider

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

* Re: Browsing to original article in gwene?
  2012-10-05 13:25   ` Memnon Anon
  2012-10-05 15:06     ` Haider Rizvi
@ 2012-10-07 21:04     ` Toke Høiland-Jørgensen
  2012-10-08  6:46       ` Reiner Steib
  2012-10-08  8:13       ` Kevin Brubeck Unhammer
  1 sibling, 2 replies; 12+ messages in thread
From: Toke Høiland-Jørgensen @ 2012-10-07 21:04 UTC (permalink / raw)
  To: info-gnus-english


[-- Attachment #1.1: Type: text/plain, Size: 1405 bytes --]

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> Something like this?

I modified that function a tiny bit to make sure it doesn't throw an
error if an invalid buffer shows up in the list, and so it doesn't leave
the article unformatted if it can't find the archive-at header. It now
looks like this:

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
"Start a browser for current gwene article"
  (interactive)
  (dolist (buf (buffer-list))
    (when (buffer-live-p buf)
      (with-current-buffer buf
        (when (eq major-mode 'gnus-article-mode)
          (gnus-summary-show-article '(4))
          (switch-to-buffer buf)
          (goto-char (point-min))
          (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) t)
            (browse-url (match-string 1)))
          (gnus-summary-show-article))))))
#+end_src

I added the following to my gnus-summary-mode-hook to bind ctrl+enter to
run the function in gwene/gmane summary buffers, and unbind it otherwise
(this is not strictly necessary, but I figured I might want to use
ctrl+enter for something else in other buffers at some point...):

#+begin_src emacs-lisp
(if (string-match "g\\(we\\|ma\\)ne" (buffer-name))
  (local-set-key [(control return)] 'my-gnus-browse-gwene)
  (local-unset-key [(control return)]))
#+end_src

-Toke

-- 
Toke Høiland-Jørgensen
toke@toke.dk

[-- Attachment #1.2: Type: application/pgp-signature, Size: 489 bytes --]

[-- Attachment #2: Type: text/plain, Size: 162 bytes --]

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Browsing to original article in gwene?
  2012-10-07 21:04     ` Toke Høiland-Jørgensen
@ 2012-10-08  6:46       ` Reiner Steib
  2012-10-08 16:10         ` Haider Rizvi
  2012-10-08  8:13       ` Kevin Brubeck Unhammer
  1 sibling, 1 reply; 12+ messages in thread
From: Reiner Steib @ 2012-10-08  6:46 UTC (permalink / raw)
  To: info-gnus-english

On Sun, Oct 07 2012, Toke Høiland-Jørgensen wrote:

> #+begin_src emacs-lisp
> (defun my-gnus-browse-gwene ()
> "Start a browser for current gwene article"

AFAIK, Archived-at is not specific to Gwene.

>   (interactive)
>   (dolist (buf (buffer-list))
>     (when (buffer-live-p buf)
>       (with-current-buffer buf
>         (when (eq major-mode 'gnus-article-mode)

This might get the wrong article if `gnus-single-article-buffer' is
nil.

>           (gnus-summary-show-article '(4))

Use `gnus-original-article-buffer' ...

>           (switch-to-buffer buf)

... and `with-current-buffer'.

>           (goto-char (point-min))
>           (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) t)

There is `gnus-fetch-field'.

>             (browse-url (match-string 1)))
>           (gnus-summary-show-article))))))
> #+end_src

I'd suggest something like this:

#+begin_src emacs-lisp
(defun rs-gnus-browse-archived-at ()
  "Browse \"Archived-at\" URL of the current article."
  (interactive)
  (let (url)
    (with-current-buffer gnus-original-article-buffer
      (setq url (gnus-fetch-field "Archived-at")))
    (if (not (stringp url))
	(gnus-message 1 "No \"Archived-at\" header found.")
      (setq url (gnus-replace-in-string url "^<\\|>$" ""))
      (browse-url url))))
#+end_src

Probably it should be expanded to handle process marked articles etc.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: Browsing to original article in gwene?
  2012-10-07 21:04     ` Toke Høiland-Jørgensen
  2012-10-08  6:46       ` Reiner Steib
@ 2012-10-08  8:13       ` Kevin Brubeck Unhammer
  2012-10-08  8:39         ` Kevin Brubeck Unhammer
  1 sibling, 1 reply; 12+ messages in thread
From: Kevin Brubeck Unhammer @ 2012-10-08  8:13 UTC (permalink / raw)
  To: info-gnus-english


[-- Attachment #1.1: Type: text/plain, Size: 1764 bytes --]

Toke Høiland-Jørgensen <toke@toke.dk> writes:

> Memnon Anon <gegendosenfleisch@googlemail.com> writes:
>
>> Something like this?
>
> I modified that function a tiny bit to make sure it doesn't throw an
> error if an invalid buffer shows up in the list, and so it doesn't leave
> the article unformatted if it can't find the archive-at header. It now
> looks like this:

[…]

Note that gnus has this handy macro `gnus-with-article-buffer' that lets
you do away with the whole buffer-list loop:

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
  "Start a browser for current gwene article"
  (interactive)
  (gnus-summary-show-article '(4))
  (let ((url
	 (gnus-with-article-buffer
	   (goto-char (point-min))
	   (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) 'noerror)
	     (match-string 1)))))
    (gnus-summary-show-article)
    (if url
	(browse-url url)
      (message "Couldn't find any likely url"))))
#+end_src


Of course, if gnus had an even handier macro like

#+begin_src emacs-lisp
(defmacro gnus-with-raw-article-buffer (&rest forms)
  `(progn
     (gnus-summary-show-article '(4))
     (prog1 (gnus-with-article-buffer ,@forms)
       (gnus-summary-show-article))))
#+end_src

then you could simplify that even further to 

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
  "Start a browser for current gwene article"
  (interactive)
  (let ((url
	 (gnus-with-raw-article-buffer
	   (goto-char (point-min))
	   (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) 'noerror)
	     (match-string 1)))))
    (if url
	(browse-url url)
      (message "Couldn't find any likely url"))))
#+end_src



-- 
Kevin Brubeck Unhammer

GPG: 0x766AC60C

[-- Attachment #1.2: Type: application/pgp-signature, Size: 489 bytes --]

[-- Attachment #2: Type: text/plain, Size: 162 bytes --]

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Browsing to original article in gwene?
  2012-10-08  8:13       ` Kevin Brubeck Unhammer
@ 2012-10-08  8:39         ` Kevin Brubeck Unhammer
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Brubeck Unhammer @ 2012-10-08  8:39 UTC (permalink / raw)
  To: info-gnus-english


[-- Attachment #1.1: Type: text/plain, Size: 1520 bytes --]

Kevin Brubeck Unhammer <unhammer@fsfe.org> writes:

> Toke Høiland-Jørgensen <toke@toke.dk> writes:
>
>> Memnon Anon <gegendosenfleisch@googlemail.com> writes:
>>
>>> Something like this?
>>
>> I modified that function a tiny bit to make sure it doesn't throw an
>> error if an invalid buffer shows up in the list, and so it doesn't leave
>> the article unformatted if it can't find the archive-at header. It now
>> looks like this:
>
> […]
>
> Note that gnus has this handy macro `gnus-with-article-buffer' that lets
> you do away with the whole buffer-list loop:
>
> #+begin_src emacs-lisp
> (defun my-gnus-browse-gwene ()
>   "Start a browser for current gwene article"
>   (interactive)
>   (gnus-summary-show-article '(4))
>   (let ((url
> 	 (gnus-with-article-buffer
> 	   (goto-char (point-min))
> 	   (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) 'noerror)
> 	     (match-string 1)))))
>     (gnus-summary-show-article)
>     (if url
> 	(browse-url url)
>       (message "Couldn't find any likely url"))))
> #+end_src
>
>
> Of course, if gnus had an even handier macro like
>
> #+begin_src emacs-lisp
> (defmacro gnus-with-raw-article-buffer (&rest forms)
>   `(progn
>      (gnus-summary-show-article '(4))
>      (prog1 (gnus-with-article-buffer ,@forms)
>        (gnus-summary-show-article))))
> #+end_src

Doh, Reiner Steib found the better solution with
gnus-original-article-buffer :-)

-- 
Kevin Brubeck Unhammer

GPG: 0x766AC60C

[-- Attachment #1.2: Type: application/pgp-signature, Size: 489 bytes --]

[-- Attachment #2: Type: text/plain, Size: 162 bytes --]

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Browsing to original article in gwene?
  2012-10-08  6:46       ` Reiner Steib
@ 2012-10-08 16:10         ` Haider Rizvi
  2012-10-08 17:07           ` Haider Rizvi
  0 siblings, 1 reply; 12+ messages in thread
From: Haider Rizvi @ 2012-10-08 16:10 UTC (permalink / raw)
  To: info-gnus-english

Reiner Steib <reinersteib+gmane@imap.cc> writes:

> AFAIK, Archived-at is not specific to Gwene.

I have only seen it in gmane and gwene newsgroups. May be it exists
elsewhere as well.

Thanks to all for the helpful hints / code. I have now set a key ';'
to the following defun, which takes me to the original article in any
of nnrss, gwene and gmane groups, exactly what I wanted: 

(defun my-gnus-browse (arg)
  (interactive "p")
;  (cond ((string-match ":\(gwene\|gmane\)\." (car gnus-article-current))
  (cond ((string-match ":gwene\." (car gnus-article-current))
	  (rs-gnus-browse-archived-at))
        ((string-match ":gmane\." (car gnus-article-current))
         (rs-gnus-browse-archived-at))
	((string-match "^nnrss\." (car gnus-article-current))
	  (browse-nnrss-url arg))))

The above commented regexp is a mystery to me, it seems correct and
matches when I run it manually on (car gnus-article-current).


Regards, 
-- 
Haider

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

* Re: Browsing to original article in gwene?
  2012-10-08 16:10         ` Haider Rizvi
@ 2012-10-08 17:07           ` Haider Rizvi
  2012-10-08 19:11             ` Reiner Steib
  0 siblings, 1 reply; 12+ messages in thread
From: Haider Rizvi @ 2012-10-08 17:07 UTC (permalink / raw)
  To: info-gnus-english

Haider Rizvi <harizvi@gmail.com> writes:

> The above commented regexp is a mystery to me, it seems correct and
> matches when I run it manually on (car gnus-article-current).

Never mind, it just needed some more backslashes.

  (cond ((string-match ":\\(gwene\\|gmane\\)\\." (car gnus-article-current))


Regards, 
-- 
Haider

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

* Re: Browsing to original article in gwene?
  2012-10-08 17:07           ` Haider Rizvi
@ 2012-10-08 19:11             ` Reiner Steib
  0 siblings, 0 replies; 12+ messages in thread
From: Reiner Steib @ 2012-10-08 19:11 UTC (permalink / raw)
  To: info-gnus-english

On Mon, Oct 08 2012, Haider Rizvi wrote:

>   (cond ((string-match ":\\(gwene\\|gmane\\)\\." (car gnus-article-current))

    (cond ((string-match ":\\(gwene\\|gmane\\)\\." gnus-newsgroup-name)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

end of thread, other threads:[~2012-10-08 19:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-05  2:05 Browsing to original article in gwene? Haider Rizvi
2012-10-05  4:25 ` William Gardella
2012-10-05  4:32   ` William Gardella
2012-10-05 13:25   ` Memnon Anon
2012-10-05 15:06     ` Haider Rizvi
2012-10-07 21:04     ` Toke Høiland-Jørgensen
2012-10-08  6:46       ` Reiner Steib
2012-10-08 16:10         ` Haider Rizvi
2012-10-08 17:07           ` Haider Rizvi
2012-10-08 19:11             ` Reiner Steib
2012-10-08  8:13       ` Kevin Brubeck Unhammer
2012-10-08  8:39         ` Kevin Brubeck Unhammer

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