Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Richard G Riley <rileyrgdev@gmail.com>
To: info-gnus-english@gnu.org
Subject: Re: Cursoring in an article : want to add a hook.
Date: Tue, 04 Mar 2008 02:09:22 +0100	[thread overview]
Message-ID: <fqi7gp$o0l$1@registered.motzarella.org> (raw)
In-Reply-To: <mailman.8245.1204569624.18990.info-gnus-english@gnu.org>

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

  parent reply	other threads:[~2008-03-04  1:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-03 15:43 Richard G Riley
2008-03-03 18:39 ` Tassilo Horn
     [not found] ` <mailman.8245.1204569624.18990.info-gnus-english@gnu.org>
2008-03-04  1:09   ` Richard G Riley [this message]
2008-03-04  9:05     ` Tassilo Horn
     [not found]     ` <mailman.8274.1204621575.18990.info-gnus-english@gnu.org>
2008-03-04 13:54       ` Richard G Riley
2008-03-04 16:49         ` Tassilo Horn
2008-03-04 16:57         ` Richard G Riley
     [not found]         ` <mailman.8291.1204649408.18990.info-gnus-english@gnu.org>
2008-03-04 17:03           ` Richard G Riley
2008-03-04 18:00           ` Richard G Riley
2008-03-04 19:10             ` Tassilo Horn
     [not found]             ` <mailman.8297.1204657843.18990.info-gnus-english@gnu.org>
2008-03-04 19:38               ` Richard G Riley
2008-03-05  7:57                 ` Tassilo Horn
2008-03-05 10:51                   ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fqi7gp$o0l$1@registered.motzarella.org' \
    --to=rileyrgdev@gmail.com \
    --cc=info-gnus-english@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).