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 18:03:45 +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,
>
>> Works well. I'd already done this last night actually but used
>> setq. Is this bad?
>
> Not really.  You will get compiler warnings when trying to byte-compile
> it and it's not a clean style.
>
> | (defun rdictcc-rgr-translate()
> |   (interactive)
> | ;  (save-window-excursion
> |   (message "myt")
> |   (save-selected-window
> |     (let ((word (rdictcc-current-word)))
> |       (when (and word rdictcc-rgr-show-translations (not(eq word 
> rdictcc-rgr-last-word)))
> |     (rdictcc-translate-word word)
> |     )
> |       (setq rdictcc-rgr-last-word word)
> |       )
> |     )
> |   )
>
> I've "corrected" it to this:
>
> (defun rdictcc-rgr-translate()
>   (interactive)
>   (save-selected-window
>     (let ((word (rdictcc-current-word)))
>       (when (and word
>                  rdictcc-rgr-show-translations
>                  (not (string= word rdictcc-rgr-last-word)))
>       (rdictcc-translate-word word)
>         (setq rdictcc-rgr-last-word word)))))
>
> When comparing strings you normally use `string=', because two strings
> may have the same contents but are not `eq', e.g. they're not the same
> lisp object.
>
> And I've moved the last setq into the `when', cause if the word didn't
> change there's no reason to re-set it.
>
> Bye,
> Tassilo

Thanks. All pointers appreciated. I tend to only pop into elisp when I
need something and it rarely sticks into my head since its such a rare
occurrence and lisp isn't the most obvious language from coming from C
:-;



reply via email to

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