info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cursoring in an article : want to add a hook.


From: Richard G Riley
Subject: Re: Cursoring in an article : want to add a hook.
Date: Tue, 04 Mar 2008 02:09:22 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Tassilo Horn <tassilo@member.fsf.org> writes:

> Richard G Riley <rileyrgdev@gmail.com> writes:
>
> Hi Richard,
>
>> Could someone suggest how I might add a hook which is called when I
>> cursor around in a Gnus article buffer?
>
> I don't know one.
>
>> I wish to add call to some rdictcc stuff which I have done
>> successfully in w3m, but dont see an equivalent for
>> 'w3m-after-cursor-move-hook for normal article buffers.
>
> You could create wrapper functions that call rdictcc followed by the
> movement command and bind them in gnus-article-mode-map.
>
> Bye,
> Tassilo

I did this and it works well enough. I now have an auto updated rdictcc
buffer when scrolling around in w3m or article buffers. Thanks for your
help. Maybe some sort of timer would be nice so it only updates the
rdictcc buffer after resting on the same word for a while - but that is
a little beyond my current experience at the moment. Another nice
addition might be to be able to set the rdictcc window height so its
always a fixed height at the bottom of the frame.

You can toggle the rdictcc auto update using f5-o in the code below.

==

(setq show-translations nil)

(defun mytranslate()
  (interactive)
;  (save-window-excursion
  (message "myt")
  (save-selected-window
    (let ((word (rdictcc-current-word)))
      (when (and word show-translations)
        (rdictcc-translate-word word)
        )
      )
    )
  )

(add-hook 'w3m-after-cursor-move-hook 'mytranslate)

(global-set-key (kbd "<f5> T") 'mytranslate)
(global-set-key (kbd "<f5> o") (lambda()(interactive)(setq show-translations 
(not show-translations))))

(define-key gnus-article-mode-map [right] (lambda () 
(interactive)(mytranslate)(forward-char)))
(define-key gnus-article-mode-map [left] (lambda () 
(interactive)(mytranslate)(backward-char)))
(define-key gnus-article-mode-map [up] (lambda () 
(interactive)(mytranslate)(previous-line)))
(define-key gnus-article-mode-map [down] (lambda () 
(interactive)(mytranslate)(next-line)))







reply via email to

[Prev in Thread] Current Thread [Next in Thread]