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: Tassilo Horn
Subject: Re: Cursoring in an article : want to add a hook.
Date: Tue, 04 Mar 2008 17:49:46 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux)

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:

--8<---------------cut here---------------start------------->8---
(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)))))
--8<---------------cut here---------------end--------------->8---

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
-- 
Chuck Norris doesn't see dead people. He makes people dead. 





reply via email to

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