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 17:57:34 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Richard G Riley <rileyrgdev@gmail.com> writes:

> Tassilo Horn <tassilo@member.fsf.org> writes:
>
>> Richard G Riley <rileyrgdev@gmail.com> writes:
>>
>> Hi Richard,
>>
>>> 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.
>>
>> I'd suggest to save the current word in a global variable (`defvar') and
>> only update the translation if the current word is not nil and not
>> string= with the saved word.  When that's the case, do the translation
>> and save the current word in the global variable.
>
> Works well. I'd already done this last night actually but used setq. Is
> this bad?

Apologies. Well, it would work well had I posted the working code:

>
> ,----
> | 
> | (setq rdictcc-rgr-show-translations nil)
> | (setq rdictcc-rgr-last-word nil)
> | 

*snip incorrect function using EQ instead of EQUAL*

*insert working function*

(defun rdictcc-rgr-translate()
  (interactive)
  (save-selected-window
    (let ((word (rdictcc-current-word)))
      (when (and word rdictcc-rgr-show-translations (not(equal word 
rdictcc-rgr-last-word)))
        (rdictcc-translate-word word)
        (setq rdictcc-rgr-last-word word)
        )
      )
    )
  )


> | 
> | (add-hook 'w3m-after-cursor-move-hook 'rdictcc-rgr-translate)
> | 
> | (define-key gnus-article-mode-map [right] (lambda () 
> (interactive)(rdictcc-rgr-translate)(forward-char)))
> | (define-key gnus-article-mode-map [left] (lambda () 
> (interactive)(rdictcc-rgr-translate)(backward-char)))
> | (define-key gnus-article-mode-map [up] (lambda () 
> (interactive)(rdictcc-rgr-translate)(previous-line)))
> | (define-key gnus-article-mode-map [down] (lambda () 
> (interactive)(rdictcc-rgr-translate)(next-line)))
> | 
> | (global-set-key (kbd "<f5> T") 'rdictcc-rgr-translate)
> | (global-set-key (kbd "<f5> o") (lambda()(interactive)(setq 
> rdictcc-rgr-show-translations (not rdictcc-rgr-show-translations))))
> `----


reply via email to

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