* Why does this hook not work
@ 2012-10-23 19:56 Cecil Westerhof
2012-10-24 10:44 ` Stephen Leake
0 siblings, 1 reply; 3+ messages in thread
From: Cecil Westerhof @ 2012-10-23 19:56 UTC (permalink / raw)
To: info-gnus-english
I have defined the following working hook:
(add-hook 'gnus-browse-mode-hook
(lambda ()
(define-key gnus-browse-mode-map "vu"
`(lambda ()
"Find unsubscribed groups that contains messages"
(interactive)
(search-forward-regexp "^[^ ] *[1-9]")))))
With this I find the unsubscribed groups that are not empty.
I wanted to go a step further. A lot of times I open messages in the
browser and expire them. For this I defined the following hook:
(add-hook 'gnus-article-mode-hook
(lambda ()
(define-key gnus-browse-mode-map "v"
`(lambda ()
"Open article in browser and expire it"
(interactive)
(message "got here")
(gnus-article-browse-html-article)
(gnus-summary-mark-as-expirable 1)))))
But this does not work. The v key keeps undefined. What am I doing
wrong?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Why does this hook not work
2012-10-23 19:56 Why does this hook not work Cecil Westerhof
@ 2012-10-24 10:44 ` Stephen Leake
2012-10-25 11:00 ` Cecil Westerhof
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Leake @ 2012-10-24 10:44 UTC (permalink / raw)
To: info-gnus-english
Cecil Westerhof <Cecil@decebal.nl> writes:
> I wanted to go a step further. A lot of times I open messages in the
> browser and expire them. For this I defined the following hook:
> (add-hook 'gnus-article-mode-hook
> (lambda ()
> (define-key gnus-browse-mode-map "v"
>
> But this does not work. The v key keeps undefined. What am I doing
> wrong?
I haven't tried this, but it appears you are defining this key in the
wrong map; use gnus-article-mode-map
--
-- Stephe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Why does this hook not work
2012-10-24 10:44 ` Stephen Leake
@ 2012-10-25 11:00 ` Cecil Westerhof
0 siblings, 0 replies; 3+ messages in thread
From: Cecil Westerhof @ 2012-10-25 11:00 UTC (permalink / raw)
To: info-gnus-english
Op woensdag 24 okt 2012 12:44 CEST schreef Stephen Leake:
> Cecil Westerhof <Cecil@decebal.nl> writes:
>
>> I wanted to go a step further. A lot of times I open messages in the
>> browser and expire them. For this I defined the following hook:
>> (add-hook 'gnus-article-mode-hook
>> (lambda ()
>> (define-key gnus-browse-mode-map "v"
>>
>> But this does not work. The v key keeps undefined. What am I doing
>> wrong?
>
> I haven't tried this, but it appears you are defining this key in the
> wrong map; use gnus-article-mode-map
Spot on. That is the problem with copy/paste: you can forget to
change a part of the code. It works with one hitch: after this
gnus-summary-mode is selected. I think this is a bug: when something
is executed interactive or in a batch there should be no difference in
the outcome. That is why I changed it to:
(add-hook 'gnus-article-mode-hook
(lambda ()
(define-key gnus-article-mode-map "v"
`(lambda ()
"Open article in browser and expire it"
(interactive)
(gnus-article-browse-html-article)
(gnus-summary-mark-as-expirable 1)
(when (string= major-mode "gnus-summary-mode")
(gnus-summary-next-page)
(gnus-summary-select-article-buffer))))))
I put in the when so that the function still works when the bug is
solved. ;-)
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-25 11:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-23 19:56 Why does this hook not work Cecil Westerhof
2012-10-24 10:44 ` Stephen Leake
2012-10-25 11:00 ` Cecil Westerhof
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).