Gnus development mailing list
 help / color / mirror / Atom feed
* From Elisp: Do stuff with article at point
@ 2014-01-07 21:29 Alexander Baier
  2014-01-08 15:16 ` Ted Zlatanov
  2014-01-08 20:59 ` Jan Tatarik
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Baier @ 2014-01-07 21:29 UTC (permalink / raw)
  To: ding

Hello,

I want to do "something" (what exactly is not really interesting I
think) with the article at point. In this scenario the cursor is either
in the summary or the article buffer.

What are the recommended means of doing something like that from emacs
lisp? Are there some functions I can take a look at, or even a macro in
the form of (with-article-at-point BODY)? Or some documentation that
adresses such questions?

Any pointers are greatly appreciated.

Regards,
-- 
 Alexander Baier



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

* Re: From Elisp: Do stuff with article at point
  2014-01-07 21:29 From Elisp: Do stuff with article at point Alexander Baier
@ 2014-01-08 15:16 ` Ted Zlatanov
  2014-01-08 16:09   ` Alexander Baier
  2014-01-08 20:59 ` Jan Tatarik
  1 sibling, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2014-01-08 15:16 UTC (permalink / raw)
  To: ding

On Tue, 07 Jan 2014 22:29:57 +0100 Alexander Baier <lexi.baier@gmail.com> wrote: 

AB> I want to do "something" (what exactly is not really interesting I
AB> think) with the article at point. In this scenario the cursor is either
AB> in the summary or the article buffer.

AB> What are the recommended means of doing something like that from emacs
AB> lisp? Are there some functions I can take a look at, or even a macro in
AB> the form of (with-article-at-point BODY)? Or some documentation that
AB> adresses such questions?

Take a look at `gnus-summary-save-article'.  Note how it can handle
multiple articles, that's a pretty common usage pattern in Gnus: mark a
number of articles, then run a single command on all of them.

Ted




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

* Re: From Elisp: Do stuff with article at point
  2014-01-08 15:16 ` Ted Zlatanov
@ 2014-01-08 16:09   ` Alexander Baier
  2014-01-08 17:22     ` Haider Rizvi
  2014-01-08 21:13     ` Ted Zlatanov
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Baier @ 2014-01-08 16:09 UTC (permalink / raw)
  To: ding

Hello Ted,

On 2014-01-08 16:16 Ted Zlatanov wrote:
> On Tue, 07 Jan 2014 22:29:57 +0100 Alexander Baier <lexi.baier@gmail.com> wrote: 
>
> AB> I want to do "something" (what exactly is not really interesting I
> AB> think) with the article at point. In this scenario the cursor is either
> AB> in the summary or the article buffer.
>
> AB> What are the recommended means of doing something like that from emacs
> AB> lisp? Are there some functions I can take a look at, or even a macro in
> AB> the form of (with-article-at-point BODY)? Or some documentation that
> AB> adresses such questions?
>
> Take a look at `gnus-summary-save-article'.  Note how it can handle
> multiple articles, that's a pretty common usage pattern in Gnus: mark a
> number of articles, then run a single command on all of them.

Thank you for the quick reply. Unfortunatley this is not what I was
looking for.  Maybe my explanation was misleading--Let me try again:

I do not want to save the article to disk, I merely want to do some
searching and copying in the buffer containing the article in question.
So I "just" need a fuction that gives me the buffer name or buffer
object of the current article at point, so that I can use it with
`with-current-buffer'.

Thanks,
-- 
 Alexander Baier



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

* Re: From Elisp: Do stuff with article at point
  2014-01-08 16:09   ` Alexander Baier
@ 2014-01-08 17:22     ` Haider Rizvi
  2014-01-08 21:13     ` Ted Zlatanov
  1 sibling, 0 replies; 7+ messages in thread
From: Haider Rizvi @ 2014-01-08 17:22 UTC (permalink / raw)
  To: ding

Alexander Baier <lexi.baier@gmail.com> writes:

> I do not want to save the article to disk, I merely want to do some
> searching and copying in the buffer containing the article in
> question.  So I "just" need a fuction that gives me the buffer name
> or buffer object of the current article at point, so that I can use
> it with `with-current-buffer'.

Sounds like the following may help you. I have coded ';' to
my-gnus-browse in gnus-summary-mode-map, which is an overloaded
function as follows. For the various scenarios, it tries to build an
appropriate url from the article, and then browse-url it.

(defun my-gnus-browse (arg)
  (interactive "p")
  (cond ((string-match ":\\(gwene\\|gmane\\)\\." gnus-newsgroup-name)
         (hr/gnus-browse-archived-at))
        ((string-match "^nnrss\." gnus-newsgroup-name)
         (browse-nnrss-url arg))
        ((string-match "^w3Forums\\|CommunitiesCategory\\|MyForums" gnus-newsgroup-name)
         (hr/gnus-browse-messageid-ibmconnections))
        ((string-match "salpha" (mail-header-from gnus-current-headers))
         (hr/gnus-browse-said-salpha))
        ))

;; this came from the gnus manual, I believe
(defun browse-nnrss-url( arg )
  (interactive "p")
  (let ((url (assq nnrss-url-field
                   (mail-header-extra
                    (gnus-data-header
                     (assq (gnus-summary-article-number)
                           gnus-newsgroup-data))))))
    (if url
        (progn
          (browse-url (cdr url))
          (gnus-summary-mark-as-read-forward 1))
      (gnus-summary-scroll-up arg))))
(add-to-list 'nnmail-extra-headers nnrss-url-field)

(defun hr/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))))


Regards, 
-- 
Haider




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

* Re: From Elisp: Do stuff with article at point
  2014-01-07 21:29 From Elisp: Do stuff with article at point Alexander Baier
  2014-01-08 15:16 ` Ted Zlatanov
@ 2014-01-08 20:59 ` Jan Tatarik
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Tatarik @ 2014-01-08 20:59 UTC (permalink / raw)
  To: ding

On Tue, Jan 07 2014, Alexander Baier wrote:

> Hello,

> I want to do "something" (what exactly is not really interesting I
> think) with the article at point. In this scenario the cursor is either
> in the summary or the article buffer.

> What are the recommended means of doing something like that from emacs
> lisp? Are there some functions I can take a look at, or even a macro in
> the form of (with-article-at-point BODY)? Or some documentation that
> adresses such questions?

How about (with-current-buffer gnus-article-buffer ...)?



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

* Re: From Elisp: Do stuff with article at point
  2014-01-08 16:09   ` Alexander Baier
  2014-01-08 17:22     ` Haider Rizvi
@ 2014-01-08 21:13     ` Ted Zlatanov
  2014-01-09 12:07       ` Alexander Baier
  1 sibling, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2014-01-08 21:13 UTC (permalink / raw)
  To: ding

On Wed, 08 Jan 2014 17:09:57 +0100 Alexander Baier <lexi.baier@gmail.com> wrote: 

AB> I do not want to save the article to disk, I merely want to do some
AB> searching and copying in the buffer containing the article in question.
AB> So I "just" need a fuction that gives me the buffer name or buffer
AB> object of the current article at point, so that I can use it with
AB> `with-current-buffer'.

As Jan suggested, `gnus-article-buffer' has the right buffer name.  It
changes as you visit specific groups.  I hope it works for you!

Ted




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

* Re: From Elisp: Do stuff with article at point
  2014-01-08 21:13     ` Ted Zlatanov
@ 2014-01-09 12:07       ` Alexander Baier
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Baier @ 2014-01-09 12:07 UTC (permalink / raw)
  To: ding

On 2014-01-08 21:59 Jan Tatarik wrote:
> How about (with-current-buffer gnus-article-buffer ...)?

On 2014-01-08 22:13 Ted Zlatanov wrote:
> As Jan suggested, `gnus-article-buffer' has the right buffer name.  It
> changes as you visit specific groups.  I hope it works for you!

I did not test this, but that seems to be exactly what I was looking
for, thank you guys!

Regards,
-- 
 Alexander Baier



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

end of thread, other threads:[~2014-01-09 12:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 21:29 From Elisp: Do stuff with article at point Alexander Baier
2014-01-08 15:16 ` Ted Zlatanov
2014-01-08 16:09   ` Alexander Baier
2014-01-08 17:22     ` Haider Rizvi
2014-01-08 21:13     ` Ted Zlatanov
2014-01-09 12:07       ` Alexander Baier
2014-01-08 20:59 ` Jan Tatarik

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